mirror of https://git.rancher.io/charts
Move establishing CRD logic to a helper template
parent
5f3bbe4a36
commit
02ff0c9df8
|
@ -26,4 +26,25 @@ beta.kubernetes.io/os: linux
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
kubernetes.io/os: linux
|
kubernetes.io/os: linux
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
# CRD Installation
|
||||||
|
|
||||||
|
{{- define "crd.established" -}}
|
||||||
|
{{- if not (regexMatch "^([a-zA-Z]+[.][a-zA-Z]*)+$" .) -}}
|
||||||
|
{{ required (printf "%s is not a valid CRD" .) "" }}
|
||||||
|
{{- else -}}
|
||||||
|
echo "beginning wait for {{ . }} to be established...";
|
||||||
|
num_tries=1;
|
||||||
|
until kubectl get crd {{ . }} -o=jsonpath='{range .status.conditions[*]}{.type}={.status} {end}' | grep -qE 'Established=True'; do
|
||||||
|
if (( num_tries == 30 )); then
|
||||||
|
echo "timed out waiting for {{ . }}";
|
||||||
|
exit 1;
|
||||||
|
fi;
|
||||||
|
num_tries=$(( num_tries + 1 ));
|
||||||
|
echo "{{ . }} is not established. Sleeping for 2 seconds and trying again...";
|
||||||
|
sleep 2;
|
||||||
|
done;
|
||||||
|
echo "successfully established {{ . }}";
|
||||||
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
|
@ -35,18 +35,7 @@ spec:
|
||||||
patch="{\"spec\": {\"preserveUnknownFields\": false, \"versions\": [{\"name\": \"v1\", \"served\": false, \"storage\": true}]}}";
|
patch="{\"spec\": {\"preserveUnknownFields\": false, \"versions\": [{\"name\": \"v1\", \"served\": false, \"storage\": true}]}}";
|
||||||
fi
|
fi
|
||||||
if kubectl patch crd {{ $crd }} -p "${patch}" --type="merge"; then
|
if kubectl patch crd {{ $crd }} -p "${patch}" --type="merge"; then
|
||||||
echo "beginning wait for {{ $crd }} to be established...";
|
{{- include "crd.established" $crd | nindent 18 }}
|
||||||
num_tries=1;
|
|
||||||
until kubectl get crd {{ $crd }} -o=jsonpath='{range .status.conditions[*]}{.type}={.status} {end}' | grep -qE 'Established=True'; do
|
|
||||||
if (( num_tries == 30 )); then
|
|
||||||
echo "timed out waiting for {{ $crd }}";
|
|
||||||
exit 1;
|
|
||||||
fi;
|
|
||||||
num_tries=$(( num_tries + 1 ));
|
|
||||||
echo "{{ $crd }} is not established. Sleeping for 2 seconds and trying again...";
|
|
||||||
sleep 2;
|
|
||||||
done;
|
|
||||||
echo "successfully established {{ $crd }}";
|
|
||||||
fi;
|
fi;
|
||||||
fi;
|
fi;
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
@ -70,18 +59,7 @@ spec:
|
||||||
|
|
||||||
{{- range $path, $_ := (.Files.Glob "crd-manifest/**.yaml") }}
|
{{- range $path, $_ := (.Files.Glob "crd-manifest/**.yaml") }}
|
||||||
{{- $crd := get (get ($.Files.Get $path | fromYaml) "metadata") "name" }}
|
{{- $crd := get (get ($.Files.Get $path | fromYaml) "metadata") "name" }}
|
||||||
echo "beginning wait for {{ $crd }} to be established...";
|
{{- include "crd.established" $crd | nindent 12 }}
|
||||||
num_tries=1;
|
|
||||||
until kubectl get crd {{ $crd }} -o=jsonpath='{range .status.conditions[*]}{.type}={.status} {end}' | grep -qE 'Established=True'; do
|
|
||||||
if (( num_tries == 30 )); then
|
|
||||||
echo "timed out waiting for {{ $crd }}";
|
|
||||||
exit 1;
|
|
||||||
fi;
|
|
||||||
num_tries=$(( num_tries + 1 ));
|
|
||||||
echo "{{ $crd }} is not established. Sleeping for 2 seconds and trying again...";
|
|
||||||
sleep 2;
|
|
||||||
done;
|
|
||||||
echo "successfully established {{ $crd }}";
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: crd-manifest
|
- name: crd-manifest
|
||||||
|
@ -127,18 +105,7 @@ spec:
|
||||||
{{- range $path, $_ := (.Files.Glob "crd-manifest/**.yaml") }}
|
{{- range $path, $_ := (.Files.Glob "crd-manifest/**.yaml") }}
|
||||||
{{- $crd := get (get ($.Files.Get $path | fromYaml) "metadata") "name" }}
|
{{- $crd := get (get ($.Files.Get $path | fromYaml) "metadata") "name" }}
|
||||||
if kubectl patch crd {{ $crd }} -p '{"metadata": {"finalizers": []}}'; then
|
if kubectl patch crd {{ $crd }} -p '{"metadata": {"finalizers": []}}'; then
|
||||||
echo "beginning wait for {{ $crd }} to be established...";
|
{{- include "crd.established" $crd | nindent 14 }}
|
||||||
num_tries=1;
|
|
||||||
until kubectl get crd {{ $crd }} -o=jsonpath='{range .status.conditions[*]}{.type}={.status} {end}' | grep -qE 'Established=True'; do
|
|
||||||
if (( num_tries == 30 )); then
|
|
||||||
echo "timed out waiting for {{ $crd }}";
|
|
||||||
exit 1;
|
|
||||||
fi;
|
|
||||||
num_tries=$(( num_tries + 1 ));
|
|
||||||
echo "{{ $crd }} is not established. Sleeping for 2 seconds and trying again...";
|
|
||||||
sleep 2;
|
|
||||||
done;
|
|
||||||
echo "successfully established {{ $crd }}";
|
|
||||||
fi;
|
fi;
|
||||||
{{- end }}
|
{{- end }}
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
|
|
Loading…
Reference in New Issue