Skip to content

Instantly share code, notes, and snippets.

@prydonius
Created March 2, 2017 23:01
Show Gist options
  • Save prydonius/30747d0bbee3487b1b67b4454d65b423 to your computer and use it in GitHub Desktop.
Save prydonius/30747d0bbee3487b1b67b4454d65b423 to your computer and use it in GitHub Desktop.
Common Chart example
{{ $params := dict "top" . "deployment" .Values.deployment -}}
{{ define "mariadb.env" }}
env:
- name: MARIADB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "common.fullname" . }}
key: mariadb-root-password
- name: MARIADB_USER
value: {{ default "" .Values.mariadbUser | quote }}
- name: MARIADB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "common.fullname" . }}
key: mariadb-password
- name: MARIADB_DATABASE
value: {{ default "" .Values.mariadbDatabase | quote }}
{{ end }}
{{ $_ := set $params.deployment.pod "env" (include "mariadb.env" . | fromYaml).env }}
{{ define "mariadb.annotations" }}
annotations:
pod.alpha.kubernetes.io/init-containers: '[
{
"name": "copy-custom-config",
"image": "{{ .Values.deployment.pod.image }}",
"imagePullPolicy": {{ .Values.deployment.pod.imagePullPolicy | quote }},
"command": ["sh", "-c", "mkdir -p /bitnami/mariadb/conf && cp -n /bitnami/mariadb_config/my.cnf /bitnami/mariadb/conf/my_custom.cnf"],
"volumeMounts": [
{
"name": "config",
"mountPath": "/bitnami/mariadb_config"
},
{
"name": "data",
"mountPath": "/bitnami/mariadb"
}
]
}
]'
{{ end }}
{{ $_ := set $params.deployment.pod "annotations" (include "mariadb.annotations" . | fromYaml).annotations }}
{{ template "common.deployment" $params }}
{{ $params := dict "top" . "service" .Values.service -}}
{{ template "common.service" $params }}
service:
ports:
- name: mysql
port: 3306
targetPort: 3306
deployment:
pod:
name: mariadb
image: bitnami/mariadb
tag: 10.2.21-r0
imagePullPolicy: IfNotPresent
ports:
- name: mysql
containerPort: 3306
livenessProbe:
exec:
command:
- mysqladmin
- ping
initialDelaySeconds: 30
timeoutSeconds: 5
readinessProbe:
exec:
command:
- mysqladmin
- ping
initialDelaySeconds: 5
timeoutSeconds: 1
persistence:
enabled: true
mounts:
- path: /bitnami/mariadb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment