diff --git a/examples/custom-controller/Makefile b/examples/custom-controller/Makefile index e3ec52d278..ecf646ffea 100644 --- a/examples/custom-controller/Makefile +++ b/examples/custom-controller/Makefile @@ -25,7 +25,7 @@ REPOSITORY ?= PROD_REPO ?= us-docker.pkg.dev/agones-images/examples -version := 0.1 +version := 0.2 ifeq ($(REPOSITORY),) server_tag := custom-controller:$(version) else diff --git a/examples/custom-controller/deployment.yaml b/examples/custom-controller/deployment.yaml index b5fd791872..9defa898a3 100644 --- a/examples/custom-controller/deployment.yaml +++ b/examples/custom-controller/deployment.yaml @@ -29,6 +29,9 @@ rules: - apiGroups: ["agones.dev"] resources: ["gameservers"] verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] + - apiGroups: ["coordination.k8s.io"] + resources: ["leases"] + verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding @@ -49,7 +52,7 @@ metadata: name: custom-controller namespace: agones-system spec: - replicas: 1 + replicas: 2 selector: matchLabels: app: custom-controller @@ -61,5 +64,5 @@ spec: serviceAccountName: custom-controller-sa containers: - name: custom-controller - image: us-docker.pkg.dev/agones-images/examples/custom-controller:0.1 + image: us-docker.pkg.dev/agones-images/examples/custom-controller:0.2 imagePullPolicy: Always diff --git a/examples/custom-controller/main.go b/examples/custom-controller/main.go index 2534167ce7..0495307491 100644 --- a/examples/custom-controller/main.go +++ b/examples/custom-controller/main.go @@ -79,7 +79,12 @@ func main() { ctrl.SetLogger(zap.New(zap.UseDevMode(true))) ctrl.Log.Info("Starting controller manager.") - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{}) + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ + LeaderElection: true, + LeaderElectionResourceLock: "leases", + LeaderElectionNamespace: "agones-system", + LeaderElectionID: "custom-controller-leader", + }) if err != nil { ctrl.Log.Error(err, "Unable to start manager") os.Exit(1)