Skip to content

Commit

Permalink
Merge pull request #58 from dasmeta/DMVP-2021-add-extracontainer
Browse files Browse the repository at this point in the history
feat(DMVP-2021): Add ExtraContainer
  • Loading branch information
aghamyan44 committed Feb 2, 2023
2 parents 1f3435e + 62eae20 commit 3622d0f
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 3 deletions.
4 changes: 2 additions & 2 deletions charts/base/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
41 changes: 41 additions & 0 deletions charts/base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
```
10 changes: 10 additions & 0 deletions charts/base/templates/configmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
74 changes: 74 additions & 0 deletions charts/base/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion charts/base/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions charts/base/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3622d0f

Please sign in to comment.