Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ spec:
secretKeyRef:
key: SERVICE_PASSWORD
name: {{ include "openstack-hypervisor-operator.fullname" . }}-secret
- name: LABEL_SELECTOR
value: {{ quote .Values.controllerManager.manager.env.labelSelector }}
- name: KUBERNETES_CLUSTER_DOMAIN
value: {{ quote .Values.kubernetesClusterDomain }}
image: {{ .Values.controllerManager.manager.image.repository }}:{{ .Values.controllerManager.manager.image.tag
Expand Down
2 changes: 2 additions & 0 deletions charts/openstack-hypervisor-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ controllerManager:
- --metrics-bind-address=:8443
- --leader-elect
- --health-probe-bind-address=:8081
- --label-selector=${LABEL_SELECTOR}
containerSecurityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
env:
labelSelector: ""
osAuthUrl: ""
osProjectDomainName: ""
osProjectName: ""
Expand Down
8 changes: 7 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
package main

import (
"crypto/sha256"
"crypto/tls"
"flag"
"fmt"
Expand Down Expand Up @@ -162,6 +163,7 @@ func main() {
bininfo.Component(), bininfo.VersionOr("devel"), gruntime.GOOS, gruntime.GOARCH,
bininfo.CommitOr("edge"))

leaderElectionID := "4c28796a.cloud.sap"
var cacheOptions cache.Options
if global.LabelSelector != "" {
setupLog.Info("setting up cache with label selector", "selector", global.LabelSelector)
Expand All @@ -182,6 +184,10 @@ func main() {
},
},
}

h := sha256.New()
h.Write([]byte(global.LabelSelector))
leaderElectionID = fmt.Sprintf("%x.cloud.sap", h.Sum(nil))
}

mgr, err := ctrl.NewManager(restConfig, ctrl.Options{
Expand All @@ -190,7 +196,7 @@ func main() {
WebhookServer: webhookServer,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "4c28796a.cloud.sap",
LeaderElectionID: leaderElectionID,
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
// when the Manager ends. This requires the binary to immediately end when the
// Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
Expand Down
2 changes: 2 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ spec:
- args:
- --leader-elect
- --health-probe-bind-address=:8081
- --label-selector=${LABEL_SELECTOR}
env:
- name: OS_AUTH_URL
- name: OS_PROJECT_DOMAIN_NAME
Expand All @@ -73,6 +74,7 @@ spec:
secretKeyRef:
name: secret
key: SERVICE_PASSWORD
- name: LABEL_SELECTOR
image: keppel.eu-de-1.cloud.sap/ccloud/openstack-hypervisor-operator:latest
name: manager
securityContext:
Expand Down