Merge "[DCAEMOD] Uses new tpls for repos / images"
[oom.git] / kubernetes / common / etcd / templates / statefulset.yaml
index 8b6a534..f5592bd 100644 (file)
@@ -1,3 +1,4 @@
+{{/*
 # Copyright © 2019 Intel Corporation Inc
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # 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
+*/}}
+apiVersion: apps/v1
 kind: StatefulSet
 metadata:
   name: {{ include "common.fullname" .  }}
   labels:
     heritage: "{{ .Release.Service }}"
-    release: "{{ .Release.Name }}"
+    release: "{{ include "common.release" . }}"
     chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
     app: {{ include "common.name" . }}
 spec:
   serviceName: {{ include "common.servicename" .}}
   replicas: {{ .Values.replicaCount }}
+  selector:
+    matchLabels:
+      app: {{ include "common.name" .  }}
   template:
     metadata:
       labels:
         heritage: "{{ .Release.Service }}"
-        release: "{{ .Release.Name }}"
+        release: "{{ include "common.release" . }}"
         chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
         app: {{ include "common.name" . }}
     spec:
@@ -46,7 +50,7 @@ spec:
 {{- end }}
       containers:
       - name: {{ include "common.fullname" .  }}
-        image: "{{ .Values.repository }}/{{ .Values.image }}"
+        image: {{ include "repositoryGenerator.googleK8sRepository" . }}/{{ .Values.image }}
         imagePullPolicy: "{{ .Values.pullPolicy }}"
         ports:
         - containerPort: {{ .Values.service.peerInternalPort }}
@@ -55,17 +59,12 @@ spec:
           name: {{ .Values.service.clientPortName }}
         {{- if eq .Values.liveness.enabled true }}
         livenessProbe:
-          exec:
-            command: ["/bin/sh", "-c", "etcdctl cluster-health | grep -w healthy" ]
-            initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
-            periodSeconds: {{ .Values.liveness.periodSeconds }}
-            timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
-          {{ end -}}
-        readinessProbe:
-          exec:
-            command: ["/bin/sh", "-c", "etcdctl cluster-health | grep -w healthy" ]
-            initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
-            periodSeconds: {{ .Values.readiness.periodSeconds }}
+          tcpSocket:
+            port: {{ .Values.service.clientInternalPort }}
+          initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
+          periodSeconds: {{ .Values.liveness.periodSeconds }}
+          timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
+        {{ end -}}
         resources:
 {{ include "common.resources" . | indent 10 }}
         env:
@@ -142,7 +141,7 @@ spec:
             done
 
             # re-joining after failure?
-            if [ -e /var/run/etcd/default.etcd ]; then
+            if [[ -e /var/run/etcd/default.etcd && -f /var/run/etcd/member_id ]]; then
                 echo "Re-joining etcd member"
                 member_id=$(cat /var/run/etcd/member_id)
 
@@ -219,14 +218,19 @@ spec:
   volumeClaimTemplates:
   - metadata:
       name: {{ include "common.fullname" . }}-data
+      labels:
+        name: {{ include "common.fullname" . }}
+        chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+        release: "{{ include "common.release" . }}"
+        heritage: "{{ .Release.Service }}"
     spec:
       accessModes:
-        - "{{ .Values.persistence.accessMode }}"
+      - "{{ .Values.persistence.accessMode }}"
+      storageClassName: {{ include "common.storageClass" . }}
       resources:
         requests:
           # upstream recommended max is 700M
           storage: "{{ .Values.persistence.storage }}"
-      storageClassName: {{ include "common.fullname" . }}-data
   {{- else }}
       volumes:
       - name: {{ include "common.fullname" . }}-data
@@ -237,4 +241,3 @@ spec:
         emptyDir: {}
       {{- end }}
   {{- end }}
-