Skip to content

Commit

Permalink
Allow user customize LeaderElectionID (#3577)
Browse files Browse the repository at this point in the history
* Allow user customize LeaderElectionID

* Allow user customize LeaderElectionID - helm changes
  • Loading branch information
anggao authored Sep 9, 2021
1 parent d1c29f0 commit c5f9904
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions helm-charts/seldon-core-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions helm-charts/seldon-core-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ manager:
memoryLimit: 300Mi
memoryRequest: 200Mi
logLevel: INFO
leaderElectionID: a33bd623.machinelearning.seldon.io
rbac:
configmap:
create: true
Expand Down
3 changes: 3 additions & 0 deletions operator/config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions operator/helm/split_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
12 changes: 8 additions & 4 deletions operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
Expand All @@ -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()
Expand Down Expand Up @@ -165,7 +169,7 @@ func main() {
Scheme: scheme,
MetricsBindAddress: metricsAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "a33bd623.machinelearning.seldon.io",
LeaderElectionID: leaderElectionID,
Port: webHookPort,
Namespace: namespace,
})
Expand Down

0 comments on commit c5f9904

Please sign in to comment.