Skip to content

Commit

Permalink
update charts for controller manager
Browse files Browse the repository at this point in the history
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
  • Loading branch information
Iceber committed Jul 11, 2022
1 parent 5991cf1 commit 652bea2
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 0 deletions.
39 changes: 39 additions & 0 deletions charts/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/}}
Expand All @@ -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 -}}
Expand All @@ -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 := "" -}}
Expand Down Expand Up @@ -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 -}}
Expand Down
3 changes: 3 additions & 0 deletions charts/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
54 changes: 54 additions & 0 deletions charts/templates/controller-manager-deployment.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
6 changes: 6 additions & 0 deletions charts/templates/controller-manager-serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "clusterpedia.controllerManager.fullname" . }}
namespace: {{ .Release.Namespace }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
50 changes: 50 additions & 0 deletions charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 652bea2

Please sign in to comment.