git clone https://github.com/bitnami/charts.git
cd charts/bitnami/kube-prometheus
bash update-crds.sh
Created
September 3, 2020 14:46
-
-
Save crandles/29c18d5649f5e88cc9fa3c23d6d8faee to your computer and use it in GitHub Desktop.
update bitnami/kube-prometheus prometheus-operator CRDs
This file contains hidden or 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
#!/bin/bash | |
# download the latest operator crd bundle | |
wget https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.41.1/bundle.yaml | |
# split the bundle into multiple files on `---` | |
csplit --elide-empty-files -f bundle- bundle.yaml "/^---$/" "{*}" | |
for f in ./bundle-* | |
do | |
name=$(cat $f | sed -n -e '/^metadata:/,/^spec:/p' | sed -n 's/ name: \(.\)/\1/p') | |
kind=$(cat $f | sed -n 's/^kind: \(.*\)/\1/p') | |
if [ "$kind" = "CustomResourceDefinition" ]; then | |
if [[ ! -z "$name" ]]; then | |
crd=$(echo $name | cut -d "." -f 1) | |
normalizedCRD=$( | |
case "$crd" in | |
("alertmanagers") echo "alertmanager" ;; | |
("prometheuses") echo "prometheus" ;; | |
("podmonitors") echo "podmonitor" ;; | |
("servicemonitors") echo "servicemonitor" ;; | |
(*) echo "$crd" ;; | |
esac) | |
contents=$(tail -n +2 $f) | |
echo "$contents" > crds/crd-$normalizedCRD.yaml | |
(cat <<-EOF | |
{{- if and .Values.operator.enabled .Values.operator.createCustomResource -}} | |
apiVersion: apiextensions.k8s.io/v1 | |
kind: CustomResourceDefinition | |
metadata: | |
name: ${name} | |
annotations: | |
controller-gen.kubebuilder.io/version: v0.2.4 | |
"helm.sh/hook": crd-install | |
{{- if .Values.operator.customResourceDeletePolicy }} | |
"helm.sh/hook-delete-policy": {{ .Values.operator.customResourceDeletePolicy }} | |
{{- end }} | |
EOF | |
) > templates/prometheus-operator/crd-$normalizedCRD.yaml | |
spec=$(echo "$contents" | sed -n -e '/^spec:/,/^status:/p' | sed -e '$ d') | |
echo -e "${spec}" >> templates/prometheus-operator/crd-$normalizedCRD.yaml | |
status=$(echo "$contents" | sed -n -e '/^status:/,$p') | |
echo -e "${status}" >> templates/prometheus-operator/crd-$normalizedCRD.yaml | |
echo -e "{{- end }}\n" >> templates/prometheus-operator/crd-$normalizedCRD.yaml | |
sed -i -e 's/ *$//g' templates/prometheus-operator/crd-$normalizedCRD.yaml | |
fi | |
fi | |
rm $f | |
done | |
rm bundle.yaml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment