diff --git a/.github/actions/deploy/entrypoint.sh b/.github/actions/deploy/entrypoint.sh index ed90b814bc..bac9e74447 100644 --- a/.github/actions/deploy/entrypoint.sh +++ b/.github/actions/deploy/entrypoint.sh @@ -20,12 +20,13 @@ cd - && kustomize build --load-restrictor LoadRestrictionsNone config/release/de kubectl delete secrets my-atlas-key --ignore-not-found -n "${ns}" kubectl create secret generic my-atlas-key --from-literal="orgId=${INPUT_ATLAS_ORG_ID}" --from-literal="publicApiKey=${INPUT_ATLAS_PUBLIC_KEY}" --from-literal="privateApiKey=${INPUT_ATLAS_PRIVATE_KEY}" -n "${ns}" +label="app.kubernetes.io/instance=mongodb-atlas-kubernetes-operator" # Wait for the Operator to start -cmd="while ! kubectl -n ${ns} get pods -l control-plane=controller-manager -o jsonpath={.items[0].status.phase} 2>/dev/null | grep -q Running ; do printf .; sleep 1; done" +cmd="while ! kubectl -n ${ns} get pods -l $label -o jsonpath={.items[0].status.phase} 2>/dev/null | grep -q Running ; do printf .; sleep 1; done" timeout --foreground "1m" bash -c "${cmd}" || true -if ! kubectl -n "${ns}" get pods -l "control-plane=controller-manager" -o 'jsonpath="{.items[0].status.phase}"' | grep -q "Running"; then +if ! kubectl -n "${ns}" get pods -l "$label" -o 'jsonpath="{.items[0].status.phase}"' | grep -q "Running"; then echo "Operator hasn't reached RUNNING state after 1 minute. The full yaml configuration for the pod is:" - kubectl -n "${ns}" get pods -l "control-plane=controller-manager" -o yaml + kubectl -n "${ns}" get pods -l "$label" -o yaml echo "Operator failed to start, exiting" exit 1 diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index e3b09e148d..aa2521bf86 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -1,8 +1,6 @@ apiVersion: v1 kind: Namespace metadata: - labels: - control-plane: controller-manager name: system --- apiVersion: apps/v1 @@ -10,17 +8,13 @@ kind: Deployment metadata: name: operator namespace: system - labels: - control-plane: operator spec: selector: matchLabels: - control-plane: controller-manager replicas: 1 template: metadata: labels: - control-plane: controller-manager spec: securityContext: runAsNonRoot: true diff --git a/config/managerwithproxy/kustomization.yaml b/config/managerwithproxy/kustomization.yaml index 1f9eb1cccd..fdb77eefec 100644 --- a/config/managerwithproxy/kustomization.yaml +++ b/config/managerwithproxy/kustomization.yaml @@ -1,8 +1,6 @@ -# Labels to add to all resources and selectors. -#commonLabels: -# app.kubernetes.io/component: controller -# app.kubernetes.io/name: mongodb-atlas-kubernetes-operator -# app.kubernetes.io/instance: mongodb-atlas-kubernetes-operator +# +# This is the main source of config for Deployment that is reused by all the configurations in 'release' folder +# resources: - ../manager diff --git a/config/rbac/auth_proxy_service.yaml b/config/rbac/auth_proxy_service.yaml index 6cf656be14..a06a7df7c9 100644 --- a/config/rbac/auth_proxy_service.yaml +++ b/config/rbac/auth_proxy_service.yaml @@ -1,8 +1,6 @@ apiVersion: v1 kind: Service metadata: - labels: - control-plane: controller-manager name: controller-manager-metrics-service namespace: system spec: @@ -10,5 +8,3 @@ spec: - name: https port: 8443 targetPort: https - selector: - control-plane: controller-manager diff --git a/config/release/base/allinone/kustomization.yaml b/config/release/base/allinone/kustomization.yaml index 34d18ba7ff..f92bd2454d 100644 --- a/config/release/base/allinone/kustomization.yaml +++ b/config/release/base/allinone/kustomization.yaml @@ -2,6 +2,12 @@ namespace: mongodb-atlas-system namePrefix: mongodb-atlas- +# Labels to add to all resources and selectors. +commonLabels: + app.kubernetes.io/component: controller + app.kubernetes.io/name: mongodb-atlas-kubernetes-operator + app.kubernetes.io/instance: mongodb-atlas-kubernetes-operator + resources: - ../../../managerwithproxy - ../../../crd diff --git a/config/release/base/clusterwide/kustomization.yaml b/config/release/base/clusterwide/kustomization.yaml index 72b93966b0..b87c9afbba 100644 --- a/config/release/base/clusterwide/kustomization.yaml +++ b/config/release/base/clusterwide/kustomization.yaml @@ -2,6 +2,11 @@ namespace: mongodb-atlas-system namePrefix: mongodb-atlas- +# Labels to add to all resources and selectors. +commonLabels: + app.kubernetes.io/component: controller + app.kubernetes.io/name: mongodb-atlas-kubernetes-operator + app.kubernetes.io/instance: mongodb-atlas-kubernetes-operator resources: - ../../../managerwithproxy diff --git a/config/release/base/namespaced/kustomization.yaml b/config/release/base/namespaced/kustomization.yaml index 86abe5b0e6..3da50aac8e 100644 --- a/config/release/base/namespaced/kustomization.yaml +++ b/config/release/base/namespaced/kustomization.yaml @@ -2,6 +2,12 @@ namespace: mongodb-atlas-system namePrefix: mongodb-atlas- +# Labels to add to all resources and selectors. +commonLabels: + app.kubernetes.io/component: controller + app.kubernetes.io/name: mongodb-atlas-kubernetes-operator + app.kubernetes.io/instance: mongodb-atlas-kubernetes-operator + resources: - ../../../managerwithproxy - ../../../rbac/namespaced diff --git a/config/webhook/service.yaml b/config/webhook/service.yaml index 31e0f82959..75cbdaf959 100644 --- a/config/webhook/service.yaml +++ b/config/webhook/service.yaml @@ -8,5 +8,3 @@ spec: ports: - port: 443 targetPort: 9443 - selector: - control-plane: controller-manager diff --git a/test/e2e/cli/kube/kubectl.go b/test/e2e/cli/kube/kubectl.go index 7ba2ce51f8..05430d8c9d 100644 --- a/test/e2e/cli/kube/kubectl.go +++ b/test/e2e/cli/kube/kubectl.go @@ -26,7 +26,7 @@ func GenKubeVersion(fullVersion string) string { // GetPodStatus status.phase func GetPodStatus(ns string) func() string { return func() string { - session := cli.Execute("kubectl", "get", "pods", "-l", "control-plane=controller-manager", "-o", "jsonpath={.items[0].status.phase}", "-n", ns) + session := cli.Execute("kubectl", "get", "pods", "-l", "app.kubernetes.io/instance=mongodb-atlas-kubernetes-operator", "-o", "jsonpath={.items[0].status.phase}", "-n", ns) return string(session.Wait("1m").Out.Contents()) } } @@ -34,7 +34,7 @@ func GetPodStatus(ns string) func() string { // DescribeOperatorPod performs "kubectl describe" to get Operator pod information func DescribeOperatorPod(ns string) func() string { return func() string { - session := cli.Execute("kubectl", "describe", "pods", "-l", "control-plane=controller-manager", "-n", ns) + session := cli.Execute("kubectl", "describe", "pods", "-l", "app.kubernetes.io/instance=mongodb-atlas-kubernetes-operator", "-n", ns) return string(session.Wait("1m").Out.Contents()) } }