github.com/replicatedcom/ship@v0.50.0/integration/base/shipapp-helm-values/expected/installer/consul/templates/consul-statefulset.yaml (about) 1 apiVersion: apps/v1beta1 2 kind: StatefulSet 3 metadata: 4 name: "{{ template "consul.fullname" . }}" 5 labels: 6 heritage: {{ .Release.Service | quote }} 7 release: {{ .Release.Name | quote }} 8 chart: {{ template "consul.chart" . }} 9 component: "{{ .Release.Name }}-{{ .Values.Component }}" 10 spec: 11 serviceName: "{{ template "consul.fullname" . }}" 12 replicas: {{ default 3 .Values.Replicas }} 13 updateStrategy: 14 type: RollingUpdate 15 selector: 16 matchLabels: 17 release: {{ .Release.Name | quote }} 18 component: "{{ .Release.Name }}-{{ .Values.Component }}" 19 template: 20 metadata: 21 name: "{{ template "consul.fullname" . }}" 22 labels: 23 heritage: {{ .Release.Service | quote }} 24 release: {{ .Release.Name | quote }} 25 chart: {{ template "consul.chart" . }} 26 component: "{{ .Release.Name }}-{{ .Values.Component }}" 27 spec: 28 securityContext: 29 fsGroup: 1000 30 {{- if .Values.priorityClassName }} 31 priorityClassName: "{{ .Values.priorityClassName }}" 32 {{- end }} 33 {{- if .Values.affinity }} 34 affinity: 35 {{ tpl .Values.affinity . | indent 8 }} 36 {{- end }} 37 {{- if .Values.nodeSelector }} 38 nodeSelector: 39 {{ toYaml .Values.nodeSelector | indent 8 }} 40 {{- end }} 41 {{- if .Values.tolerations }} 42 tolerations: 43 {{ toYaml .Values.tolerations | indent 8 }} 44 {{- end }} 45 containers: 46 - name: "{{ template "consul.fullname" . }}" 47 image: "{{ .Values.Image }}:{{ .Values.ImageTag }}" 48 imagePullPolicy: "{{ .Values.ImagePullPolicy }}" 49 ports: 50 - name: http 51 containerPort: {{ .Values.HttpPort }} 52 - name: rpc 53 containerPort: {{ .Values.RpcPort }} 54 - name: serflan-tcp 55 protocol: "TCP" 56 containerPort: {{ .Values.SerflanPort }} 57 - name: serflan-udp 58 protocol: "UDP" 59 containerPort: {{ .Values.SerflanUdpPort }} 60 - name: serfwan-tcp 61 protocol: "TCP" 62 containerPort: {{ .Values.SerfwanPort }} 63 - name: serfwan-udp 64 protocol: "UDP" 65 containerPort: {{ .Values.SerfwanUdpPort }} 66 - name: server 67 containerPort: {{.Values.ServerPort}} 68 - name: consuldns-tcp 69 containerPort: {{.Values.ConsulDnsPort}} 70 - name: consuldns-udp 71 protocol: "UDP" 72 containerPort: {{.Values.ConsulDnsPort}} 73 resources: 74 {{ toYaml .Values.Resources | indent 10 }} 75 env: 76 - name: INITIAL_CLUSTER_SIZE 77 value: {{ default 3 .Values.Replicas | quote }} 78 - name: STATEFULSET_NAME 79 value: "{{ template "consul.fullname" . }}" 80 - name: POD_IP 81 valueFrom: 82 fieldRef: 83 fieldPath: status.podIP 84 - name: STATEFULSET_NAMESPACE 85 valueFrom: 86 fieldRef: 87 fieldPath: metadata.namespace 88 - name: DNSPORT 89 value: "{{ .Values.ConsulDnsPort }}" 90 volumeMounts: 91 - name: datadir 92 mountPath: /var/lib/consul 93 - name: gossip-key 94 mountPath: /etc/consul/secrets 95 readOnly: true 96 {{ range .Values.ConsulConfig }} 97 - name: userconfig-{{ .name }} 98 readOnly: true 99 mountPath: /etc/consul/userconfig/{{ .name }} 100 {{ end }} 101 livenessProbe: 102 exec: 103 command: 104 - consul 105 - members 106 - -http-addr=http://127.0.0.1:{{ .Values.HttpPort }} 107 initialDelaySeconds: 300 108 timeoutSeconds: 5 109 command: 110 - "/bin/sh" 111 - "-ec" 112 - | 113 IP=$(hostname -i) 114 115 {{- if .Values.Gossip.Encrypt }} 116 if [ -e /etc/consul/secrets/gossip-key ]; then 117 echo "{\"encrypt\": \"$(base64 /etc/consul/secrets/gossip-key)\"}" > /etc/consul/encrypt.json 118 GOSSIP_KEY="-config-file /etc/consul/encrypt.json" 119 fi 120 {{- end }} 121 122 for i in $(seq 0 $((${INITIAL_CLUSTER_SIZE} - 1))); do 123 while true; do 124 echo "Waiting for ${STATEFULSET_NAME}-${i}.${STATEFULSET_NAME} to come up" 125 ping -W 1 -c 1 ${STATEFULSET_NAME}-${i}.${STATEFULSET_NAME}.${STATEFULSET_NAMESPACE}.svc > /dev/null && break 126 sleep 1s 127 done 128 done 129 130 PEERS="" 131 for i in $(seq 0 $((${INITIAL_CLUSTER_SIZE} - 1))); do 132 NEXT_PEER="$(ping -c 1 ${STATEFULSET_NAME}-${i}.${STATEFULSET_NAME}.${STATEFULSET_NAMESPACE}.svc | awk -F'[()]' '/PING/{print $2}')" 133 if [ "${NEXT_PEER}" != "${POD_IP}" ]; then 134 PEERS="${PEERS}${PEERS:+ } -retry-join ${STATEFULSET_NAME}-${i}.${STATEFULSET_NAME}.${STATEFULSET_NAMESPACE}.svc" 135 fi 136 done 137 138 exec /bin/consul agent \ 139 {{- range .Values.ConsulConfig }} 140 -config-dir /etc/consul/userconfig/{{ .name }} \ 141 {{- end}} 142 {{- if .Values.uiService.enabled }} 143 -ui \ 144 {{- end }} 145 {{- if .Values.DisableHostNodeId }} 146 -disable-host-node-id \ 147 {{- end }} 148 {{- if .Values.DatacenterName }} 149 -datacenter {{ .Values.DatacenterName }} \ 150 {{- end }} 151 {{- if .Values.Domain }} 152 -domain={{ .Values.Domain }} \ 153 {{- end }} 154 -data-dir=/var/lib/consul \ 155 -server \ 156 -bootstrap-expect=${INITIAL_CLUSTER_SIZE} \ 157 -disable-keyring-file \ 158 -bind=0.0.0.0 \ 159 -advertise=${IP} \ 160 ${PEERS} \ 161 {{- if .Values.Gossip.Encrypt }} 162 ${GOSSIP_KEY} \ 163 {{- end }} 164 -client=0.0.0.0 \ 165 -dns-port=${DNSPORT} \ 166 -http-port={{ .Values.HttpPort }} 167 volumes: 168 - name: gossip-key 169 secret: 170 secretName: {{ template "consul.fullname" . }}-gossip-key 171 {{ range .Values.ConsulConfig }} 172 - name: userconfig-{{ .name }} 173 {{ .type }}: 174 {{- if (eq .type "configMap") }} 175 name: {{ .name }} 176 {{- else if (eq .type "secret") }} 177 secretName: {{ .name }} 178 {{- end}} 179 {{ end }} 180 volumeClaimTemplates: 181 - metadata: 182 name: datadir 183 spec: 184 accessModes: 185 - "ReadWriteOnce" 186 resources: 187 requests: 188 # upstream recommended max is 700M 189 storage: "{{ .Values.Storage }}" 190 {{- if .Values.StorageClass }} 191 {{- if (eq "-" .Values.StorageClass) }} 192 storageClassName: "" 193 {{- else }} 194 storageClassName: "{{ .Values.StorageClass }}" 195 {{- end }} 196 {{- end }}