operator-framework / operator-framework/operator-sdk
doc: how to use the SDK leader election with new layout
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 7.7k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
We speak over it in the Migration guide to +1.0.0 but we need to have a doc for ti with details steps and just link in the migration guide. See: https://master.sdk.operatorframework.io/docs/building-operators/golang/project_migration_guide/#migrate-maingo.
Steps required to make it work on the cluster
- Import the lib
go get -u github.com/operator-framework/operator-lib
- Update main.go which will be as:
ctx := context.TODO()
// Become the leader before proceeding
err := leader.Become(ctx, "anyproject-lock")
if err != nil {
os.Exit(1)
}
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
})
if err != nil {
setupLog.Error(err, "unable to start manager")
os.Exit(1)
}
- Update the manager.yaml file with:
...
spec:
containers:
- command:
- /manager
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
...
- Add rbac permission to the controllers
+kubebuilder:rbac:groups=core,resources=pods,verbs=get;list
- Run
make manifests
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked project migration guide, especially the migrate-maingo section, and review the main.go and manager.yaml examples in the issue. Document the leader-election setup steps, link to the new documentation from the migration guide, and run make manifests to verify the documented workflow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100