diff --git a/hack/example-service-monitoring/deploy b/hack/example-service-monitoring/deploy index 9b359d2de14c91b94af615d743a9abf9bd5ac626..420b5940504205d69dfd6d99c741ed6ef1e7bfde 100755 --- a/hack/example-service-monitoring/deploy +++ b/hack/example-service-monitoring/deploy @@ -4,8 +4,16 @@ if [ -z "${KUBECONFIG}" ]; then KUBECONFIG=~/.kube/config fi -kubectl --kubeconfig="$KUBECONFIG" apply -f manifests/examples/example-app/prometheus-frontend-svc.yaml -kubectl --kubeconfig="$KUBECONFIG" apply -f manifests/examples/example-app/example-app.yaml -kubectl --kubeconfig="$KUBECONFIG" create -f manifests/examples/example-app/prometheus-frontend.yaml -kubectl --kubeconfig="$KUBECONFIG" create -f manifests/examples/example-app/servicemonitor-frontend.yaml +if [ -z "${NAMESPACE}" ]; then + NAMESPACE=default +fi + +kubectl --namespace "$NAMESPACE" --kubeconfig="$KUBECONFIG" apply -f manifests/examples/example-app/prometheus-frontend-svc.yaml +kubectl --namespace "$NAMESPACE" --kubeconfig="$KUBECONFIG" apply -f manifests/examples/example-app/example-app.yaml + +# `kubectl apply` is currently not working for third party resources so we are +# using `kubectl create` here for the time being. +# (https://github.com/kubernetes/kubernetes/issues/29542) +kubectl --namespace "$NAMESPACE" --kubeconfig="$KUBECONFIG" create -f manifests/examples/example-app/prometheus-frontend.yaml +kubectl --namespace "$NAMESPACE" --kubeconfig="$KUBECONFIG" create -f manifests/examples/example-app/servicemonitor-frontend.yaml diff --git a/hack/example-service-monitoring/teardown b/hack/example-service-monitoring/teardown index a7362eabcd4493c9dde8c958742b638efcf05f18..a631fe3e239e2fa9a9172b2aa5162949b130a487 100755 --- a/hack/example-service-monitoring/teardown +++ b/hack/example-service-monitoring/teardown @@ -4,5 +4,9 @@ if [ -z "${KUBECONFIG}" ]; then KUBECONFIG=~/.kube/config fi -kubectl --kubeconfig="$KUBECONFIG" delete -f manifests/examples/example-app +if [ -z "${NAMESPACE}" ]; then + NAMESPACE=default +fi + +kubectl --namespace "$NAMESPACE" --kubeconfig="$KUBECONFIG" delete -f manifests/examples/example-app