forked from kloeckner-i/charts
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
274 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
reconcileInterval: "10" | ||
crds: | ||
keep: false | ||
tests: | ||
crds: | ||
enabled: true | ||
installed: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
reconcileInterval: "10" | ||
crds: | ||
keep: false | ||
install: false | ||
tests: | ||
crds: | ||
enabled: true | ||
installed: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
{{- $version := semver .Capabilities.KubeVersion.Version }} | ||
{{- if .Values.tests.crds.enabled }} | ||
# --------------------------------------------------------------------- | ||
# -- Test that CRDs are installed | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ template "db-operator.name" . }}-test-script | ||
labels: | ||
{{- include "labels" . | nindent 4 }} | ||
annotations: | ||
"helm.sh/hook": test | ||
{{- if .Values.tests.cleanup }} | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
{{- end }} | ||
"helm.sh/hook-weight": "6" | ||
data: | ||
test_crds.sh: |- | ||
#!/bin/bash | ||
ATTEMPTS_AMOUNT="{{ .Values.tests.attempts.amount }}" | ||
ATTEMPTS_TIMEOUT="{{ .Values.tests.attempts.timeout }}" | ||
CRDS=("databases.kinda.rocks" "dbinstances.kinda.rocks" "dbusers.kinda.rocks") | ||
EXPECTED_STATUS=1 | ||
TEST_PASSED=false | ||
x=1 | ||
while [ $x -le "${ATTEMPTS_AMOUNT}" ]; do | ||
for CRD in "${CRDS[@]}"; do | ||
SUCCESS=true | ||
INSTALLED="{{ .Values.tests.crds.installed }}" | ||
if ! kubectl get crd $CRD; then | ||
SUCCESS=false | ||
INSTALLED="false" | ||
echo "[ERROR]: CRS ${CRS} is not in the wished state" | ||
break; | ||
fi; | ||
done | ||
if [ "${INSTALLED}" == "{{ .Values.tests.crds.installed }}" ]; then | ||
echo "[INFO]: Test is passed, CRDs installed -> {{ .Values.tests.crds.installed }}" | ||
TEST_PASSED=true; | ||
break; | ||
fi | ||
echo "[INFO]: Sleeping ${ATTEMPTS_TIMEOUT} seconds" | ||
sleep $ATTEMPTS_TIMEOUT | ||
x=$(( $x + 1 )); | ||
done | ||
if [ "${TEST_PASSED}" != "true" ]; then | ||
echo "[ERROR]: Test is failed, check the kubectl get crds output" | ||
echo $(kubectl get crds) | ||
exit 1; | ||
fi | ||
--- | ||
# --------------------------------------------------------------------- | ||
# -- Prepare roles and bindings to access k8s resources from the test | ||
# --------------------------------------------------------------------- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: {{ template "db-operator.name" . }}-gsql-dbin-role | ||
labels: | ||
{{- include "labels" . | nindent 4 }} | ||
annotations: | ||
"helm.sh/hook": test | ||
{{- if .Values.tests.cleanup }} | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
{{- end }} | ||
"helm.sh/hook-weight": "1" | ||
rules: | ||
- apiGroups: ["*"] | ||
resources: ["*"] | ||
verbs: ["get", "list",] | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ template "db-operator.name" . }}-gsql-dbin-sa | ||
labels: | ||
{{- include "labels" . | nindent 4 }} | ||
annotations: | ||
"helm.sh/hook": test | ||
{{- if .Values.tests.cleanup }} | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
{{- end }} | ||
"helm.sh/hook-weight": "1" | ||
automountServiceAccountToken: true | ||
|
||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: {{ template "db-operator.name" . }}-gsql-dbin-rb | ||
labels: | ||
{{- include "labels" . | nindent 4 }} | ||
annotations: | ||
"helm.sh/hook": test | ||
{{- if .Values.tests.cleanup }} | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
{{- end }} | ||
"helm.sh/hook-weight": "1" | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ template "db-operator.name" . }}-gsql-dbin-sa | ||
namespace: {{ .Release.Namespace }} | ||
roleRef: | ||
kind: ClusterRole | ||
name: {{ template "db-operator.name" . }}-gsql-dbin-role | ||
apiGroup: rbac.authorization.k8s.io | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: {{ template "db-operator.name" . }}-test | ||
labels: | ||
{{- include "labels" . | nindent 4 }} | ||
annotations: | ||
"helm.sh/hook": test | ||
{{- if .Values.tests.cleanup }} | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
{{- end }} | ||
"helm.sh/hook-weight": "7" | ||
spec: | ||
serviceAccountName: {{ template "db-operator.name" . }}-gsql-dbin-sa | ||
automountServiceAccountToken: true | ||
volumes: | ||
- name: test-script | ||
configMap: | ||
name: {{ template "db-operator.name" . }}-test-script | ||
containers: | ||
- name: tester | ||
image: alpine/k8s:{{ $version.Major }}.{{ $version.Minor }}.{{ $version.Patch }} | ||
volumeMounts: | ||
- name: test-script | ||
readOnly: true | ||
mountPath: /test_crds.sh | ||
subPath: test_crds.sh | ||
command: | ||
- bash | ||
args: | ||
- -e | ||
- /test_crds.sh | ||
restartPolicy: Never | ||
{{- end }} |
Oops, something went wrong.