openstack-helm/mariadb/templates/statefulset.yaml
Michał Dulko a6cd9bac16 Use k8s 1.6 syntax of declaring affinity
K8s 1.6 has affinity/antiaffinity funtionalities as a beta feature. This
means we don't need to declare them using annotations. This commit
switches usages of affinity to 1.6 syntax.

Change-Id: Ia68f4ab28a018617bd44b1295fea58cd30eb4a39
2017-06-20 16:51:07 +02:00

128 lines
4.1 KiB
YAML

# Copyright 2017 The Openstack-Helm Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: {{ .Values.service_name }}
spec:
serviceName: "{{ .Values.service_name }}-discovery"
replicas: {{ .Values.replicas }}
template:
metadata:
labels:
app: {{ .Values.service_name }}
galera: enabled
spec:
# alanmeadows: this soft requirement allows single
# host deployments to spawn several mariadb containers
# but in a larger environment, would attempt to spread
# them out
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values: ["mariadb"]
topologyKey: kubernetes.io/hostname
weight: 10
nodeSelector:
{{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }}
containers:
- name: {{ .Values.service_name }}
image: {{ .Values.images.mariadb }}
imagePullPolicy: {{ .Values.images.pull_policy }}
{{- if .Values.resources.enabled }}
resources:
limits:
cpu: {{ .Values.resources.api.limits.cpu | quote }}
memory: {{ .Values.resources.api.limits.memory | quote }}
requests:
cpu: {{ .Values.resources.api.requests.cpu | quote }}
memory: {{ .Values.resources.api.requests.memory | quote }}
{{- end }}
command:
- /tmp/start.sh
env:
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
readinessProbe:
exec:
command:
- /tmp/readiness.sh
volumeMounts:
- name: mycnfd
mountPath: /etc/mysql/conf.d
- name: mariadb-bin
mountPath: /tmp/readiness.sh
subPath: readiness.sh
readOnly: true
- name: mariadb-bin
mountPath: /tmp/start.sh
subPath: start.sh
readOnly: true
- name: mariadb-etc
mountPath: /etc/mysql/my.cnf
readOnly: true
subPath: my.cnf
- name: mariadb-etc
mountPath: /etc/mysql/conf.d/00-base.cnf
subPath: 00-base.cnf
readOnly: true
- name: mariadb-etc
mountPath: /etc/mysql/conf.d/20-override.cnf
subPath: 20-override.cnf
readOnly: true
- name: mariadb-etc
mountPath: /etc/mysql/conf.d/99-force.cnf
subPath: 99-force.cnf
readOnly: true
- name: mysql-data
mountPath: /var/lib/mysql
volumes:
- name: mycnfd
emptyDir: {}
- name: mariadb-bin
configMap:
name: mariadb-bin
defaultMode: 0555
- name: mariadb-etc
configMap:
name: mariadb-etc
{{- if not .Values.volume.enabled }}
- name: mysql-data
emptyDir: {}
{{- end }}
{{- if .Values.volume.enabled }}
volumeClaimTemplates:
- metadata:
name: mysql-data
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: {{ .Values.volume.size }}
storageClassName: {{ .Values.volume.class_name }}
{{- end }}