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 16 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
2 changes: 1 addition & 1 deletion bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=gitops-operator
LABEL operators.operatorframework.io.bundle.channels.v1=latest,gitops-1.8
LABEL operators.operatorframework.io.bundle.channel.default.v1=latest
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.10.0+git
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.28.1
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3

Expand Down

This file was deleted.

This file was deleted.

25 changes: 15 additions & 10 deletions bundle/manifests/gitops-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,17 @@ metadata:
capabilities: Deep Insights
console.openshift.io/plugins: '["gitops-plugin"]'
containerImage: quay.io/redhat-developer/gitops-operator
createdAt: "2023-07-10T15:48:47Z"
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/builder: operator-sdk-v1.28.1
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/redhat-developer/gitops-operator
support: Red Hat
name: gitops-operator.v1.8.0
name: gitops-operator.v1.10.0-new-ns
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -865,19 +868,21 @@ spec:
- subjectaccessreviews
verbs:
- create
serviceAccountName: gitops-operator-controller-manager
serviceAccountName: openshift-gitops-operator-controller-manager
deployments:
- name: gitops-operator-controller-manager
- label:
control-plane: gitops-operator
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 All @@ -887,7 +892,7 @@ spec:
value: openshift-gitops
- name: OPERATOR_NAME
value: gitops-operator
image: quay.io/redhat-developer/gitops-operator:latest
image: quay.io/jrao/gitops-operator:1.10.0-new-ns
livenessProbe:
httpGet:
path: /healthz
Expand All @@ -911,7 +916,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 +951,7 @@ spec:
verbs:
- create
- patch
serviceAccountName: gitops-operator-controller-manager
serviceAccountName: openshift-gitops-operator-controller-manager
strategy: deployment
installModes:
- supported: false
Expand All @@ -973,4 +978,4 @@ spec:
provider:
name: Red Hat Inc
replaces: gitops-operator.v1.7.3
version: 1.8.0
version: 1.10.0-new-ns
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
2 changes: 1 addition & 1 deletion bundle/metadata/annotations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ annotations:
operators.operatorframework.io.bundle.package.v1: gitops-operator
operators.operatorframework.io.bundle.channels.v1: latest,gitops-1.8
operators.operatorframework.io.bundle.channel.default.v1: latest
operators.operatorframework.io.metrics.builder: operator-sdk-v1.10.0+git
operators.operatorframework.io.metrics.builder: operator-sdk-v1.28.1
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v3

Expand Down
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
3 changes: 2 additions & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: quay.io/redhat-developer/gitops-operator
newName: quay.io/jrao/gitops-operator
newTag: 1.10.0-new-ns
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
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -165,7 +165,7 @@ spec:

```
oc patch subscriptions.operators.coreos.com/openshift-gitops-operator \
-n openshift-operators \
-n openshift-gitops-operator \
--type='merge' \
--patch '{ "spec": { "config": { "env": [ { "name": "DISABLE_DEX", "value": "true" } ] } } }'
```
Expand Down
24 changes: 15 additions & 9 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 @@ -59,15 +60,15 @@ 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 ${NAMESPACE} --timeout=5m
for binary in "$@"; do
pod_name=$(${KUBECTL} get pods --no-headers --field-selector="status.phase!=Succeeded" -o custom-columns=":metadata.name" -n ${NAMESPACE_PREFIX}system | grep "$binary");
pod_name=$(${KUBECTL} get pods --no-headers --field-selector="status.phase!=Succeeded" -o custom-columns=":metadata.name" -n ${NAMESPACE} | grep "$binary");
if [ ! -z "$pod_name" ]; then
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 to $PREV_IMAGE";
rollback
fi
Expand Down Expand Up @@ -140,8 +141,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 @@ -288,7 +289,7 @@ function check_and_install_prerequisites {
# 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 @@ -418,9 +419,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 @@ -433,6 +438,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
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
4 changes: 2 additions & 2 deletions scripts/openshift-CI-kuttl-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export KUBECONFIG=$TMP_DIR/kubeconfig
cp $KUBECONFIG /go/src/github.com/redhat-developer/gitops-operator/kubeconfig

# Ensuring proper installation
pod=gitops-operator-controller-manager && oc get pods `oc get pods --all-namespaces | grep $pod | head -1 | awk '{print $2}'` -n openshift-operators -o yaml
subscription=gitops-operator- && oc get subscription `oc get subscription --all-namespaces | grep $subscription | head -1 | awk '{print $2}'` -n openshift-operators
pod=openshift-gitops-operator-controller-manager && oc get pods `oc get pods --all-namespaces | grep $pod | head -1 | awk '{print $2}'` -n openshift-gitops-operator -o yaml
subscription=gitops-operator- && oc get subscription `oc get subscription --all-namespaces | grep $subscription | head -1 | awk '{print $2}'` -n openshift-gitops-operator
oc wait --for=condition=Ready -n openshift-gitops pod --timeout=15m -l 'app.kubernetes.io/name in (cluster,kam,openshift-gitops-application-controller,openshift-gitops-applicationset-controller,openshift-gitops-dex-server,openshift-gitops-redis,openshift-gitops-repo-server,openshift-gitops-server)'

# Check argocd instance creation
Expand Down
Loading