diff --git a/deploy b/deploy index 68d3b5c..570bd0c 100755 --- a/deploy +++ b/deploy @@ -60,10 +60,9 @@ echo -e "${BLUE}Creating ${ORANGE}${NAMESPACE} ${BLUE}namespace." kubectl create namespace "$NAMESPACE" #Set namespace in various resources -sed -i -e 's,CUSTOM_NAMESPACE,'"$NAMESPACE"',g' manifests/kube-state-metrics/kube-state-metrics-rbac.yaml -sed -i -e 's,CUSTOM_NAMESPACE,'"$NAMESPACE"',g' manifests/prometheus/prometheus-k8s-rbac.yaml -sed -i -e 's,CUSTOM_NAMESPACE,'"$NAMESPACE"',g' manifests/prometheus/prometheus-k8s.yaml -sed -i -e 's,CUSTOM_NAMESPACE,'"$NAMESPACE"',g' manifests/prometheus-operator/prometheus-operator-cluster-role-binding.yaml +for n in $(egrep -lir --include=*.{yaml,sh} "CUSTOM_NAMESPACE" .); do + sed -i -e 's,CUSTOM_NAMESPACE,'"$NAMESPACE"',g' $n +done kctl() { kubectl --namespace "$NAMESPACE" "$@" diff --git a/manifests/grafana/grafana-datasources.cm.yaml b/manifests/grafana/grafana-datasources.cm.yaml index a0c03d7..6d8bcf5 100644 --- a/manifests/grafana/grafana-datasources.cm.yaml +++ b/manifests/grafana/grafana-datasources.cm.yaml @@ -13,7 +13,7 @@ data: "name": "prometheus", "orgId": 1, "type": "prometheus", - "url": "http://prometheus-k8s.monitoring.svc:9090", + "url": "http://prometheus-k8s.CUSTOM_NAMESPACE.svc:9090", "version": 1 } ] diff --git a/manifests/prometheus/prometheus-k8s-service-monitor-alertmanager.yaml b/manifests/prometheus/prometheus-k8s-service-monitor-alertmanager.yaml index 19669e3..a3724e3 100644 --- a/manifests/prometheus/prometheus-k8s-service-monitor-alertmanager.yaml +++ b/manifests/prometheus/prometheus-k8s-service-monitor-alertmanager.yaml @@ -10,7 +10,7 @@ spec: alertmanager: main namespaceSelector: matchNames: - - monitoring + - CUSTOM_NAMESPACE endpoints: - port: web interval: 30s diff --git a/manifests/prometheus/prometheus-k8s-service-monitor-kube-state-metrics.yaml b/manifests/prometheus/prometheus-k8s-service-monitor-kube-state-metrics.yaml index 6563a4d..baedf7e 100644 --- a/manifests/prometheus/prometheus-k8s-service-monitor-kube-state-metrics.yaml +++ b/manifests/prometheus/prometheus-k8s-service-monitor-kube-state-metrics.yaml @@ -11,7 +11,7 @@ spec: k8s-app: kube-state-metrics namespaceSelector: matchNames: - - monitoring + - CUSTOM_NAMESPACE endpoints: - port: http-metrics interval: 30s diff --git a/manifests/prometheus/prometheus-k8s-service-monitor-node-exporter.yaml b/manifests/prometheus/prometheus-k8s-service-monitor-node-exporter.yaml index e1b083b..555565a 100644 --- a/manifests/prometheus/prometheus-k8s-service-monitor-node-exporter.yaml +++ b/manifests/prometheus/prometheus-k8s-service-monitor-node-exporter.yaml @@ -11,7 +11,7 @@ spec: k8s-app: node-exporter namespaceSelector: matchNames: - - monitoring + - CUSTOM_NAMESPACE endpoints: - port: http-metrics interval: 30s diff --git a/manifests/prometheus/prometheus-k8s-service-monitor-prometheus.yaml b/manifests/prometheus/prometheus-k8s-service-monitor-prometheus.yaml index c3d11e5..200a7f0 100644 --- a/manifests/prometheus/prometheus-k8s-service-monitor-prometheus.yaml +++ b/manifests/prometheus/prometheus-k8s-service-monitor-prometheus.yaml @@ -10,7 +10,7 @@ spec: prometheus: k8s namespaceSelector: matchNames: - - monitoring + - CUSTOM_NAMESPACE endpoints: - port: web interval: 30s diff --git a/manifests/prometheus/self-hosted/prometheus-k8s-service-monitor-apiserver.yaml b/manifests/prometheus/self-hosted/prometheus-k8s-service-monitor-apiserver.yaml index afd574b..40361f0 100644 --- a/manifests/prometheus/self-hosted/prometheus-k8s-service-monitor-apiserver.yaml +++ b/manifests/prometheus/self-hosted/prometheus-k8s-service-monitor-apiserver.yaml @@ -12,7 +12,7 @@ spec: provider: kubernetes namespaceSelector: matchNames: - - kube-system + - default endpoints: - port: https interval: 30s diff --git a/teardown b/teardown index 7cb2e48..47ff4a7 100755 --- a/teardown +++ b/teardown @@ -20,10 +20,9 @@ kctl() { } #Set namespace in various resources -sed -i -e 's,CUSTOM_NAMESPACE,'"$NAMESPACE"',g' manifests/kube-state-metrics/kube-state-metrics-rbac.yaml -sed -i -e 's,CUSTOM_NAMESPACE,'"$NAMESPACE"',g' manifests/prometheus/prometheus-k8s-rbac.yaml -sed -i -e 's,CUSTOM_NAMESPACE,'"$NAMESPACE"',g' manifests/prometheus/prometheus-k8s.yaml -sed -i -e 's,CUSTOM_NAMESPACE,'"$NAMESPACE"',g' manifests/prometheus-operator/prometheus-operator-cluster-role-binding.yaml +for n in $(egrep -lir --include=*.{yaml,sh} "CUSTOM_NAMESPACE" .); do + sed -i -e 's,CUSTOM_NAMESPACE,'"$NAMESPACE"',g' $n +done kctl delete -f manifests/node-exporter kctl delete -f manifests/kube-state-metrics