diff --git a/charts/base/Chart.yaml b/charts/base/Chart.yaml index f18ecd0..e0c7116 100644 --- a/charts/base/Chart.yaml +++ b/charts/base/Chart.yaml @@ -15,10 +15,10 @@ 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.1.37 +version: 0.1.38 # 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 # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "0.1.37" +appVersion: "0.1.38" diff --git a/charts/base/README.md b/charts/base/README.md index febb124..1df1bff 100644 --- a/charts/base/README.md +++ b/charts/base/README.md @@ -292,3 +292,44 @@ readinessProbe: {} initialDelaySeconds: 60 periodSeconds: 5 ``` + +### ExteraContainer +If you have two container in one deployment you can use extraContainer parameter. + +``` +base: + extraContainer: + name: nginx + containerPort: 80 + image: + repository: nginx:1.22-alpine + pullPolicy: IfNotPresent + tag: latest + resources: + limits: + cpu: 500m + memory: 128Mi + requests: + cpu: 250m + memory: 64Mi + deployment: + volumes: + - name: config + mountPath: /etc/nginx/conf.d/nginx.conf + configMap: + name: config + service: + enabled: false + configmap: + name: config + config: + nginx.conf: | + server { + listen 80; + server_name ********; + resolver kube-dns.kube-system.svc.cluster.local valid=10s; + location /healthcheck { + return 200 'healthy\n'; + } + } +``` \ No newline at end of file diff --git a/charts/base/templates/configmap.yml b/charts/base/templates/configmap.yml index 4f58feb..6c29ebd 100644 --- a/charts/base/templates/configmap.yml +++ b/charts/base/templates/configmap.yml @@ -4,3 +4,13 @@ metadata: name: {{ include "base.fullname" . }} data: {{- toYaml .Values.config | nindent 2 }} + +--- +{{- if .Values.extraContainer.configmap }} +kind: ConfigMap +apiVersion: v1 +metadata: + name: {{ .Values.extraContainer.configmap.name }} +data: + {{- toYaml .Values.extraContainer.configmap.config | nindent 2 }} +{{- end }} diff --git a/charts/base/templates/deployment.yaml b/charts/base/templates/deployment.yaml index b060309..d156553 100644 --- a/charts/base/templates/deployment.yaml +++ b/charts/base/templates/deployment.yaml @@ -43,6 +43,80 @@ spec: securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} containers: + {{- if .Values.extraContainer }} + - name: {{ .Values.extraContainer.name }} + image: "{{ .Values.extraContainer.image.repository }}:{{ .Values.extraContainer.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.extraContainer.image.pullPolicy }} + {{- if $.Values.extraContainer.command }} + command: + {{ toYaml .Values.extraContainer.command | nindent 12 }} + {{- end }} + {{- if .Values.extraContainer.service.enabled }} + ports: + - name: http + containerPort: {{ .Values.extraContainer.containerPort | default 80 }} + protocol: TCP + {{- end }} + {{- if or .Values.extraContainer.extraEnv .Values.extraContainer.secrets}} + env: + {{- range $key, $value := .Values.extraContainer.extraEnv }} + - name: {{ $key | quote}} + value: {{ $value | quote }} + {{- end }} + {{- range $secret := .Values.extraContainer.secrets }} + {{- if ne (kindOf $secret) "string" }} + {{- range $map_key,$map_value := $secret }} + - name: {{ $map_key }} + valueFrom: + secretKeyRef: + key: {{ $map_value.key }} + name: {{ $map_value.from }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- if .Values.extraContainer.livenessProbe }} + livenessProbe: + {{- toYaml .Values.extraContainer.livenessProbe | nindent 12 }} + {{- end }} + {{- if .Values.extraContainer.readinessProbe }} + readinessProbe: + {{- toYaml .Values.extraContainer.readinessProbe | nindent 12 }} + {{- end }} + {{- if .Values.extraContainer.startupProbe }} + startupProbe: + {{- toYaml .Values.extraContainer.startupProbe | nindent 12 }} + {{- end }} + resources: + {{- toYaml .Values.extraContainer.resources | nindent 12 }} + {{- if .Values.extraContainer.envFrom }} + envFrom: + - configMapRef: + name: {{ .Values.extraContainer.name }} + {{- if eq .Values.extraContainer.secretsDefaultEngine "ExternalSecrets" -}} + - secretRef: + name: {{ .Values.extraContainer.secretRef }} + optional: true + {{- end }} + {{- end }} + {{- if eq .Values.extraContainer.secretsDefaultEngine "ExternalSecrets" -}} + - secretRef: + name: {{ include "base.fullname" . }} + optional: true + {{- end }} + {{- if .Values.extraContainer.deployment.volumes }} + volumeMounts: + {{- range $index, $element := .Values.extraContainer.deployment.volumes }} + - name: {{ coalesce $element.name (add $index 1) }} + mountPath: {{ $element.mountPath }} + readOnly: {{ $element.readOnly | default false }} + {{- end }} + {{- end }} + {{- if .Values.extraContainer.deployment.lifecycle }} + lifecycle: + {{- toYaml .Values.extraContainer.deployment.lifecycle | nindent 12 }} + {{- end }} + {{- end }} - name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} diff --git a/charts/base/templates/service.yaml b/charts/base/templates/service.yaml index 741a007..0fe7a04 100644 --- a/charts/base/templates/service.yaml +++ b/charts/base/templates/service.yaml @@ -9,7 +9,7 @@ spec: type: {{ .Values.service.type }} ports: - port: {{ .Values.service.port }} - targetPort: {{ .Values.containerPort }} + targetPort: {{ .Values.service.targetPort | default .Values.containerPort }} protocol: {{ .Values.service.protocol }} name: {{ .Values.service.name }} selector: diff --git a/charts/base/values.yaml b/charts/base/values.yaml index 21347cd..3c1ec7f 100644 --- a/charts/base/values.yaml +++ b/charts/base/values.yaml @@ -82,6 +82,8 @@ secretsDefaultEngine: "ExternalSecrets" # from: helm-test-secret # key: username +extraContainer: {} + resources: {} # We usually recommend not to specify default resources and to leave this as a conscious # choice for the user. This also increases chances charts run on environments with little