Feature Request
The new helm layout is working with the current/legacy image of the operator-sdk helm. This image is not using the controller-runtime implementation for the leader election.
We need to:
- Add the both flags to the run
- Change the main implementation to use the leader election as it is in the GO type. See:
pflag.BoolVar(&enableLeaderElection, "enable-leader-election", false,
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")
pflag.StringVar(&leaderElectionID, "leader-election-id", "",
"Name of the configmap that is used for holding the leader lock.")
pflag.StringVar(&leaderElectionNamespace, "leader-election-namespace", "",
"Namespace in which to create the leader election configmap for holding the leader lock (required if running locally).")
// Deprecated: OPERATOR_NAME environment variable is an artifact of the legacy operator-sdk project scaffolding.
// Flag `--leader-election-id` should be used instead.
if operatorName, found := os.LookupEnv("OPERATOR_NAME"); found {
setupLog.Info("environment variable OPERATOR_NAME has been deprecated, use --leader-election-id instead.")
if pflag.Lookup("leader-election-id").Changed {
setupLog.Info("ignoring OPERATOR_NAME environment variable since --leader-election-id is set")
} else {
leaderElectionID = operatorName
}
}
options := ctrl.Options{
MetricsBindAddress: metricsAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: leaderElectionID,
LeaderElectionNamespace: leaderElectionNamespace,
NewClient: manager.NewDelegatingClientFunc(),
}
Feature Request
The new helm layout is working with the current/legacy image of the operator-sdk helm. This image is not using the controller-runtime implementation for the leader election.
We need to:
cmd/helm|ansible-operator/main.gowhich is used to generate bin. See: [ansible/helm] remove operator-sdk binary from ansible/helm base images #3331internal/plugins/helm/v1/scaffolds/templates/metricsauth/auth_proxy_patch.go) to use the enableLeaderElection flag. See: https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugin/v3/scaffolds/internal/templates/metricsauth/auth_proxy_patch.go#L68-L70