Browse Source

Added Helm Test for ETCD

- Uses etcdctl endpoint health for a helm test.

Change-Id: I25162a228f1725d30a3346cd365dee7de491a26d
Aaron Sheffield 1 year ago
parent
commit
5afff6e407

+ 98
- 0
charts/etcd/templates/tests/test-etcd-health.yaml View File

@@ -0,0 +1,98 @@
1
+{{/*
2
+# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
3
+#
4
+# Licensed under the Apache License, Version 2.0 (the "License");
5
+# you may not use this file except in compliance with the License.
6
+# You may obtain a copy of the License at
7
+#
8
+#     http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+# Unless required by applicable law or agreed to in writing, software
11
+# distributed under the License is distributed on an "AS IS" BASIS,
12
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+# See the License for the specific language governing permissions and
14
+# limitations under the License.
15
+*/}}
16
+{{/*
17
+Test etcdctl endpoint health */}}
18
+{{- if .Values.manifests.test_etcd_health }}
19
+---
20
+apiVersion: v1
21
+kind: Pod
22
+metadata:
23
+  name: "{{ .Release.Name }}-etcd-test"
24
+  annotations:
25
+    "helm.sh/hook": "test-success"
26
+spec:
27
+  restartPolicy: Never
28
+  containers:
29
+    - name: "{{ .Release.Name }}-etcd-test"
30
+      env:
31
+        - name: ETCD_NAME
32
+          valueFrom:
33
+            fieldRef:
34
+              fieldPath: spec.nodeName
35
+        - name: POD_IP
36
+          valueFrom:
37
+            fieldRef:
38
+              fieldPath: status.podIP
39
+        - name: ETCDCTL_API
40
+          value: '3'
41
+        - name: ETCDCTL_DIAL_TIMEOUT
42
+          value: 3s
43
+        - name: ETCDCTL_ENDPOINTS
44
+          value: https://{{ .Values.anchor.etcdctl_endpoint }}:{{ .Values.network.service_client.port }}
45
+        - name: ETCDCTL_CACERT
46
+          value: /etc/etcd/tls/certs/client-ca.pem
47
+        - name: ETCDCTL_CERT
48
+          value: /etc/etcd/tls/certs/anchor-etcd-client.pem
49
+        - name: ETCDCTL_KEY
50
+          value: /etc/etcd/tls/keys/anchor-etcd-client-key.pem
51
+        - name: CLIENT_ENDPOINT
52
+          value: https://$(POD_IP):{{ .Values.network.service_client.target_port }}
53
+        - name: PEER_ENDPOINT
54
+          value: https://$(POD_IP):{{ .Values.network.service_peer.target_port }}
55
+      image: {{ .Values.images.tags.etcdctl }}
56
+      imagePullPolicy: {{ .Values.images.pull_policy }}
57
+{{ tuple . .Values.pod.resources.test | include "helm-toolkit.snippets.kubernetes_resources" | indent 6 }}
58
+      command:
59
+        - /bin/sh
60
+        - -c
61
+        - |
62
+          HEALTH=$(etcdctl endpoint health)
63
+          CODE=$?
64
+          echo $HEALTH
65
+          exit $CODE
66
+      volumeMounts:
67
+        - name: {{ .Values.service.name }}-bin
68
+          mountPath: /tmp
69
+        - name: {{ .Values.service.name }}-certs
70
+          mountPath: /etc/etcd/tls/certs
71
+        - name: etcd-etc
72
+          mountPath: /etcd-etc
73
+        - name: {{ .Values.service.name }}-keys
74
+          mountPath: /etc/etcd/tls/keys
75
+        - name: {{ .Values.service.name }}-etc
76
+          mountPath: /anchor-etcd
77
+  volumes:
78
+    - name: {{ .Values.service.name }}-bin
79
+      configMap:
80
+        name: {{ .Values.service.name }}-bin
81
+        defaultMode: 0555
82
+    - name: {{ .Values.service.name }}-certs
83
+      configMap:
84
+        name: {{ .Values.service.name }}-certs
85
+        defaultMode: 0444
86
+    - name: {{ .Values.service.name }}-keys
87
+      secret:
88
+        secretName: {{ .Values.service.name }}-keys
89
+        defaultMode: 0444
90
+    - name: etcd-etc
91
+      hostPath:
92
+        path: {{ .Values.etcd.host_etc_path }}
93
+    - name: {{ .Values.service.name }}-etc
94
+      configMap:
95
+        name: {{ .Values.service.name }}-etc
96
+        defaultMode: 0444
97
+...
98
+{{- end }}

+ 8
- 0
charts/etcd/values.yaml View File

@@ -116,6 +116,13 @@ pod:
116 116
       limits:
117 117
         memory: "1024Mi"
118 118
         cpu: "2000m"
119
+    test:
120
+      limits:
121
+        memory: "128Mi"
122
+        cpu: "100m"
123
+      requests:
124
+        memory: "128Mi"
125
+        cpu: "100m"
119 126
 
120 127
 manifests:
121 128
   configmap_bin: true
@@ -124,3 +131,4 @@ manifests:
124 131
   daemonset_anchor: true
125 132
   secret: true
126 133
   service: true
134
+  test_etcd_health: true

+ 1
- 0
examples/basic/armada-resources.yaml View File

@@ -1015,6 +1015,7 @@ data:
1015 1015
   timeout: 600
1016 1016
   wait:
1017 1017
     timeout: 600
1018
+  test: true
1018 1019
   upgrade:
1019 1020
     no_hooks: true
1020 1021
   values:

+ 1
- 0
examples/complete/armada-resources.yaml View File

@@ -1055,6 +1055,7 @@ data:
1055 1055
   timeout: 600
1056 1056
   wait:
1057 1057
     timeout: 600
1058
+  test: true
1058 1059
   upgrade:
1059 1060
     no_hooks: true
1060 1061
   values:

Loading…
Cancel
Save