Skip to content

Commit

Permalink
chore: add helm test && refactor labels && add pod probes (#31)
Browse files Browse the repository at this point in the history
Signed-off-by: Bird <aflybird0@gmail.com>
  • Loading branch information
aFlyBird0 authored May 4, 2023
1 parent 68ca7bc commit c6161f9
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 56 deletions.
2 changes: 1 addition & 1 deletion charts/shenyu/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
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:
Expand Down
5 changes: 1 addition & 4 deletions charts/shenyu/templates/ConfigMap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ metadata:
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*/}}
Expand Down
21 changes: 21 additions & 0 deletions charts/shenyu/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
27 changes: 17 additions & 10 deletions charts/shenyu/templates/shenyu-admin-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,16 @@ metadata:
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") -}}
Expand Down Expand Up @@ -93,6 +86,20 @@ spec:
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
Expand Down
7 changes: 2 additions & 5 deletions charts/shenyu/templates/shenyu-admin-hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ metadata:
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
Expand All @@ -29,4 +26,4 @@ spec:
name: memory
targetAverageUtilization: {{ .Values.admin.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
{{- end }}
5 changes: 1 addition & 4 deletions charts/shenyu/templates/shenyu-admin-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ kind: Ingress
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 }}
Expand Down
8 changes: 2 additions & 6 deletions charts/shenyu/templates/shenyu-admin-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ metadata:
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
Expand Down
25 changes: 15 additions & 10 deletions charts/shenyu/templates/shenyu-bootstrap-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,16 @@ metadata:
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
Expand All @@ -43,6 +36,18 @@ spec:
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
Expand Down
7 changes: 2 additions & 5 deletions charts/shenyu/templates/shenyu-bootstrap-hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ metadata:
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
Expand All @@ -29,4 +26,4 @@ spec:
name: memory
targetAverageUtilization: {{ .Values.bootstrap.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
{{- end }}
5 changes: 1 addition & 4 deletions charts/shenyu/templates/shenyu-bootstrap-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ kind: Ingress
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 }}
Expand Down
8 changes: 2 additions & 6 deletions charts/shenyu/templates/shenyu-bootstrap-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ metadata:
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
Expand Down
19 changes: 19 additions & 0 deletions charts/shenyu/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion charts/shenyu/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,11 @@ applicationConfig:
- /fallback/hystrix
- /fallback/resilience4j
health:
enabled: false
enabled: true
paths:
- /actuator/health
- /actuator/health/readiness
- /actuator/health/liveness
- /health_check
extPlugin:
path:
Expand Down

0 comments on commit c6161f9

Please sign in to comment.