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 -}}
|
||||
kubernetes.io/os: linux
|
||||
{{- 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 -}}
|
|
@ -35,18 +35,7 @@ spec:
|
|||
patch="{\"spec\": {\"preserveUnknownFields\": false, \"versions\": [{\"name\": \"v1\", \"served\": false, \"storage\": true}]}}";
|
||||
fi
|
||||
if kubectl patch crd {{ $crd }} -p "${patch}" --type="merge"; then
|
||||
echo "beginning wait for {{ $crd }} to be established...";
|
||||
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 }}";
|
||||
{{- include "crd.established" $crd | nindent 18 }}
|
||||
fi;
|
||||
fi;
|
||||
{{- end }}
|
||||
|
@ -70,18 +59,7 @@ spec:
|
|||
|
||||
{{- range $path, $_ := (.Files.Glob "crd-manifest/**.yaml") }}
|
||||
{{- $crd := get (get ($.Files.Get $path | fromYaml) "metadata") "name" }}
|
||||
echo "beginning wait for {{ $crd }} to be established...";
|
||||
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 }}";
|
||||
{{- include "crd.established" $crd | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: crd-manifest
|
||||
|
@ -127,18 +105,7 @@ spec:
|
|||
{{- range $path, $_ := (.Files.Glob "crd-manifest/**.yaml") }}
|
||||
{{- $crd := get (get ($.Files.Get $path | fromYaml) "metadata") "name" }}
|
||||
if kubectl patch crd {{ $crd }} -p '{"metadata": {"finalizers": []}}'; then
|
||||
echo "beginning wait for {{ $crd }} to be established...";
|
||||
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 }}";
|
||||
{{- include "crd.established" $crd | nindent 14 }}
|
||||
fi;
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
|
|
Loading…
Reference in New Issue