diff --git a/helm-charts/seldon-core-operator/README.md b/helm-charts/seldon-core-operator/README.md index 2f1aefc350..9b57dcb967 100644 --- a/helm-charts/seldon-core-operator/README.md +++ b/helm-charts/seldon-core-operator/README.md @@ -82,6 +82,7 @@ helm install seldon-core-operator seldonio/seldon-core-operator --namespace seld | manager.cpuLimit | string | `"500m"` | | | manager.cpuRequest | string | `"100m"` | | | manager.logLevel | string | `"INFO"` | | +| manager.leaderElectionID | string | `"a33bd623.machinelearning.seldon.io"` | | | manager.memoryLimit | string | `"300Mi"` | | | manager.memoryRequest | string | `"200Mi"` | | | managerCreateResources | bool | `false` | | diff --git a/helm-charts/seldon-core-operator/templates/deployment_seldon-controller-manager.yaml b/helm-charts/seldon-core-operator/templates/deployment_seldon-controller-manager.yaml index 7f0770ffba..73f96e82f9 100644 --- a/helm-charts/seldon-core-operator/templates/deployment_seldon-controller-manager.yaml +++ b/helm-charts/seldon-core-operator/templates/deployment_seldon-controller-manager.yaml @@ -36,10 +36,13 @@ spec: - --webhook-port={{ .Values.webhook.port }} - --create-resources=$(MANAGER_CREATE_RESOURCES) - --log-level=$(MANAGER_LOG_LEVEL) + - --leader-election-id=$(MANAGER_LEADER_ELECTION_ID) - '{{- if .Values.singleNamespace }}--namespace={{ include "seldon.namespace" . }}{{- end }}' command: - /manager env: + - name: MANAGER_LEADER_ELECTION_ID + value: '{{ .Values.manager.leaderElectionID }}' - name: MANAGER_LOG_LEVEL value: '{{ .Values.manager.logLevel }}' - name: WATCH_NAMESPACE diff --git a/helm-charts/seldon-core-operator/values.yaml b/helm-charts/seldon-core-operator/values.yaml index e246516028..7235ff5d7e 100644 --- a/helm-charts/seldon-core-operator/values.yaml +++ b/helm-charts/seldon-core-operator/values.yaml @@ -79,6 +79,7 @@ manager: memoryLimit: 300Mi memoryRequest: 200Mi logLevel: INFO + leaderElectionID: a33bd623.machinelearning.seldon.io rbac: configmap: create: true diff --git a/operator/config/manager/manager.yaml b/operator/config/manager/manager.yaml index 21ca5fbf40..bb3b8f755c 100644 --- a/operator/config/manager/manager.yaml +++ b/operator/config/manager/manager.yaml @@ -35,7 +35,10 @@ spec: - --webhook-port=4443 - --create-resources=$(MANAGER_CREATE_RESOURCES) - --log-level=$(MANAGER_LOG_LEVEL) + - --leader-election-id=$(MANAGER_LEADER_ELECTION_ID) env: + - name: MANAGER_LEADER_ELECTION_ID + value: "a33bd623.machinelearning.seldon.io" - name: MANAGER_LOG_LEVEL value: "INFO" - name: WATCH_NAMESPACE diff --git a/operator/helm/split_resources.py b/operator/helm/split_resources.py index 4c66d84c01..d09738c331 100644 --- a/operator/helm/split_resources.py +++ b/operator/helm/split_resources.py @@ -67,6 +67,7 @@ "ENGINE_DEFAULT_MEMORY_LIMIT": "engine.resources.memoryLimit", "ENGINE_DEFAULT_MEMORY_REQUEST": "engine.resources.memoryRequest", "MANAGER_LOG_LEVEL": "manager.logLevel", + "MANAGER_LEADER_ELECTION_ID": "manager.leaderElectionID", } HELM_VALUES_IMAGE_PULL_POLICY = "{{ .Values.image.pullPolicy }}" diff --git a/operator/main.go b/operator/main.go index 013c5bc0f3..755574be03 100644 --- a/operator/main.go +++ b/operator/main.go @@ -48,9 +48,11 @@ import ( ) const ( - logLevelEnvVar = "SELDON_LOG_LEVEL" - logLevelDefault = "INFO" - debugEnvVar = "SELDON_DEBUG" + logLevelEnvVar = "SELDON_LOG_LEVEL" + logLevelDefault = "INFO" + debugEnvVar = "SELDON_DEBUG" + leaderElectionIDEnvVar = "LEADER_ELECTION_ID" + leaderElectionIDDefault = "a33bd623.machinelearning.seldon.io" ) var ( @@ -114,6 +116,7 @@ func main() { var createResources bool var debug bool var logLevel string + var leaderElectionID string flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.") flag.BoolVar(&enableLeaderElection, "enable-leader-election", false, @@ -128,6 +131,7 @@ func main() { "Enable debug mode. Logs will be sampled and less structured.", ) flag.StringVar(&logLevel, "log-level", utils.GetEnv(logLevelEnvVar, logLevelDefault), "Log level.") + flag.StringVar(&leaderElectionID, "leader-election-id", utils.GetEnv(leaderElectionIDEnvVar, leaderElectionIDDefault), "Leader Election ID determines the name of the resource that leader election will use for holding the leader lock.") flag.Parse() ctx := context.Background() @@ -165,7 +169,7 @@ func main() { Scheme: scheme, MetricsBindAddress: metricsAddr, LeaderElection: enableLeaderElection, - LeaderElectionID: "a33bd623.machinelearning.seldon.io", + LeaderElectionID: leaderElectionID, Port: webHookPort, Namespace: namespace, })