Skip to content

feat: Change installation namespace #556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
31d9fd3
Merge branch 'master' of github.com:redhat-developer/gitops-operator
jaideepr97 Jan 30, 2023
71df015
Merge branch 'master' of github.com:redhat-developer/gitops-operator
jaideepr97 Jan 31, 2023
5912df9
Merge branch 'master' of github.com:redhat-developer/gitops-operator
jaideepr97 Feb 17, 2023
b4df25b
Merge branch 'master' of github.com:redhat-developer/gitops-operator
jaideepr97 Feb 28, 2023
28c87ba
Merge branch 'master' of github.com:redhat-developer/gitops-operator
jaideepr97 Apr 3, 2023
8babf3e
Merge branch 'master' of github.com:redhat-developer/gitops-operator
jaideepr97 Apr 17, 2023
34fa0dc
Merge branch 'master' of github.com:redhat-developer/gitops-operator
jaideepr97 May 8, 2023
3625dd1
pick-up hpa fixes
jaideepr97 May 8, 2023
5c3f9c0
Merge branch 'master' of github.com:redhat-developer/gitops-operator
jaideepr97 May 12, 2023
16a579f
fix merge conflicts
jaideepr97 Jun 15, 2023
50b7b67
Merge branch 'master' of github.com:redhat-developer/gitops-operator
jaideepr97 Jul 5, 2023
67e7153
support installing gitops-operator in its own namespace
jaideepr97 Jul 10, 2023
bc7630b
reverse sdk version
jaideepr97 Jul 10, 2023
56673ff
fix operator namespace in test
jaideepr97 Jul 10, 2023
41efcb9
replace openshift-operators with openshift-gitops-operator
jaideepr97 Jul 10, 2023
da8ee9b
update non-olm installation for new namespace
jaideepr97 Jul 12, 2023
0f821e8
fix unintended manifest changes
jaideepr97 Jul 27, 2023
b19adf8
resolve merge conflicts
jaideepr97 Jul 27, 2023
66c4212
resolve merge conflicts
jaideepr97 Jul 27, 2023
a4abed4
update test for failure
jaideepr97 Aug 2, 2023
58fbf49
update csv name
jaideepr97 Aug 3, 2023
5a223ae
update all remaining references to use new namespace
jaideepr97 Sep 5, 2023
3798e7f
fix merge conflicts
jaideepr97 Sep 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:

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

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.
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.
Copy link

@Srivaralakshmi Srivaralakshmi Jul 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaideepr97 A few questions:

  • Do we have any possible installation failures and underlying causes or symptoms for the same? If yes, can we have troubleshooting tips for them?
  • If not installed properly, what status(es) are available to see for the user? Please provide doc inputs with the description of the statues (es). Also, provide information on what action the users must take for each of them.

Thanks!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaideepr97 I see that the user has to just select/enable the OpenShift monitoring option while installing the GitOps Operator in the openshift-gitops-operator namespace.

  • Do we need any documentation or information like a concept/overview, or anything that we need in the Downstream documentation from the user's perspective, about monitoring metrics?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaideepr97 Can you please respond to my queries here? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Srivaralakshmi I don't know what the best place to put this info is so I'm just putting it here :

Installation instructions to be able to use this feature:

  • fresh installations of the operator will see the option to choose the namespace to install the operator in, with the recommended option already selected as openshift-gitops-operator namespace
  • users must select the check box saying Enable Operator recommended cluster monitoring on this Namespace to enable cluster monitoring

ns-installation

Usage instructions:

  • Once operator is installed, users can leverage the Observe > metrics page in the admin view to query the metrics exposed by the operator
  • At present the new operator performance metrics exposed are:
  • active_argocd_instances_total [Guage] - This metric produces the graph that tracks the total number of active argo-cd instances being managed by the operator at a given time
  • active_argocd_instances_by_phase{phase=<phase>} [Guage] - This metric produces the graph that tracks the count of active Argo CD instances by their phase [Available/Pending/Failed/unknown]
  • active_argocd_instance_reconciliation_count{namespace="<argocd-instance-ns>"} [Counter] - This metric produces the graph that tracks total number of reconciliations that have occurred for the instance in the given namespace at any given point in time
  • controller_runtime_reconcile_time_seconds_per_instance_bucket{namespace="<argocd-instance-ns>",le="0.5"} [Histogram]- This metric tracks the number of reconciliations that took under 0.5s to complete for a given instance

Any of these metrics can be queried against prometheus as described above, or can be used for more complex queries as is true with any other promql queries

reconciliations_per_instance
argocd_instances_by_phase
active_argocd_instances_total


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

Expand Down

This file was deleted.

This file was deleted.

14 changes: 8 additions & 6 deletions bundle/manifests/gitops-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ metadata:
containerImage: quay.io/redhat-developer/gitops-operator
description: Enables teams to adopt GitOps principles for managing cluster configurations
and application delivery across hybrid multi-cluster Kubernetes environments.
operatorframework.io/cluster-monitoring: "true"
operatorframework.io/suggested-namespace: openshift-gitops-operator
operators.openshift.io/infrastructure-features: '["disconnected"]'
operators.operatorframework.io/builder: operator-sdk-v1.10.0+git
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
Expand Down Expand Up @@ -865,19 +867,19 @@ spec:
- subjectaccessreviews
verbs:
- create
serviceAccountName: gitops-operator-controller-manager
serviceAccountName: openshift-gitops-operator-controller-manager
deployments:
- name: gitops-operator-controller-manager
- name: openshift-gitops-operator-controller-manager
spec:
replicas: 1
selector:
matchLabels:
control-plane: argocd-operator
control-plane: gitops-operator
strategy: {}
template:
metadata:
labels:
control-plane: argocd-operator
control-plane: gitops-operator
spec:
containers:
- command:
Expand Down Expand Up @@ -911,7 +913,7 @@ spec:
runAsNonRoot: true
securityContext:
runAsNonRoot: true
serviceAccountName: gitops-operator-controller-manager
serviceAccountName: openshift-gitops-operator-controller-manager
terminationGracePeriodSeconds: 10
permissions:
- rules:
Expand Down Expand Up @@ -946,7 +948,7 @@ spec:
verbs:
- create
- patch
serviceAccountName: gitops-operator-controller-manager
serviceAccountName: openshift-gitops-operator-controller-manager
strategy: deployment
installModes:
- supported: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ data:
resourceName: 2b63967d.openshift.io
kind: ConfigMap
metadata:
name: gitops-operator-manager-config
name: openshift-gitops-operator-manager-config
4 changes: 2 additions & 2 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Adds namespace to all resources.
namespace: gitops-operator-system
namespace: openshift-gitops-operator

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

# Labels to add to all resources and selectors.
#commonLabels:
Expand Down
8 changes: 4 additions & 4 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
kind: Namespace
metadata:
labels:
control-plane: argocd-operator
control-plane: gitops-operator
name: system
---
apiVersion: apps/v1
Expand All @@ -11,16 +11,16 @@ metadata:
name: controller-manager
namespace: system
labels:
control-plane: argocd-operator
control-plane: gitops-operator
spec:
selector:
matchLabels:
control-plane: argocd-operator
control-plane: gitops-operator
replicas: 1
template:
metadata:
labels:
control-plane: argocd-operator
control-plane: gitops-operator
spec:
securityContext:
runAsNonRoot: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ metadata:
containerImage: quay.io/redhat-developer/gitops-operator
description: Enables teams to adopt GitOps principles for managing cluster configurations
and application delivery across hybrid multi-cluster Kubernetes environments.
operatorframework.io/cluster-monitoring: "true"
operatorframework.io/suggested-namespace: openshift-gitops-operator
operators.openshift.io/infrastructure-features: '["disconnected"]'
repository: https://github.com/redhat-developer/gitops-operator
support: Red Hat
Expand Down
4 changes: 2 additions & 2 deletions config/prometheus/monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
control-plane: argocd-operator
control-plane: gitops-operator
name: controller-manager-metrics-monitor
namespace: system
spec:
Expand All @@ -17,4 +17,4 @@ spec:
insecureSkipVerify: true
selector:
matchLabels:
control-plane: argocd-operator
control-plane: gitops-operator
4 changes: 2 additions & 2 deletions config/rbac/auth_proxy_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
kind: Service
metadata:
labels:
control-plane: argocd-operator
control-plane: gitops-operator
name: controller-manager-metrics-service
namespace: system
spec:
Expand All @@ -11,4 +11,4 @@ spec:
port: 8443
targetPort: https
selector:
control-plane: argocd-operator
control-plane: gitops-operator
4 changes: 2 additions & 2 deletions config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ resources:
# Comment the following 4 lines if you want to disable
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
# which protects your /metrics endpoint.
- auth_proxy_service.yaml
# - auth_proxy_service.yaml
- auth_proxy_role.yaml
- auth_proxy_role_binding.yaml
- auth_proxy_client_clusterrole.yaml
# - auth_proxy_client_clusterrole.yaml
2 changes: 1 addition & 1 deletion docs/OpenShift GitOps Usage Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: openshift-gitops-operator
namespace: openshift-operators
namespace: openshift-gitops-operator
spec:
channel: stable
installPlanApproval: Automatic
Expand Down
38 changes: 22 additions & 16 deletions hack/non-olm-install/install-gitops-operator.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash

NAMESPACE_PREFIX=${NAMESPACE_PREFIX:-"gitops-operator-"}
NAMESPACE=${NAMESPACE:-"openshift-gitops-operator"}
NAME_PREFIX=${NAME_PREFIX:-"openshift-gitops-operator-"}
GIT_REVISION=${GIT_REVISION:-"master"}
MAX_RETRIES=3

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

pod_name=$(${KUBECTL} get pods --no-headers --field-selector="status.phase!=Succeeded" -o custom-columns=":metadata.name" -n ${NAMESPACE_PREFIX}system | grep "${1}");
pod_name=$(${KUBECTL} get pods --no-headers --field-selector="status.phase!=Succeeded" -o custom-columns=":metadata.name" -n openshift-gitops-operator | grep "${1}");
if [ -z "$pod_name" ]; then
echo "[WARN] Ignoring empty pod name"
return 0
fi
echo "[DEBUG] Pod name : $pod_name";
${KUBECTL} wait pod --for=condition=Ready $pod_name -n ${NAMESPACE_PREFIX}system --timeout=150s;
${KUBECTL} wait pod --for=condition=Ready $pod_name -n ${NAMESPACE} --timeout=150s;
if [ $? -ne 0 ]; then
echo "[INFO] Pod '$pod_name' failed to become Ready in desired time. Logs from the pod:"
${KUBECTL} logs $pod_name -n ${NAMESPACE_PREFIX}system --all-containers;
${KUBECTL} logs $pod_name -n ${NAMESPACE} --all-containers;
echo "[ERROR] Install/Upgrade failed. Performing rollback";
rollback
return 1
Expand Down Expand Up @@ -170,8 +171,8 @@ function create_kustomization_init_file() {
echo "[INFO] Creating kustomization.yaml file using manifests from revision '${GIT_REVISION}'"
echo "apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: ${NAMESPACE_PREFIX}system
namePrefix: ${NAMESPACE_PREFIX}
namespace: ${NAMESPACE}
namePrefix: ${NAME_PREFIX}
resources:
- https://github.com/redhat-developer/gitops-operator/config/crd?ref=$GIT_REVISION&timeout=90s
- https://github.com/redhat-developer/gitops-operator/config/rbac?ref=$GIT_REVISION&timeout=90s
Expand Down Expand Up @@ -344,7 +345,7 @@ function check_prerequisite() {
# if so, stores the previous version which would be used for rollback in case of
# a failure during installation.
function get_prev_operator_image() {
for image in $(${KUBECTL} get deploy/gitops-operator-controller-manager -n ${NAMESPACE_PREFIX}system -o jsonpath='{..image}' 2>/dev/null)
for image in $(${KUBECTL} get deploy/openshift-gitops-operator-controller-manager -n ${NAMESPACE} -o jsonpath='{..image}' 2>/dev/null)
do
if [[ "${image}" == *"operator"* ]]; then
PREV_OPERATOR_IMG="${image}"
Expand Down Expand Up @@ -454,7 +455,7 @@ function migrate_olm_installation() {
fi
apply_kustomize_manifests
# Check pod status if it becomes ready
check_pod_status_ready gitops-operator-controller-manager
check_pod_status_ready openshift-gitops-operator-controller-manager

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

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

# Deletes the subscription for openshift-gitops-operator
function remove_subscription() {
#Delete the gitops subscription
${KUBECTL} delete subscription openshift-gitops-operator -n openshift-operators
${KUBECTL} delete subscription openshift-gitops-operator -n ${NAMESPACE}
}

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

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

# Extract the custom configuration set in the Subscription and
# store the env settings in a file which can be sourced when running
# the non-OLM installation.
function extract_custom_env_in_subscription() {
# Get the GitOps subscription object as yaml
${KUBECTL} get subscription openshift-gitops-operator -n openshift-operators -o yaml > ${WORK_DIR}/subscription.yaml
${KUBECTL} get subscription openshift-gitops-operator -n ${NAMESPACE} -o yaml > ${WORK_DIR}/subscription.yaml
# check if config.env element is present
element=$(${YQ} '.spec.config.env' ${WORK_DIR}/subscription.yaml)
if [ "${element}" == "null" ]; then
Expand Down Expand Up @@ -547,9 +548,13 @@ function main() {
prepare_kustomize_files
print_info
echo "[INFO] Performing $MODE operation for openshift-gitops-operator..."
if [[ $MODE == "Install" ]]; then
${KUBECTL} create ns ${NAMESPACE}
${KUBECTL} label ns ${NAMESPACE} openshift.io/cluster-monitoring=true
fi
apply_kustomize_manifests
# Check pod status and rollback if necessary.
check_pod_status_ready gitops-operator-controller-manager
check_pod_status_ready openshift-gitops-operator-controller-manager
exit 0
;;
--uninstall | -u)
Expand All @@ -562,6 +567,7 @@ function main() {
# Remove the GitOpsService instance created for the default
# ArgoCD instance created in openshift-gitops namespace.
${KUBECTL} delete gitopsservice/cluster
${KUBECTL} delete ns ${NAMESPACE}
delete_kustomize_manifests
exit 0
;;
Expand Down
4 changes: 2 additions & 2 deletions hack/scripts/run-non-olm-kuttl-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ done
#replace the namespace for assert in test file

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

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

cleanup() {
Expand Down
14 changes: 7 additions & 7 deletions scripts/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function dump_cluster_state() {

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


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

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

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"
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"

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

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

function install_operator_resources() {
echo -e ">>Ensure Gitops subscription exists"
oc get subscription gitops-operator -n openshift-operators 2>/dev/null || \
oc get subscription gitops-operator -n openshift-gitops-operator 2>/dev/null || \
cat <<EOF | oc apply -f -
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: gitops-operator
namespace: openshift-operators
namespace: openshift-gitops-operator
spec:
channel: $CHANNEL
installPlanApproval: Automatic
Expand All @@ -288,7 +288,7 @@ spec:
sourceNamespace: openshift-marketplace
EOF

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

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