chore: add helm test && refactor labels && add pod probes (#31)
Signed-off-by: Bird <aflybird0@gmail.com>
diff --git a/charts/shenyu/Chart.yaml b/charts/shenyu/Chart.yaml
index 64b3dc3..bd26a43 100644
--- a/charts/shenyu/Chart.yaml
+++ b/charts/shenyu/Chart.yaml
@@ -2,7 +2,7 @@
name: shenyu
description: Helm Chart for deploying Apache ShenYu in Kubernetes
type: application
-version: 0.6.1
+version: 0.6.2
appVersion: "2.5.1"
icon: https://shenyu.apache.org/img/logo.png
maintainers:
diff --git a/charts/shenyu/templates/ConfigMap.yaml b/charts/shenyu/templates/ConfigMap.yaml
index cfcc946..5867e36 100644
--- a/charts/shenyu/templates/ConfigMap.yaml
+++ b/charts/shenyu/templates/ConfigMap.yaml
@@ -4,10 +4,7 @@
namespace: {{.Release.Namespace}}
name: {{ template "common.names.fullname" . }}-configmap
labels:
- "app.kubernetes.io/name": '{{ template "common.names.name" . }}'
- "app.kubernetes.io/managed-by": "{{ .Release.Service }}"
- "app.kubernetes.io/component": "shenyu-configmap"
- "app.kubernetes.io/instance": "{{ .Release.Name }}"
+ {{- include "common.labels.standard" . | nindent 4 }}
data:
application-bootstrap.yml: |-
{{- /* Put the whole application-bootstrap.yml here*/}}
diff --git a/charts/shenyu/templates/_helpers.tpl b/charts/shenyu/templates/_helpers.tpl
index 6a9e01e..4e61e8b 100644
--- a/charts/shenyu/templates/_helpers.tpl
+++ b/charts/shenyu/templates/_helpers.tpl
@@ -31,3 +31,24 @@
{{- end }}
{{- end }}
{{- end -}}
+
+
+{{- define "shenyu.admin.labels" -}}
+{{ include "common.labels.standard" . }}
+app.kubernetes.io/component: shenyu-admin
+{{- end -}}
+
+{{- define "shenyu.admin.selectorLabels" -}}
+{{ include "common.labels.matchLabels" . }}
+app.kubernetes.io/component: shenyu-admin
+{{- end -}}
+
+{{- define "shenyu.bootstrap.labels" -}}
+{{ include "common.labels.standard" . }}
+app.kubernetes.io/component: shenyu-bootstrap
+{{- end -}}
+
+{{- define "shenyu.bootstrap.selectorLabels" -}}
+{{ include "common.labels.matchLabels" . }}
+app.kubernetes.io/component: shenyu-bootstrap
+{{- end -}}
diff --git a/charts/shenyu/templates/shenyu-admin-deployment.yaml b/charts/shenyu/templates/shenyu-admin-deployment.yaml
index 63807ec..e35c88f 100644
--- a/charts/shenyu/templates/shenyu-admin-deployment.yaml
+++ b/charts/shenyu/templates/shenyu-admin-deployment.yaml
@@ -5,23 +5,16 @@
namespace: {{ .Release.Namespace }}
name: {{ template "common.names.fullname" . }}-admin
labels:
- "app.kubernetes.io/name": '{{ template "common.names.name" . }}-admin'
- "app.kubernetes.io/managed-by": "{{ .Release.Service }}"
- "app.kubernetes.io/component": "shenyu-admin"
- "app.kubernetes.io/instance": "{{ .Release.Name }}"
+ {{- include "shenyu.admin.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
- "app.kubernetes.io/component": "shenyu-admin"
- "app.kubernetes.io/instance": "{{ .Release.Name }}"
+ {{- include "shenyu.admin.selectorLabels" . | nindent 6 }}
replicas: {{ .Values.admin.replicas }}
template:
metadata:
labels:
- "app.kubernetes.io/name": '{{ template "common.names.name" . }}-admin'
- "app.kubernetes.io/managed-by": "{{ .Release.Service }}"
- "app.kubernetes.io/component": "shenyu-admin"
- "app.kubernetes.io/instance": "{{ .Release.Name }}"
+ {{- include "shenyu.admin.labels" . | nindent 8 }}
spec:
{{/* check if database type is valid */}}
{{- $dataSourceTypeValid := has .Values.dataSource.active (list "h2" "mysql" "pg" "oracle") -}}
@@ -93,6 +86,20 @@
value: {{ .Values.admin.javaOpts | quote }}
resources:
{{- toYaml .Values.admin.resources | nindent 12 }}
+ readinessProbe:
+ httpGet:
+ # todo change it to /actuator/health/readiness when shenyu-admin support it
+ path: /actuator/health
+ port: 9095
+ periodSeconds: 5
+ failureThreshold: 12
+ livenessProbe:
+ httpGet:
+ # todo change it to /actuator/health/liveness when shenyu-admin support it
+ path: /actuator/health
+ port: 9095
+ periodSeconds: 5
+ failureThreshold: 12
volumeMounts:
- name: shenyu-admin-config
mountPath: /opt/shenyu-admin/conf/application.yml
diff --git a/charts/shenyu/templates/shenyu-admin-hpa.yaml b/charts/shenyu/templates/shenyu-admin-hpa.yaml
index 2538063..2bdbb95 100644
--- a/charts/shenyu/templates/shenyu-admin-hpa.yaml
+++ b/charts/shenyu/templates/shenyu-admin-hpa.yaml
@@ -5,10 +5,7 @@
namespace: {{ .Release.Namespace }}
name: {{ template "common.names.fullname" . }}-admin
labels:
- "app.kubernetes.io/name": '{{ template "common.names.name" . }}-admin'
- "app.kubernetes.io/managed-by": "{{ .Release.Service }}"
- "app.kubernetes.io/component": "shenyu-admin"
- "app.kubernetes.io/instance": "{{ .Release.Name }}"
+ {{- include "shenyu.admin.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
@@ -29,4 +26,4 @@
name: memory
targetAverageUtilization: {{ .Values.admin.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
-{{- end }}
\ No newline at end of file
+{{- end }}
diff --git a/charts/shenyu/templates/shenyu-admin-ingress.yaml b/charts/shenyu/templates/shenyu-admin-ingress.yaml
index 4eaff00..2b71fed 100644
--- a/charts/shenyu/templates/shenyu-admin-ingress.yaml
+++ b/charts/shenyu/templates/shenyu-admin-ingress.yaml
@@ -17,10 +17,7 @@
metadata:
name: {{ $fullName }}-admin
labels:
- "app.kubernetes.io/name": '{{ template "common.names.name" . }}-admin'
- "app.kubernetes.io/managed-by": "{{ .Release.Service }}"
- "app.kubernetes.io/component": "shenyu-admin"
- "app.kubernetes.io/instance": "{{ .Release.Name }}"
+ {{- include "shenyu.admin.labels" . | nindent 4 }}
{{- with .Values.admin.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
diff --git a/charts/shenyu/templates/shenyu-admin-svc.yaml b/charts/shenyu/templates/shenyu-admin-svc.yaml
index 06ced5e..6392d6a 100644
--- a/charts/shenyu/templates/shenyu-admin-svc.yaml
+++ b/charts/shenyu/templates/shenyu-admin-svc.yaml
@@ -6,14 +6,10 @@
namespace: {{ .Release.Namespace }}
name: {{ template "common.names.fullname" . }}-admin
labels:
- "app.kubernetes.io/name": '{{ template "common.names.name" . }}-admin'
- "app.kubernetes.io/managed-by": "{{ .Release.Service }}"
- "app.kubernetes.io/component": "shenyu-admin"
- "app.kubernetes.io/instance": "{{ .Release.Name }}"
+ {{- include "shenyu.admin.labels" . | nindent 4 }}
spec:
selector:
- "app.kubernetes.io/component": "shenyu-admin"
- "app.kubernetes.io/instance": "{{ .Release.Name }}"
+ {{- include "shenyu.admin.selectorLabels" . | nindent 4 }}
type: NodePort
ports:
- protocol: TCP
diff --git a/charts/shenyu/templates/shenyu-bootstrap-deployment.yaml b/charts/shenyu/templates/shenyu-bootstrap-deployment.yaml
index 28d9412..c402123 100644
--- a/charts/shenyu/templates/shenyu-bootstrap-deployment.yaml
+++ b/charts/shenyu/templates/shenyu-bootstrap-deployment.yaml
@@ -6,23 +6,16 @@
namespace: {{ .Release.Namespace }}
name: {{ template "common.names.fullname" . }}-bootstrap
labels:
- "app.kubernetes.io/name": '{{ template "common.names.name" . }}-bootstrap'
- "app.kubernetes.io/managed-by": "{{ .Release.Service }}"
- "app.kubernetes.io/component": "shenyu-bootstrap"
- "app.kubernetes.io/instance": "{{ .Release.Name }}"
+ {{- include "shenyu.bootstrap.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
- "app.kubernetes.io/component": "shenyu-bootstrap"
- "app.kubernetes.io/instance": "{{ .Release.Name }}"
+ {{- include "shenyu.bootstrap.selectorLabels" . | nindent 6 }}
replicas: {{ .Values.bootstrap.replicas }}
template:
metadata:
labels:
- "app.kubernetes.io/name": '{{ template "common.names.name" . }}-bootstrap'
- "app.kubernetes.io/managed-by": "{{ .Release.Service }}"
- "app.kubernetes.io/component": "shenyu-bootstrap"
- "app.kubernetes.io/instance": "{{ .Release.Name }}"
+ {{- include "shenyu.bootstrap.labels" . | nindent 8 }}
spec:
volumes:
- name: shenyu-bootstrap-config
@@ -43,6 +36,18 @@
value: {{ .Values.bootstrap.javaOpts | quote }}
resources:
{{- toYaml .Values.bootstrap.resources | nindent 12 }}
+ readinessProbe:
+ httpGet:
+ path: /actuator/health/readiness
+ port: 9195
+ periodSeconds: 5
+ failureThreshold: 12
+ livenessProbe:
+ httpGet:
+ path: /actuator/health/liveness
+ port: 9195
+ periodSeconds: 5
+ failureThreshold: 12
volumeMounts:
- name: shenyu-bootstrap-config
mountPath: /opt/shenyu-bootstrap/conf/application.yml
diff --git a/charts/shenyu/templates/shenyu-bootstrap-hpa.yaml b/charts/shenyu/templates/shenyu-bootstrap-hpa.yaml
index 174bdde..6f6a887 100644
--- a/charts/shenyu/templates/shenyu-bootstrap-hpa.yaml
+++ b/charts/shenyu/templates/shenyu-bootstrap-hpa.yaml
@@ -5,10 +5,7 @@
namespace: {{ .Release.Namespace }}
name: {{ template "common.names.fullname" . }}-bootstrap
labels:
- "app.kubernetes.io/name": '{{ template "common.names.name" . }}-bootstrap'
- "app.kubernetes.io/managed-by": "{{ .Release.Service }}"
- "app.kubernetes.io/component": "shenyu-bootstrap"
- "app.kubernetes.io/instance": "{{ .Release.Name }}"
+ {{- include "shenyu.bootstrap.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
@@ -29,4 +26,4 @@
name: memory
targetAverageUtilization: {{ .Values.bootstrap.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
-{{- end }}
\ No newline at end of file
+{{- end }}
diff --git a/charts/shenyu/templates/shenyu-bootstrap-ingress.yaml b/charts/shenyu/templates/shenyu-bootstrap-ingress.yaml
index 46169df..bb29782 100644
--- a/charts/shenyu/templates/shenyu-bootstrap-ingress.yaml
+++ b/charts/shenyu/templates/shenyu-bootstrap-ingress.yaml
@@ -17,10 +17,7 @@
metadata:
name: {{ $fullName }}-bootstrap
labels:
- "app.kubernetes.io/name": '{{ template "common.names.name" . }}-bootstrap'
- "app.kubernetes.io/managed-by": "{{ .Release.Service }}"
- "app.kubernetes.io/component": "shenyu-bootstrap"
- "app.kubernetes.io/instance": "{{ .Release.Name }}"
+ {{- include "shenyu.bootstrap.labels" . | nindent 4 }}
{{- with .Values.bootstrap.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
diff --git a/charts/shenyu/templates/shenyu-bootstrap-svc.yaml b/charts/shenyu/templates/shenyu-bootstrap-svc.yaml
index 4bef437..bf6ff33 100644
--- a/charts/shenyu/templates/shenyu-bootstrap-svc.yaml
+++ b/charts/shenyu/templates/shenyu-bootstrap-svc.yaml
@@ -6,14 +6,10 @@
namespace: {{ .Release.Namespace }}
name: {{ template "common.names.fullname" . }}-bootstrap
labels:
- "app.kubernetes.io/name": '{{ template "common.names.name" .}}-bootstrap'
- "app.kubernetes.io/managed-by": "{{ .Release.Service }}"
- "app.kubernetes.io/component": "shenyu-bootstrap"
- "app.kubernetes.io/instance": "{{ .Release.Name }}"
+ {{- include "shenyu.bootstrap.labels" . | nindent 4 }}
spec:
selector:
- "app.kubernetes.io/component": "shenyu-bootstrap"
- "app.kubernetes.io/instance": "{{ .Release.Name }}"
+ {{- include "shenyu.bootstrap.selectorLabels" . | nindent 4 }}
type: NodePort
ports:
- protocol: TCP
diff --git a/charts/shenyu/templates/tests/test-connection.yaml b/charts/shenyu/templates/tests/test-connection.yaml
new file mode 100644
index 0000000..1650a76
--- /dev/null
+++ b/charts/shenyu/templates/tests/test-connection.yaml
@@ -0,0 +1,19 @@
+apiVersion: v1
+kind: Pod
+metadata:
+ name: "{{ template "common.names.fullname" .}}-test-connection"
+ labels:
+ {{- include "common.labels.standard" . | nindent 4 }}
+ annotations:
+ "helm.sh/hook": test
+spec:
+ containers:
+ - name: wget
+ image: busybox
+ command: ['sh', '-c']
+ args:
+ - |
+ wget -q -O - '{{ include "common.names.fullname" . }}-admin:{{ .Values.admin.service.port }}/actuator/health'
+ wget -q -O - '{{ include "common.names.fullname" . }}-bootstrap:{{ .Values.bootstrap.service.port }}/actuator/health'
+ # TODO add more tests, such as shenyu test scripts
+ restartPolicy: Never
diff --git a/charts/shenyu/values.yaml b/charts/shenyu/values.yaml
index a128001..2116016 100644
--- a/charts/shenyu/values.yaml
+++ b/charts/shenyu/values.yaml
@@ -357,9 +357,11 @@
- /fallback/hystrix
- /fallback/resilience4j
health:
- enabled: false
+ enabled: true
paths:
- /actuator/health
+ - /actuator/health/readiness
+ - /actuator/health/liveness
- /health_check
extPlugin:
path: