From 6b855f4155a8864d97fa7eed0806ddd90fb8181c Mon Sep 17 00:00:00 2001 From: "guozhi.li" Date: Fri, 8 Sep 2023 14:20:13 +0800 Subject: [PATCH 1/3] minio operator should not use a fixed name to Get. --- helm/operator/values.yaml | 22 +++++++++++++--------- pkg/controller/main-controller.go | 4 +++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/helm/operator/values.yaml b/helm/operator/values.yaml index 38328a133f8..4b55bb5de23 100644 --- a/helm/operator/values.yaml +++ b/helm/operator/values.yaml @@ -2,15 +2,19 @@ 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" # ### Image field: ## Image from tag (original behaviour), for example: diff --git a/pkg/controller/main-controller.go b/pkg/controller/main-controller.go index 4b31e323647..1b6f7b21e6f 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 { @@ -523,6 +523,8 @@ func (c *Controller) Start(threadiness int, stopCh <-chan struct{}) error { } go func() { + leaderRun(ctx, c, threadiness, stopCh) + return // start the leader election code loop leaderelection.RunOrDie(ctx, leaderelection.LeaderElectionConfig{ Lock: lock, From 4078965c0372d66a9294c779760d51c56ed53736 Mon Sep 17 00:00:00 2001 From: "guozhi.li" Date: Fri, 8 Sep 2023 14:27:05 +0800 Subject: [PATCH 2/3] minio operator should not use a fixed name to Get. --- pkg/controller/main-controller.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/controller/main-controller.go b/pkg/controller/main-controller.go index 1b6f7b21e6f..2bde7f7dab1 100644 --- a/pkg/controller/main-controller.go +++ b/pkg/controller/main-controller.go @@ -523,8 +523,6 @@ func (c *Controller) Start(threadiness int, stopCh <-chan struct{}) error { } go func() { - leaderRun(ctx, c, threadiness, stopCh) - return // start the leader election code loop leaderelection.RunOrDie(ctx, leaderelection.LeaderElectionConfig{ Lock: lock, From 993cac7bbfa2c9027a01ce47a3ca420f961dbf39 Mon Sep 17 00:00:00 2001 From: "guozhi.li" Date: Fri, 8 Sep 2023 17:33:00 +0800 Subject: [PATCH 3/3] change the order --- helm/operator/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/operator/values.yaml b/helm/operator/values.yaml index 4b55bb5de23..98676c0d097 100644 --- a/helm/operator/values.yaml +++ b/helm/operator/values.yaml @@ -15,6 +15,7 @@ operator: # value: "" # - name: MINIO_OPERATOR_RUNTIME # value: "OpenShift" + env: [ ] # ### Image field: ## Image from tag (original behaviour), for example: @@ -34,7 +35,6 @@ operator: imagePullSecrets: [ ] runtimeClassName: ~ initContainers: [ ] - env: [ ] replicaCount: 2 securityContext: runAsUser: 1000