diff --git a/charts/templates/_helpers.tpl b/charts/templates/_helpers.tpl index 4be3ade42..f5c8752ed 100644 --- a/charts/templates/_helpers.tpl +++ b/charts/templates/_helpers.tpl @@ -14,6 +14,15 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- printf "%s-%s" (include "common.names.fullname" .) "clustersynchro-manager" | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "clusterpedia.controllerManager.fullname" -}} +{{- printf "%s-%s" (include "common.names.fullname" .) "controller-manager" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + + {{/* Return the proper apiserver image name */}} @@ -28,6 +37,13 @@ Return the proper clustersynchroManager image name {{ include "common.images.image" (dict "imageRoot" .Values.clustersynchroManager.image "global" .Values.global) }} {{- end -}} +{{/* +Return the proper controllerManager image name +*/}} +{{- define "clusterpedia.controllerManager.image" -}} +{{ include "common.images.image" (dict "imageRoot" .Values.controllerManager.image "global" .Values.global) }} +{{- end -}} + {{- define "clusterpedia.internalstorage.fullname" -}} {{- printf "%s-%s" (include "common.names.fullname" .) "internalstorage" | trunc 63 | trimSuffix "-" -}} {{- end -}} @@ -46,6 +62,13 @@ Return the proper Docker Image Registry Secret Names {{ include "common.images.pullSecrets" (dict "images" (list .Values.clustersynchroManager.image) "global" .Values.global) }} {{- end -}} +{{/* +Return the proper Docker Image Registry Secret Names +*/}} +{{- define "clusterpedia.controllerManager.imagePullSecrets" -}} +{{ include "common.images.pullSecrets" (dict "images" (list .Values.controllerManager.image) "global" .Values.global) }} +{{- end -}} + {{- define "clusterpedia.apiserver.featureGates" -}} {{- if (not (empty .Values.apiserver.featureGates)) }} {{- $featureGatesFlag := "" -}} @@ -78,6 +101,22 @@ Return the proper Docker Image Registry Secret Names {{- end -}} {{- end -}} +{{- define "clusterpedia.controllerManager.featureGates" -}} + {{- if (not (empty .Values.controllerManager.featureGates)) }} + {{- $featureGatesFlag := "" -}} + {{- range $key, $value := .Values.controllerManager.featureGates -}} + {{- if not (empty (toString $value)) }} + {{- $featureGatesFlag = cat $featureGatesFlag $key "=" $value "," -}} + {{- end -}} + {{- end -}} + + {{- if gt (len $featureGatesFlag) 0 }} + {{- $featureGatesFlag := trimSuffix "," $featureGatesFlag | nospace -}} + {{- printf "%s=%s" "--feature-gates" $featureGatesFlag -}} + {{- end -}} + {{- end -}} +{{- end -}} + {{- define "clusterpedia.storage.user" -}} {{- if eq .Values.storageInstallMode "external" }} {{- required "Please set correct storage user!" .Values.externalStorage.user -}} diff --git a/charts/templates/clusterrolebinding.yaml b/charts/templates/clusterrolebinding.yaml index 984b20391..daa4be95f 100644 --- a/charts/templates/clusterrolebinding.yaml +++ b/charts/templates/clusterrolebinding.yaml @@ -14,3 +14,6 @@ subjects: - kind: ServiceAccount name: {{ include "clusterpedia.clustersynchroManager.fullname" . }} namespace: {{ .Release.Namespace }} + - kind: ServiceAccount + name: {{ include "clusterpedia.controllerManager.fullname" . }} + namespace: {{ .Release.Namespace }} diff --git a/charts/templates/controller-manager-deployment.yaml b/charts/templates/controller-manager-deployment.yaml new file mode 100644 index 000000000..81f64f599 --- /dev/null +++ b/charts/templates/controller-manager-deployment.yaml @@ -0,0 +1,54 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "clusterpedia.controllerManager.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: {{- include "common.labels.standard" . | nindent 4 }} + app: {{ include "clusterpedia.controllerManager.fullname" . }} + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} + {{- end }} + {{- if .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} + {{- end }} +spec: + replicas: {{ .Values.controllerManager.replicaCount }} + selector: + matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }} + app: {{ include "clusterpedia.controllerManager.fullname" . }} + template: + metadata: + {{- if .Values.controllerManager.podAnnotations }} + annotations: + {{- include "common.tplvalues.render" (dict "value" .Values.controllerManager.podAnnotations "context" $) | nindent 8 }} + {{- end }} + labels: {{- include "common.labels.standard" . | nindent 8 }} + app: {{ include "clusterpedia.controllerManager.fullname" . }} + {{- if .Values.podLabels }} + {{- include "common.tplvalues.render" (dict "value" .Values.controllerManager.podLabels "context" $) | nindent 8 }} + {{- end }} + spec: + {{- include "clusterpedia.controllerManager.imagePullSecrets" . | nindent 6 }} + containers: + - name: {{ include "clusterpedia.controllerManager.fullname" . }} + image: {{ template "clusterpedia.controllerManager.image" . }} + imagePullPolicy: {{ .Values.controllerManager.image.pullPolicy }} + command: + - /usr/local/bin/clustersynchro-manager + - --leader-elect-resource-namespace={{ .Release.Namespace }} + {{- with (include "clusterpedia.controllerManager.featureGates" .) }} + - {{ . }} + {{- end }} + {{- if .Values.controllerManager.resources }} + resources: {{- toYaml .Values.controllerManager.resources | nindent 12 }} + {{- end }} + serviceAccountName: {{ include "clusterpedia.controllerManager.fullname" . }} + {{- if .Values.controllerManager.affinity }} + affinity: {{- include "common.tplvalues.render" (dict "value" .Values.controllerManager.affinity "context" $) | nindent 8 }} + {{- end }} + {{- if .Values.controllerManager.nodeSelector }} + nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.controllerManager.nodeSelector "context" $) | nindent 8 }} + {{- end }} + {{- if .Values.controllerManager.tolerations }} + tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.controllerManager.tolerations "context" $) | nindent 8 }} + {{- end }} diff --git a/charts/templates/controller-manager-serviceaccount.yaml b/charts/templates/controller-manager-serviceaccount.yaml new file mode 100644 index 000000000..0ca96bff7 --- /dev/null +++ b/charts/templates/controller-manager-serviceaccount.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "clusterpedia.controllerManager.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: {{- include "common.labels.standard" . | nindent 4 }} diff --git a/charts/values.yaml b/charts/values.yaml index c511c1b85..1b5ffe84f 100644 --- a/charts/values.yaml +++ b/charts/values.yaml @@ -209,6 +209,56 @@ clustersynchroManager: ## alpha: v0.3.0 AllowSyncAllResources: false +## controller manager config +controllerManager: + ## @param controllerManager.labels + labels: {} + ## @param controllerManager.replicaCount target replicas + replicaCount: 1 + ## @param controllerManager.podAnnotations + podAnnotations: {} + ## @param controllerManager.podLabels + podLabels: {} + ## @param image.registry clusterpedia controllerManager image registry + ## @param image.repository clusterpedia controllerManager image repository + ## @param image.tag clusterpedia controllerManager image tag (immutable tags are recommended) + ## @param image.pullPolicy clusterpedia controllerManager image pull policy + ## @param image.pullSecrets Specify docker-registry secret names as an array + ## + image: + registry: ghcr.io + repository: clusterpedia-io/clusterpedia/controller-manager + tag: latest + ## Specify a imagePullPolicy + ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' + ## + pullPolicy: IfNotPresent + ## Optionally specify an array of imagePullSecrets. + ## Secrets must be manually created in the namespace. + ## Example: + ## pullSecrets: + ## - myRegistryKeySecretName + ## + pullSecrets: [] + ## @param controllerManager.resources + resources: {} + # If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + ## @param controllerManager.nodeSelector + nodeSelector: {} + ## @param controllerManager.affinity + affinity: {} + ## @param controllerManager.tolerations + tolerations: [] + ## @param featureGate to controller + featureGates: {} + ## @section PostgreSQL Parameters ## ## PostgreSQL properties