Skip to content

Commit a5e18ed

Browse files
Merge pull request #556 from jaideepr97/change-installation-namespace
feat: Change installation namespace
2 parents d2fd0df + 3798e7f commit a5e18ed

File tree

39 files changed

+167
-128
lines changed

39 files changed

+167
-128
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ spec:
2727

2828
![a relative link](docs/assets/operatorhub-listing.png)
2929

30-
3. Install the operator using the defaults in the wizard, and wait for it to show up in the list of "Installed Operators". If it doesn't install properly, you can check on its status in the "Installed Operators" tab in the `openshift-operators` namespace.
30+
3. Install the operator in the `openshift-gitops-operator` namesapce using the defaults in the wizard, and optionally, select the checkbox to enable cluster monitoring on the namesapce. Wait for it to show up in the list of "Installed Operators". If it doesn't install properly, you can check on its status in the "Installed Operators" tab in the `openshift-gitops-operator` namespace.
3131

3232
![a relative link](docs/assets/installed-operator.png)
3333

bundle/manifests/gitops-operator-controller-manager-metrics-service_v1_service.yaml

-16
This file was deleted.

bundle/manifests/gitops-operator-metrics-reader_rbac.authorization.k8s.io_v1_clusterrole.yaml

-10
This file was deleted.

bundle/manifests/gitops-operator.clusterserviceversion.yaml

+8-6
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ metadata:
137137
containerImage: quay.io/redhat-developer/gitops-operator
138138
description: Enables teams to adopt GitOps principles for managing cluster configurations
139139
and application delivery across hybrid multi-cluster Kubernetes environments.
140+
operatorframework.io/cluster-monitoring: "true"
141+
operatorframework.io/suggested-namespace: openshift-gitops-operator
140142
operators.openshift.io/infrastructure-features: '["disconnected"]'
141143
operators.operatorframework.io/builder: operator-sdk-v1.10.0+git
142144
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
@@ -865,19 +867,19 @@ spec:
865867
- subjectaccessreviews
866868
verbs:
867869
- create
868-
serviceAccountName: gitops-operator-controller-manager
870+
serviceAccountName: openshift-gitops-operator-controller-manager
869871
deployments:
870-
- name: gitops-operator-controller-manager
872+
- name: openshift-gitops-operator-controller-manager
871873
spec:
872874
replicas: 1
873875
selector:
874876
matchLabels:
875-
control-plane: argocd-operator
877+
control-plane: gitops-operator
876878
strategy: {}
877879
template:
878880
metadata:
879881
labels:
880-
control-plane: argocd-operator
882+
control-plane: gitops-operator
881883
spec:
882884
containers:
883885
- command:
@@ -911,7 +913,7 @@ spec:
911913
runAsNonRoot: true
912914
securityContext:
913915
runAsNonRoot: true
914-
serviceAccountName: gitops-operator-controller-manager
916+
serviceAccountName: openshift-gitops-operator-controller-manager
915917
terminationGracePeriodSeconds: 10
916918
permissions:
917919
- rules:
@@ -946,7 +948,7 @@ spec:
946948
verbs:
947949
- create
948950
- patch
949-
serviceAccountName: gitops-operator-controller-manager
951+
serviceAccountName: openshift-gitops-operator-controller-manager
950952
strategy: deployment
951953
installModes:
952954
- supported: false

bundle/manifests/gitops-operator-manager-config_v1_configmap.yaml renamed to bundle/manifests/openshift-gitops-operator-manager-config_v1_configmap.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ data:
1414
resourceName: 2b63967d.openshift.io
1515
kind: ConfigMap
1616
metadata:
17-
name: gitops-operator-manager-config
17+
name: openshift-gitops-operator-manager-config

config/default/kustomization.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Adds namespace to all resources.
2-
namespace: gitops-operator-system
2+
namespace: openshift-gitops-operator
33

44
# Value of this field is prepended to the
55
# names of all resources, e.g. a deployment named
66
# "wordpress" becomes "alices-wordpress".
77
# Note that it should also match with the prefix (text before '-') of the namespace
88
# field above.
9-
namePrefix: gitops-operator-
9+
namePrefix: openshift-gitops-operator-
1010

1111
# Labels to add to all resources and selectors.
1212
#commonLabels:

config/manager/manager.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: Namespace
33
metadata:
44
labels:
5-
control-plane: argocd-operator
5+
control-plane: gitops-operator
66
name: system
77
---
88
apiVersion: apps/v1
@@ -11,16 +11,16 @@ metadata:
1111
name: controller-manager
1212
namespace: system
1313
labels:
14-
control-plane: argocd-operator
14+
control-plane: gitops-operator
1515
spec:
1616
selector:
1717
matchLabels:
18-
control-plane: argocd-operator
18+
control-plane: gitops-operator
1919
replicas: 1
2020
template:
2121
metadata:
2222
labels:
23-
control-plane: argocd-operator
23+
control-plane: gitops-operator
2424
spec:
2525
securityContext:
2626
runAsNonRoot: true

config/manifests/bases/gitops-operator.clusterserviceversion.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ metadata:
77
containerImage: quay.io/redhat-developer/gitops-operator
88
description: Enables teams to adopt GitOps principles for managing cluster configurations
99
and application delivery across hybrid multi-cluster Kubernetes environments.
10+
operatorframework.io/cluster-monitoring: "true"
11+
operatorframework.io/suggested-namespace: openshift-gitops-operator
1012
operators.openshift.io/infrastructure-features: '["disconnected"]'
1113
repository: https://github.com/redhat-developer/gitops-operator
1214
support: Red Hat

config/prometheus/monitor.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apiVersion: monitoring.coreos.com/v1
44
kind: ServiceMonitor
55
metadata:
66
labels:
7-
control-plane: argocd-operator
7+
control-plane: gitops-operator
88
name: controller-manager-metrics-monitor
99
namespace: system
1010
spec:
@@ -17,4 +17,4 @@ spec:
1717
insecureSkipVerify: true
1818
selector:
1919
matchLabels:
20-
control-plane: argocd-operator
20+
control-plane: gitops-operator

config/rbac/auth_proxy_service.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
labels:
5-
control-plane: argocd-operator
5+
control-plane: gitops-operator
66
name: controller-manager-metrics-service
77
namespace: system
88
spec:
@@ -11,4 +11,4 @@ spec:
1111
port: 8443
1212
targetPort: https
1313
selector:
14-
control-plane: argocd-operator
14+
control-plane: gitops-operator

config/rbac/kustomization.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ resources:
1212
# Comment the following 4 lines if you want to disable
1313
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
1414
# which protects your /metrics endpoint.
15-
- auth_proxy_service.yaml
15+
# - auth_proxy_service.yaml
1616
- auth_proxy_role.yaml
1717
- auth_proxy_role_binding.yaml
18-
- auth_proxy_client_clusterrole.yaml
18+
# - auth_proxy_client_clusterrole.yaml

docs/OpenShift GitOps Usage Guide.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ apiVersion: operators.coreos.com/v1alpha1
4747
kind: Subscription
4848
metadata:
4949
name: openshift-gitops-operator
50-
namespace: openshift-operators
50+
namespace: openshift-gitops-operator
5151
spec:
5252
channel: stable
5353
installPlanApproval: Automatic

hack/non-olm-install/install-gitops-operator.sh

+22-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

3-
NAMESPACE_PREFIX=${NAMESPACE_PREFIX:-"gitops-operator-"}
3+
NAMESPACE=${NAMESPACE:-"openshift-gitops-operator"}
4+
NAME_PREFIX=${NAME_PREFIX:-"openshift-gitops-operator-"}
45
GIT_REVISION=${GIT_REVISION:-"master"}
56
MAX_RETRIES=3
67

@@ -61,24 +62,24 @@ function print_help() {
6162
function check_pod_status_ready() {
6263
# Wait for the deployment rollout to complete before trying to list the pods
6364
# to ensure that only pods corresponding to the new version is considered.
64-
${KUBECTL} rollout status deploy -n ${NAMESPACE_PREFIX}system --timeout=5m
65+
${KUBECTL} rollout status deploy -n openshift-gitops-operator --timeout=5m
6566
if [ $? -ne 0 ]; then
6667
echo "[INFO] Deployments did not reach healthy state within 5m. Rolling back"
6768
else
6869
echo "[INFO] Deployments reached healthy state."
6970
return 0
7071
fi
7172

72-
pod_name=$(${KUBECTL} get pods --no-headers --field-selector="status.phase!=Succeeded" -o custom-columns=":metadata.name" -n ${NAMESPACE_PREFIX}system | grep "${1}");
73+
pod_name=$(${KUBECTL} get pods --no-headers --field-selector="status.phase!=Succeeded" -o custom-columns=":metadata.name" -n openshift-gitops-operator | grep "${1}");
7374
if [ -z "$pod_name" ]; then
7475
echo "[WARN] Ignoring empty pod name"
7576
return 0
7677
fi
7778
echo "[DEBUG] Pod name : $pod_name";
78-
${KUBECTL} wait pod --for=condition=Ready $pod_name -n ${NAMESPACE_PREFIX}system --timeout=150s;
79+
${KUBECTL} wait pod --for=condition=Ready $pod_name -n ${NAMESPACE} --timeout=150s;
7980
if [ $? -ne 0 ]; then
8081
echo "[INFO] Pod '$pod_name' failed to become Ready in desired time. Logs from the pod:"
81-
${KUBECTL} logs $pod_name -n ${NAMESPACE_PREFIX}system --all-containers;
82+
${KUBECTL} logs $pod_name -n ${NAMESPACE} --all-containers;
8283
echo "[ERROR] Install/Upgrade failed. Performing rollback";
8384
rollback
8485
return 1
@@ -170,8 +171,8 @@ function create_kustomization_init_file() {
170171
echo "[INFO] Creating kustomization.yaml file using manifests from revision '${GIT_REVISION}'"
171172
echo "apiVersion: kustomize.config.k8s.io/v1beta1
172173
kind: Kustomization
173-
namespace: ${NAMESPACE_PREFIX}system
174-
namePrefix: ${NAMESPACE_PREFIX}
174+
namespace: ${NAMESPACE}
175+
namePrefix: ${NAME_PREFIX}
175176
resources:
176177
- https://github.com/redhat-developer/gitops-operator/config/crd?ref=$GIT_REVISION&timeout=90s
177178
- https://github.com/redhat-developer/gitops-operator/config/rbac?ref=$GIT_REVISION&timeout=90s
@@ -344,7 +345,7 @@ function check_prerequisite() {
344345
# if so, stores the previous version which would be used for rollback in case of
345346
# a failure during installation.
346347
function get_prev_operator_image() {
347-
for image in $(${KUBECTL} get deploy/gitops-operator-controller-manager -n ${NAMESPACE_PREFIX}system -o jsonpath='{..image}' 2>/dev/null)
348+
for image in $(${KUBECTL} get deploy/openshift-gitops-operator-controller-manager -n ${NAMESPACE} -o jsonpath='{..image}' 2>/dev/null)
348349
do
349350
if [[ "${image}" == *"operator"* ]]; then
350351
PREV_OPERATOR_IMG="${image}"
@@ -454,7 +455,7 @@ function migrate_olm_installation() {
454455
fi
455456
apply_kustomize_manifests
456457
# Check pod status if it becomes ready
457-
check_pod_status_ready gitops-operator-controller-manager
458+
check_pod_status_ready openshift-gitops-operator-controller-manager
458459

459460
if [ $? -eq 0 ]; then
460461
# Non OLM installation is successful and its safe to remove the OLM specific
@@ -468,20 +469,20 @@ function migrate_olm_installation() {
468469
# When migrating from OLM to non OLM installation, deployment created by the OLM operator
469470
# must be scaled down to avoid 2 conflicting operators operating on the same CR.
470471
function scale_down_olm_deploy() {
471-
${KUBECTL} scale deploy/gitops-operator-controller-manager -n openshift-operators --replicas=0
472+
${KUBECTL} scale deploy/openshift-gitops-operator-controller-manager -n ${NAMESPACE} --replicas=0
472473
}
473474

474475
# If migration to non OLM installation fails, revert to OLM based installation
475476
# by scaling back the OLM created deployments from 0 to 1.
476477
# Note: Rollback is possible only if the corresponding Subscription and ClusterServiceVersion objects are available.
477478
function rollback_to_olm() {
478-
${KUBECTL} scale deploy/gitops-operator-controller-manager -n openshift-operators --replicas=1
479+
${KUBECTL} scale deploy/openshift-gitops-operator-controller-manager -n ${NAMESPACE} --replicas=1
479480
}
480481

481482
# Deletes the subscription for openshift-gitops-operator
482483
function remove_subscription() {
483484
#Delete the gitops subscription
484-
${KUBECTL} delete subscription openshift-gitops-operator -n openshift-operators
485+
${KUBECTL} delete subscription openshift-gitops-operator -n ${NAMESPACE}
485486
}
486487

487488
# Deletes the ClusterServiceVersion Object from the system
@@ -492,21 +493,21 @@ function remove_installed_csv() {
492493
echo "[INFO] No installed CSV in Subscription"
493494
return
494495
fi
495-
${KUBECTL} delete clusterserviceversion ${installedCSV} -n openshift-operators
496+
${KUBECTL} delete clusterserviceversion ${installedCSV} -n ${NAMESPACE}
496497
}
497498

498499
# Waits till the OLM removal is successful.
499500
function wait_for_olm_removal() {
500501
# Wait till the operator deployment is completely removed.
501-
${KUBECTL} wait --for=delete deploy/gitops-operator-controller-manager -n openshift-operators --timeout=60s
502+
${KUBECTL} wait --for=delete deploy/openshift-gitops-operator-controller-manager -n ${NAMESPACE} --timeout=60s
502503
}
503504

504505
# Extract the custom configuration set in the Subscription and
505506
# store the env settings in a file which can be sourced when running
506507
# the non-OLM installation.
507508
function extract_custom_env_in_subscription() {
508509
# Get the GitOps subscription object as yaml
509-
${KUBECTL} get subscription openshift-gitops-operator -n openshift-operators -o yaml > ${WORK_DIR}/subscription.yaml
510+
${KUBECTL} get subscription openshift-gitops-operator -n ${NAMESPACE} -o yaml > ${WORK_DIR}/subscription.yaml
510511
# check if config.env element is present
511512
element=$(${YQ} '.spec.config.env' ${WORK_DIR}/subscription.yaml)
512513
if [ "${element}" == "null" ]; then
@@ -547,9 +548,13 @@ function main() {
547548
prepare_kustomize_files
548549
print_info
549550
echo "[INFO] Performing $MODE operation for openshift-gitops-operator..."
551+
if [[ $MODE == "Install" ]]; then
552+
${KUBECTL} create ns ${NAMESPACE}
553+
${KUBECTL} label ns ${NAMESPACE} openshift.io/cluster-monitoring=true
554+
fi
550555
apply_kustomize_manifests
551556
# Check pod status and rollback if necessary.
552-
check_pod_status_ready gitops-operator-controller-manager
557+
check_pod_status_ready openshift-gitops-operator-controller-manager
553558
exit 0
554559
;;
555560
--uninstall | -u)
@@ -562,6 +567,7 @@ function main() {
562567
# Remove the GitOpsService instance created for the default
563568
# ArgoCD instance created in openshift-gitops namespace.
564569
${KUBECTL} delete gitopsservice/cluster
570+
${KUBECTL} delete ns ${NAMESPACE}
565571
delete_kustomize_manifests
566572
exit 0
567573
;;

hack/scripts/run-non-olm-kuttl-test.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ done
5555
#replace the namespace for assert in test file
5656

5757
if [ -d "$temp_dir/sequential/1-018_validate_disable_default_instance" ]; then
58-
sed -i 's/openshift-operators/gitops-operator-system/g' $temp_dir/sequential/1-018_validate_disable_default_instance/02-assert.yaml
58+
sed -i 's/openshift-operators/openshift-gitops-operator/g' $temp_dir/sequential/1-018_validate_disable_default_instance/02-assert.yaml
5959
fi
6060

6161
if [ -d "$temp_dir/sequential/1-035_validate_argocd_secret_repopulate" ]; then
62-
sed -i 's/openshift-operators/gitops-operator-system/g' $temp_dir/sequential/1-035_validate_argocd_secret_repopulate/04-check_controller_pod_status.yaml
62+
sed -i 's/openshift-operators/openshift-gitops-operator/g' $temp_dir/sequential/1-035_validate_argocd_secret_repopulate/04-check_controller_pod_status.yaml
6363
fi
6464

6565
cleanup() {

scripts/e2e-common.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function dump_cluster_state() {
134134

135135
function dump_extra_cluster_state() {
136136
echo ">>> Gitops controller log:"
137-
kubectl -n openshift-operators logs $(get_app_pod argocd-operator openshift-operators) --all-containers=true
137+
kubectl -n openshift-gitops-operator logs $(get_app_pod argocd-operator openshift-gitops-operator) --all-containers=true
138138
}
139139

140140

@@ -251,11 +251,11 @@ function uninstall_operator_resources() {
251251
oc wait --for=delete $deployment -n openshift-gitops --timeout=5m || fail_test "Failed to delete deployment: $deployment in openshift-gitops namespace"
252252
done
253253

254-
oc delete $(oc get csv -n openshift-operators -o name|grep gitops) -n openshift-operators || fail_test "Unable to delete CSV"
254+
oc delete $(oc get csv -n openshift-gitops-operator -o name|grep gitops) -n openshift-gitops-operator || fail_test "Unable to delete CSV"
255255

256-
oc delete -n openshift-operators installplan $(oc get subscription gitops-operator -n openshift-operators -o jsonpath='{.status.installplan.name}') || fail_test "Unable to delete installplan"
256+
oc delete -n openshift-gitops-operator installplan $(oc get subscription gitops-operator -n openshift-gitops-operator -o jsonpath='{.status.installplan.name}') || fail_test "Unable to delete installplan"
257257

258-
oc delete subscription gitops-operator -n openshift-operators --cascade=background || fail_test "Unable to delete subscription"
258+
oc delete subscription gitops-operator -n openshift-gitops-operator --cascade=background || fail_test "Unable to delete subscription"
259259

260260
echo -e ">> Delete arogo resources accross all namespaces"
261261
for res in applications applicationsets appprojects argocds; do
@@ -273,13 +273,13 @@ function uninstall_operator_resources() {
273273

274274
function install_operator_resources() {
275275
echo -e ">>Ensure Gitops subscription exists"
276-
oc get subscription gitops-operator -n openshift-operators 2>/dev/null || \
276+
oc get subscription gitops-operator -n openshift-gitops-operator 2>/dev/null || \
277277
cat <<EOF | oc apply -f -
278278
apiVersion: operators.coreos.com/v1alpha1
279279
kind: Subscription
280280
metadata:
281281
name: gitops-operator
282-
namespace: openshift-operators
282+
namespace: openshift-gitops-operator
283283
spec:
284284
channel: $CHANNEL
285285
installPlanApproval: Automatic
@@ -288,7 +288,7 @@ spec:
288288
sourceNamespace: openshift-marketplace
289289
EOF
290290

291-
wait_until_pods_running "openshift-operators" || fail_test "openshift gitops Operator controller did not come up"
291+
wait_until_pods_running "openshift-gitops-operator" || fail_test "openshift gitops Operator controller did not come up"
292292

293293
echo ">> Wait for GitopsService creation"
294294
wait_until_object_exist "gitopsservices.pipelines.openshift.io" "cluster" "openshift-gitops" || fail_test "gitops service haven't created yet"

0 commit comments

Comments
 (0)