Skip to content

Commit

Permalink
.werft/observability: Better CRD handling
Browse files Browse the repository at this point in the history
Signed-off-by: ArthurSens <[email protected]>
  • Loading branch information
ArthurSens authored and roboquat committed Nov 17, 2021
1 parent ae13964 commit 6e565c3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions .werft/observability/monitoring-satellite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,10 @@ function installSetup() {
exec('kubectl apply -f observability/monitoring-satellite/manifests/namespace.yaml', {silent: true})
exec('kubectl apply -f observability/monitoring-satellite/manifests/podsecuritypolicy-restricted.yaml', {silent: true})

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

Expand Down

0 comments on commit 6e565c3

Please sign in to comment.