Skip to content

Commit 6e565c3

Browse files
ArthurSensroboquat
authored andcommitted
.werft/observability: Better CRD handling
Signed-off-by: ArthurSens <[email protected]>
1 parent ae13964 commit 6e565c3

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

.werft/observability/monitoring-satellite.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,10 @@ function installSetup() {
231231
exec('kubectl apply -f observability/monitoring-satellite/manifests/namespace.yaml', {silent: true})
232232
exec('kubectl apply -f observability/monitoring-satellite/manifests/podsecuritypolicy-restricted.yaml', {silent: true})
233233

234-
const crdExists = exec('kubectl get customresourcedefinitions.apiextensions.k8s.io alertmanagers.monitoring.coreos.com', {silent: true, dontCheckRc: true}).code == 0
235-
if (crdExists) {
236-
werft.log(sliceName, "CRDs already exists, replacing CRDs'")
237-
exec('for yaml in $(find observability/monitoring-satellite/manifests/prometheus-operator/ -type f -name "*CustomResourceDefinition.yaml"); do cat $yaml | kubectl delete -f -; done', {slice: sliceName})
238-
}
239-
exec('for yaml in $(find observability/monitoring-satellite/manifests/prometheus-operator/ -type f -name "*CustomResourceDefinition.yaml"); do cat $yaml | kubectl create -f -; done', {slice: sliceName})
234+
const CRDs = exec(`find observability/monitoring-satellite/manifests/prometheus-operator/ -type f -name "*CustomResourceDefinition.yaml"`, {silent: true}).stdout.trim().split('\n')
235+
CRDs.forEach(crd => {
236+
exec(`kubectl replace -f ${crd} || kubectl create -f ${crd}`, {slice: sliceName})
237+
});
240238
// Making sure CRDs got installed
241239
exec('until kubectl get servicemonitors.monitoring.coreos.com --all-namespaces ; do date; sleep 1; echo ""; done', {silent: true})
242240

0 commit comments

Comments
 (0)