From 1b1b5a226fbb1978d3412d4c1e9fad483b6dc3ce Mon Sep 17 00:00:00 2001 From: Johannes Faltermeier Date: Mon, 31 Jul 2023 09:57:23 +0200 Subject: [PATCH] Support multiple operator replicas with leader election eclipsesource/theia-cloud#201 * allow to specify number of operator replicas * allow operator to work with leases --- charts/theia.cloud-base/Chart.yaml | 2 +- charts/theia.cloud-base/templates/operator-role.yaml | 4 +++- charts/theia.cloud/Chart.yaml | 2 +- charts/theia.cloud/templates/operator.yaml | 8 +++++++- charts/theia.cloud/values.yaml | 9 +++++++++ 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/charts/theia.cloud-base/Chart.yaml b/charts/theia.cloud-base/Chart.yaml index d304cf6..63f25a1 100644 --- a/charts/theia.cloud-base/Chart.yaml +++ b/charts/theia.cloud-base/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.8.1-v001-MS1 +version: 0.8.1-v002 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/theia.cloud-base/templates/operator-role.yaml b/charts/theia.cloud-base/templates/operator-role.yaml index 1e7dd57..7fac410 100644 --- a/charts/theia.cloud-base/templates/operator-role.yaml +++ b/charts/theia.cloud-base/templates/operator-role.yaml @@ -12,6 +12,7 @@ rules: - theia.cloud - networking.k8s.io - apps + - coordination.k8s.io resources: - customresourcedefinitions - appdefinitions @@ -23,6 +24,7 @@ rules: - services - configmaps - deployments - verbs: ["list", "create", "watch", "get", "patch", "delete"] + - leases + verbs: ["list", "create", "watch", "get", "patch", "delete", "update"] {{- end }} \ No newline at end of file diff --git a/charts/theia.cloud/Chart.yaml b/charts/theia.cloud/Chart.yaml index 3f7a507..c2ad608 100644 --- a/charts/theia.cloud/Chart.yaml +++ b/charts/theia.cloud/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.8.1-v002-MS1 +version: 0.8.1-v003 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/theia.cloud/templates/operator.yaml b/charts/theia.cloud/templates/operator.yaml index 31c861a..20919b9 100644 --- a/charts/theia.cloud/templates/operator.yaml +++ b/charts/theia.cloud/templates/operator.yaml @@ -6,7 +6,7 @@ metadata: app: operator namespace: {{ .Release.Namespace }} spec: - replicas: 1 + replicas: {{ tpl (.Values.operator.replicas | toString) . }} selector: matchLabels: app: operator @@ -71,6 +71,12 @@ spec: - "{{ tpl (.Values.monitor.activityTracker.interval | toString) . }}" {{- end }} {{- end }} + - "--leaderLeaseDuration" + - "{{ tpl (.Values.operator.leaderElection.leaseDuration | toString) . }}" + - "--leaderRenewDeadline" + - "{{ tpl (.Values.operator.leaderElection.renewDeadline | toString) . }}" + - "--leaderRetryPeriod" + - "{{ tpl (.Values.operator.leaderElection.retryPeriod | toString) . }}" {{- if .Values.operator.imagePullSecret }} imagePullSecrets: - name: {{ tpl (.Values.operator.imagePullSecret | toString) . }} diff --git a/charts/theia.cloud/values.yaml b/charts/theia.cloud/values.yaml index 6f7279d..b0e87d8 100644 --- a/charts/theia.cloud/values.yaml +++ b/charts/theia.cloud/values.yaml @@ -184,6 +184,15 @@ operator: # See https://kubernetes.io/docs/reference/kubernetes-api/common-definitions/quantity/ requestedStorage: "250Mi" + # Number of operator instances to create + replicas: 2 + + # Options to influence the operator's leader election + leaderElection: + leaseDuration: 6 + renewDeadline: 4 + retryPeriod: 1 + # Values of the Theia.cloud REST service service: # The image to use