mirror of https://github.com/easzlab/kubeasz.git
184 lines
5.5 KiB
YAML
184 lines
5.5 KiB
YAML
|
apiVersion: apps/v1
|
||
|
kind: StatefulSet
|
||
|
metadata:
|
||
|
name: {{ template "redis-ha.fullname" . }}-server
|
||
|
labels:
|
||
|
{{ include "labels.standard" . | indent 4 }}
|
||
|
spec:
|
||
|
selector:
|
||
|
matchLabels:
|
||
|
release: {{ .Release.Name }}
|
||
|
app: {{ template "redis-ha.name" . }}
|
||
|
serviceName: {{ template "redis-ha.fullname" . }}
|
||
|
replicas: {{ .Values.replicas }}
|
||
|
podManagementPolicy: OrderedReady
|
||
|
updateStrategy:
|
||
|
type: RollingUpdate
|
||
|
template:
|
||
|
metadata:
|
||
|
annotations:
|
||
|
checksum/init-config: {{ include (print $.Template.BasePath "/redis-ha-configmap.yaml") . | sha256sum }}
|
||
|
checksum/probe-config: {{ include (print $.Template.BasePath "/redis-ha-healthchecks.yaml") . | sha256sum }}
|
||
|
{{- if .Values.podAnnotations }}
|
||
|
{{ toYaml .Values.podAnnotations | indent 8 }}
|
||
|
{{- end }}
|
||
|
labels:
|
||
|
release: {{ .Release.Name }}
|
||
|
app: {{ template "redis-ha.name" . }}
|
||
|
spec:
|
||
|
{{- if .Values.nodeSelector }}
|
||
|
nodeSelector:
|
||
|
{{ toYaml .Values.nodeSelector | indent 8 }}
|
||
|
{{- end }}
|
||
|
{{- if .Values.tolerations }}
|
||
|
tolerations:
|
||
|
{{ toYaml .Values.tolerations | indent 8 }}
|
||
|
{{- end }}
|
||
|
{{- with .Values.affinity }}
|
||
|
affinity:
|
||
|
{{ tpl . $ | indent 8 }}
|
||
|
{{- end }}
|
||
|
securityContext:
|
||
|
{{ toYaml .Values.securityContext | indent 8 }}
|
||
|
initContainers:
|
||
|
- name: config-init
|
||
|
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
|
||
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||
|
resources:
|
||
|
{{ toYaml .Values.init.resources | indent 10 }}
|
||
|
command:
|
||
|
- sh
|
||
|
args:
|
||
|
- /readonly-config/init.sh
|
||
|
{{- if .Values.auth }}
|
||
|
env:
|
||
|
- name: AUTH
|
||
|
valueFrom:
|
||
|
secretKeyRef:
|
||
|
{{- if .Values.existingSecret }}
|
||
|
name: {{ .Values.existingSecret }}
|
||
|
{{- else }}
|
||
|
name: {{ template "redis-ha.fullname" . }}
|
||
|
{{- end }}
|
||
|
key: auth
|
||
|
{{- end }}
|
||
|
volumeMounts:
|
||
|
- name: config
|
||
|
mountPath: /readonly-config
|
||
|
readOnly: true
|
||
|
- name: data
|
||
|
mountPath: /data
|
||
|
containers:
|
||
|
- name: redis
|
||
|
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
|
||
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||
|
command:
|
||
|
- redis-server
|
||
|
args:
|
||
|
- /data/conf/redis.conf
|
||
|
{{- if .Values.auth }}
|
||
|
env:
|
||
|
- name: AUTH
|
||
|
valueFrom:
|
||
|
secretKeyRef:
|
||
|
{{- if .Values.existingSecret }}
|
||
|
name: {{ .Values.existingSecret }}
|
||
|
{{- else }}
|
||
|
name: {{ template "redis-ha.fullname" . }}
|
||
|
{{- end }}
|
||
|
key: auth
|
||
|
{{- end }}
|
||
|
livenessProbe:
|
||
|
exec:
|
||
|
command: [ "sh", "/probes/readiness.sh", "{{ .Values.redis.port }}"]
|
||
|
initialDelaySeconds: 15
|
||
|
periodSeconds: 5
|
||
|
readinessProbe:
|
||
|
exec:
|
||
|
command: ["sh", "/probes/readiness.sh", "{{ .Values.redis.port }}"]
|
||
|
initialDelaySeconds: 15
|
||
|
periodSeconds: 5
|
||
|
resources:
|
||
|
{{ toYaml .Values.redis.resources | indent 10 }}
|
||
|
ports:
|
||
|
- name: redis
|
||
|
containerPort: {{ .Values.redis.port }}
|
||
|
volumeMounts:
|
||
|
- mountPath: /data
|
||
|
name: data
|
||
|
- mountPath: /probes
|
||
|
name: probes
|
||
|
- name: sentinel
|
||
|
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
|
||
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||
|
command:
|
||
|
- redis-sentinel
|
||
|
args:
|
||
|
- /data/conf/sentinel.conf
|
||
|
{{- if .Values.auth }}
|
||
|
env:
|
||
|
- name: AUTH
|
||
|
valueFrom:
|
||
|
secretKeyRef:
|
||
|
{{- if .Values.existingSecret }}
|
||
|
name: {{ .Values.existingSecret }}
|
||
|
{{- else }}
|
||
|
name: {{ template "redis-ha.fullname" . }}
|
||
|
{{- end }}
|
||
|
key: auth
|
||
|
{{- end }}
|
||
|
livenessProbe:
|
||
|
exec:
|
||
|
command: [ "sh", "/probes/readiness.sh", "{{ .Values.sentinel.port }}"]
|
||
|
initialDelaySeconds: 15
|
||
|
periodSeconds: 5
|
||
|
readinessProbe:
|
||
|
exec:
|
||
|
command: ["sh", "/probes/readiness.sh", "{{ .Values.sentinel.port }}"]
|
||
|
initialDelaySeconds: 15
|
||
|
periodSeconds: 5
|
||
|
resources:
|
||
|
{{ toYaml .Values.sentinel.resources | indent 10 }}
|
||
|
ports:
|
||
|
- name: sentinel
|
||
|
containerPort: {{ .Values.sentinel.port }}
|
||
|
volumeMounts:
|
||
|
- mountPath: /data
|
||
|
name: data
|
||
|
- mountPath: /probes
|
||
|
name: probes
|
||
|
volumes:
|
||
|
- name: config
|
||
|
configMap:
|
||
|
name: {{ template "redis-ha.fullname" . }}-configmap
|
||
|
- name: probes
|
||
|
configMap:
|
||
|
name: {{ template "redis-ha.fullname" . }}-probes
|
||
|
{{- if .Values.persistentVolume.enabled }}
|
||
|
volumeClaimTemplates:
|
||
|
- metadata:
|
||
|
name: data
|
||
|
annotations:
|
||
|
{{- range $key, $value := .Values.persistentVolume.annotations }}
|
||
|
{{ $key }}: {{ $value }}
|
||
|
{{- end }}
|
||
|
spec:
|
||
|
accessModes:
|
||
|
{{- range .Values.persistentVolume.accessModes }}
|
||
|
- {{ . | quote }}
|
||
|
{{- end }}
|
||
|
resources:
|
||
|
requests:
|
||
|
storage: {{ .Values.persistentVolume.size | quote }}
|
||
|
{{- if .Values.persistentVolume.storageClass }}
|
||
|
{{- if (eq "-" .Values.persistentVolume.storageClass) }}
|
||
|
storageClassName: ""
|
||
|
{{- else }}
|
||
|
storageClassName: "{{ .Values.persistentVolume.storageClass }}"
|
||
|
{{- end }}
|
||
|
{{- end }}
|
||
|
{{- else }}
|
||
|
- name: data
|
||
|
emptyDir: {}
|
||
|
{{- end }}
|