From 87b747e79ebff4457173b4b50ed5964e2dbe13fa Mon Sep 17 00:00:00 2001 From: Zbynek Roubalik Date: Wed, 10 Jul 2024 14:00:56 +0200 Subject: [PATCH] http-add-on: ability to specify number of operator replicas Signed-off-by: Zbynek Roubalik --- http-add-on/README.md | 1 + http-add-on/templates/operator/deployment.yaml | 4 +++- http-add-on/templates/operator/rbac.yml | 2 ++ http-add-on/templates/operator/service.yaml | 2 ++ http-add-on/templates/operator/serviceaccount.yaml | 2 ++ http-add-on/values.yaml | 2 ++ 6 files changed, 12 insertions(+), 1 deletion(-) diff --git a/http-add-on/README.md b/http-add-on/README.md index 3ce6c303..5b64899c 100644 --- a/http-add-on/README.md +++ b/http-add-on/README.md @@ -117,6 +117,7 @@ their default values. | `operator.nodeSelector` | object | `{}` | Node selector for pod scheduling ([docs](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/)) | | `operator.port` | int | `8443` | The port for the operator main server to run on | | `operator.pullPolicy` | string | `"Always"` | The image pull policy for the operator component | +| `operator.replicas` | int | `1` | Number of replicas, oerator k8s resources will not be installed if this is set to 0 | | `operator.resources.limits` | object | `{"cpu":0.5,"memory":"64Mi"}` | The CPU/memory resource limit for the operator component | | `operator.resources.requests` | object | `{"cpu":"250m","memory":"20Mi"}` | The CPU/memory resource request for the operator component | | `operator.tolerations` | list | `[]` | Tolerations for pod scheduling ([docs](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)) | diff --git a/http-add-on/templates/operator/deployment.yaml b/http-add-on/templates/operator/deployment.yaml index 93bda3dc..51841dec 100644 --- a/http-add-on/templates/operator/deployment.yaml +++ b/http-add-on/templates/operator/deployment.yaml @@ -1,3 +1,4 @@ +{{- if gt (int .Values.operator.replicas) 0 }} apiVersion: apps/v1 kind: Deployment metadata: @@ -7,7 +8,7 @@ metadata: name: {{ .Chart.Name }}-controller-manager namespace: {{ .Release.Namespace }} spec: - replicas: 1 + replicas: {{ .Values.operator.replicas }} selector: matchLabels: app.kubernetes.io/component: operator @@ -99,3 +100,4 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} +{{- end }} diff --git a/http-add-on/templates/operator/rbac.yml b/http-add-on/templates/operator/rbac.yml index d3e7ccb1..b5a738dd 100644 --- a/http-add-on/templates/operator/rbac.yml +++ b/http-add-on/templates/operator/rbac.yml @@ -1,3 +1,4 @@ +{{- if gt (int .Values.operator.replicas) 0 }} apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: @@ -175,3 +176,4 @@ subjects: - kind: ServiceAccount name: {{ .Chart.Name }} namespace: {{ .Release.Namespace }} +{{- end }} diff --git a/http-add-on/templates/operator/service.yaml b/http-add-on/templates/operator/service.yaml index 71f6990a..7d9ec340 100644 --- a/http-add-on/templates/operator/service.yaml +++ b/http-add-on/templates/operator/service.yaml @@ -1,3 +1,4 @@ +{{- if gt (int .Values.operator.replicas) 0 }} apiVersion: v1 kind: Service metadata: @@ -14,3 +15,4 @@ spec: selector: app.kubernetes.io/component: operator {{- include "keda-http-add-on.matchLabels" . | indent 4 }} +{{- end }} diff --git a/http-add-on/templates/operator/serviceaccount.yaml b/http-add-on/templates/operator/serviceaccount.yaml index d70b754e..4282bd95 100644 --- a/http-add-on/templates/operator/serviceaccount.yaml +++ b/http-add-on/templates/operator/serviceaccount.yaml @@ -1,3 +1,4 @@ +{{- if gt (int .Values.operator.replicas) 0 }} apiVersion: v1 kind: ServiceAccount metadata: @@ -6,3 +7,4 @@ metadata: {{- include "keda-http-add-on.labels" . | indent 4 }} name: {{ .Chart.Name }} namespace: {{ .Release.Namespace }} +{{- end }} diff --git a/http-add-on/values.yaml b/http-add-on/values.yaml index 2c4534bd..42d6be6e 100644 --- a/http-add-on/values.yaml +++ b/http-add-on/values.yaml @@ -44,6 +44,8 @@ logging: # operator-specific configuration values operator: + # -- Number of replicas, oerator k8s resources will not be installed if this is set to 0 + replicas: 1 # -- The image pull secrets for the operator component imagePullSecrets: [] # -- The namespace to watch for new `HTTPScaledObject`s. Leave this blank (i.e. `""`) to tell the operator to watch all namespaces.