From 9e319acaa91f42099d41d7a5a247df8dcad8f5b5 Mon Sep 17 00:00:00 2001 From: Frederic Branczyk <fbranczyk@gmail.com> Date: Tue, 3 Jan 2017 11:33:42 +0100 Subject: [PATCH] hack/*: use kubectl apply where possible There is an issue with kubectl apply and third party resources, so for the time being we use create for TPRs, but apply for all manifests that it can handle. --- hack/cluster-monitoring/deploy | 22 +++++++++++++++++----- hack/cluster-monitoring/teardown | 1 + hack/example-service-monitoring/deploy | 6 +++++- hack/example-service-monitoring/teardown | 3 ++- hack/scripts/generate-configmaps.sh | 1 + 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/hack/cluster-monitoring/deploy b/hack/cluster-monitoring/deploy index 25220dd8..9620872a 100755 --- a/hack/cluster-monitoring/deploy +++ b/hack/cluster-monitoring/deploy @@ -14,14 +14,26 @@ kctl() { kubectl --namespace "$NAMESPACE" "$@" } -kctl create -f manifests/prometheus-operator.yaml +kctl apply -f manifests/prometheus-operator.yaml # Wait for TPRs to be ready. until kctl get servicemonitor; do sleep 1; done until kctl get prometheus; do sleep 1; done until kctl get alertmanager; do sleep 1; done -kctl create -f manifests/exporters -kctl create -f manifests/grafana -kctl create -f manifests/prometheus -kctl create -f manifests/alertmanager +kctl apply -f manifests/exporters +kctl apply -f manifests/grafana + +kctl apply -f manifests/prometheus/prometheus-k8s-cm.yaml +kctl apply -f manifests/prometheus/prometheus-k8s-rules.yaml +kctl apply -f manifests/prometheus/prometheus-k8s-svc.yaml + +kctl apply -f manifests/alertmanager/alertmanager-config.yaml +kctl apply -f manifests/alertmanager/alertmanager-service.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) +kctl create -f manifests/prometheus/prometheus-k8s.yaml +kctl create -f manifests/alertmanager/alertmanager.yaml + diff --git a/hack/cluster-monitoring/teardown b/hack/cluster-monitoring/teardown index c8a60c9b..45ae61ed 100755 --- a/hack/cluster-monitoring/teardown +++ b/hack/cluster-monitoring/teardown @@ -21,3 +21,4 @@ kctl delete -f manifests/alertmanager sleep 5 kctl delete -f manifests/prometheus-operator.yaml + diff --git a/hack/example-service-monitoring/deploy b/hack/example-service-monitoring/deploy index 36b72754..9b359d2d 100755 --- a/hack/example-service-monitoring/deploy +++ b/hack/example-service-monitoring/deploy @@ -4,4 +4,8 @@ if [ -z "${KUBECONFIG}" ]; then KUBECONFIG=~/.kube/config fi -kubectl --kubeconfig="$KUBECONFIG" create -f manifests/examples/example-app \ No newline at end of file +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 + diff --git a/hack/example-service-monitoring/teardown b/hack/example-service-monitoring/teardown index 448ff8a8..a7362eab 100755 --- a/hack/example-service-monitoring/teardown +++ b/hack/example-service-monitoring/teardown @@ -4,4 +4,5 @@ if [ -z "${KUBECONFIG}" ]; then KUBECONFIG=~/.kube/config fi -kubectl --kubeconfig="$KUBECONFIG" delete -f manifests/examples/example-app \ No newline at end of file +kubectl --kubeconfig="$KUBECONFIG" delete -f manifests/examples/example-app + diff --git a/hack/scripts/generate-configmaps.sh b/hack/scripts/generate-configmaps.sh index 50f3c903..6fb7b6e3 100755 --- a/hack/scripts/generate-configmaps.sh +++ b/hack/scripts/generate-configmaps.sh @@ -8,3 +8,4 @@ kubectl create configmap --dry-run=true prometheus-k8s-rules --from-file=assets/ # Generate Dashboard ConfigMap kubectl create configmap --dry-run=true grafana-dashboards --from-file=assets/grafana/ -oyaml > manifests/grafana/grafana-cm.yaml + -- GitLab