From 2f9b7b65312366e3b5c486a51da93bce9a36d66d Mon Sep 17 00:00:00 2001 From: jiuker <2818723467@qq.com> Date: Fri, 8 Sep 2023 23:21:37 +0800 Subject: [PATCH] fix: allow configuring custom operator deployment name (#1762) --- helm/operator/values.yaml | 24 ++++++++++++++---------- pkg/controller/main-controller.go | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/helm/operator/values.yaml b/helm/operator/values.yaml index 38328a133f8..98676c0d097 100644 --- a/helm/operator/values.yaml +++ b/helm/operator/values.yaml @@ -2,15 +2,20 @@ operator: ## Setup environment variables for the Operator - # env: - # - name: MINIO_CONSOLE_TLS_ENABLE - # value: "off" - # - name: CLUSTER_DOMAIN - # value: "cluster.domain" - # - name: WATCHED_NAMESPACE - # value: "" - # - name: MINIO_OPERATOR_RUNTIME - # value: "OpenShift" +# env: +# - name: MINIO_OPERATOR_DEPLOYMENT_NAME +# valueFrom: +# fieldRef: +# fieldPath: metadata.labels['app.kubernetes.io/name'] +# - name: MINIO_CONSOLE_TLS_ENABLE +# value: "off" +# - name: CLUSTER_DOMAIN +# value: "cluster.domain" +# - name: WATCHED_NAMESPACE +# value: "" +# - name: MINIO_OPERATOR_RUNTIME +# value: "OpenShift" + env: [ ] # ### Image field: ## Image from tag (original behaviour), for example: @@ -30,7 +35,6 @@ operator: imagePullSecrets: [ ] runtimeClassName: ~ initContainers: [ ] - env: [ ] replicaCount: 2 securityContext: runAsUser: 1000 diff --git a/pkg/controller/main-controller.go b/pkg/controller/main-controller.go index 4b31e323647..2bde7f7dab1 100644 --- a/pkg/controller/main-controller.go +++ b/pkg/controller/main-controller.go @@ -231,7 +231,7 @@ func NewController(podName string, namespacesToWatch set.StringSet, kubeClientSe ns := miniov2.GetNSFromFile() ctx := context.Background() oprImg := DefaultOperatorImage - oprDep, err := kubeClientSet.AppsV1().Deployments(ns).Get(ctx, DefaultDeploymentName, metav1.GetOptions{}) + oprDep, err := kubeClientSet.AppsV1().Deployments(ns).Get(ctx, getOperatorDeploymentName(), metav1.GetOptions{}) if err == nil && oprDep != nil { // assume we are the first container, just in case they changed the default name if len(oprDep.Spec.Template.Spec.Containers) > 0 {