openstack-helm/mariadb/templates/deployment.yaml
2016-12-29 14:58:09 -08:00

173 lines
5.3 KiB
YAML

---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: {{ .Values.service_name }}
spec:
serviceName: "{{ .Values.service_name }}"
{{- if .Values.development.enabled }}
replicas: 1
{{- else }}
replicas: {{ .Values.replicas }}
{{- end }}
template:
metadata:
labels:
app: {{ .Values.service_name }}
galera: enabled
annotations:
# alanmeadows: this soft requirement allows single
# host deployments to spawn several mariadb containers
# but in a larger environment, would attempt to spread
# them out
scheduler.alpha.kubernetes.io/affinity: >
{
"podAntiAffinity": {
"preferredDuringSchedulingIgnoredDuringExecution": [{
"labelSelector": {
"matchExpressions": [{
"key": "app",
"operator": "In",
"values":["mariadb"]
}]
},
"topologyKey": "kubernetes.io/hostname",
"weight": 10
}]
}
}
spec:
nodeSelector:
{{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }}
containers:
- name: {{ .Values.service_name }}
image: {{ .Values.images.mariadb }}
imagePullPolicy: Always
env:
- name: INTERFACE_NAME
value: "eth0"
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: COMMAND
value: "bash /tmp/start.sh"
ports:
- containerPort: {{ .Values.network.port.mariadb }}
- containerPort: {{ .Values.network.port.wsrep }}
- containerPort: {{ .Values.network.port.ist }}
# a readinessprobe is a much more complex affair with
# statefulsets, as the container must be "live"
# before the next stateful member is created
# and with galera this is problematic
readinessProbe:
exec:
command:
- python
- /mariadb-readiness.py
initialDelaySeconds: 60
volumeMounts:
- name: mycnfd
mountPath: /etc/my.cnf.d
- name: startsh
mountPath: /tmp/start.sh
subPath: start.sh
- name: bootstrapdb
mountPath: /tmp/bootstrap-db.sh
subPath: bootstrap-db.sh
- name: peerfinder
mountPath: /tmp/peer-finder.py
subPath: peer-finder.py
- name: readiness
mountPath: /mariadb-readiness.py
subPath: readiness.py
- name: charsets
mountPath: /etc/my.cnf.d/charsets.cnf
subPath: charsets.cnf
- name: engine
mountPath: /etc/my.cnf.d/engine.cnf
subPath: engine.cnf
- name: log
mountPath: /etc/my.cnf.d/log.cnf
subPath: log.cnf
- name: mycnf
mountPath: /etc/my.cnf
subPath: my.cnf
- name: networking
mountPath: /etc/my.cnf.d/networking.cnf
subPath: networking.cnf
- name: pid
mountPath: /etc/my.cnf.d/pid.cnf
subPath: pid.cnf
- name: tuning
mountPath: /etc/my.cnf.d/tuning.cnf
subPath: tuning.cnf
- name: wsrep
mountPath: /etc/my.cnf.d/wsrep.cnf
subPath: wsrep.cnf
- name: mysql-data
mountPath: /var/lib/mysql
volumes:
- name: mycnfd
emptyDir: {}
- name: startsh
configMap:
name: mariadb-bin
- name: bootstrapdb
configMap:
name: mariadb-bin
- name: peerfinder
configMap:
name: mariadb-bin
- name: readiness
configMap:
name: mariadb-bin
- name: charsets
configMap:
name: mariadb-etc
- name: engine
configMap:
name: mariadb-etc
- name: log
configMap:
name: mariadb-etc
- name: mycnf
configMap:
name: mariadb-etc
- name: networking
configMap:
name: mariadb-etc
- name: pid
configMap:
name: mariadb-etc
- name: tuning
configMap:
name: mariadb-etc
- name: wsrep
configMap:
name: mariadb-etc
{{- if .Values.development.enabled }}
- name: mysql-data
hostPath:
path: {{ .Values.development.storage_path }}
{{- else }}
volumeClaimTemplates:
- metadata:
name: mysql-data
annotations:
{{ .Values.volume.class_path }}: {{ .Values.volume.class_name }}
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: {{ .Values.volume.size }}
{{- end }}