From 3dff75b8f148d7c65f3c63705febc01fecf99eb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Mon, 12 Dec 2022 06:58:36 +0100 Subject: [PATCH] feat: add dev config with support for prom loki and tempo (#5647) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché Signed-off-by: Charles-Edouard Brétéché --- Makefile | 68 ++++++++++++++----- .../dev}/kube-prometheus-stack.yaml | 31 ++------- scripts/config/dev/kyverno-policies.yaml | 1 + scripts/config/dev/kyverno.yaml | 24 +++++++ scripts/config/dev/loki-stack.yaml | 2 + scripts/config/dev/metrics-server.yaml | 5 ++ scripts/config/dev/tempo-datasource.yaml | 17 +++++ scripts/config/dev/tempo.yaml | 2 + scripts/{ => config}/kind.yaml | 0 scripts/config/standard/kyverno-policies.yaml | 1 + scripts/{ => config/standard}/kyverno.yaml | 5 +- scripts/config/standard/policy-reporter.yaml | 5 ++ 12 files changed, 113 insertions(+), 48 deletions(-) rename scripts/{ => config/dev}/kube-prometheus-stack.yaml (64%) create mode 100644 scripts/config/dev/kyverno-policies.yaml create mode 100644 scripts/config/dev/kyverno.yaml create mode 100644 scripts/config/dev/loki-stack.yaml create mode 100644 scripts/config/dev/metrics-server.yaml create mode 100644 scripts/config/dev/tempo-datasource.yaml create mode 100644 scripts/config/dev/tempo.yaml rename scripts/{ => config}/kind.yaml (100%) create mode 100644 scripts/config/standard/kyverno-policies.yaml rename scripts/{ => config/standard}/kyverno.yaml (77%) create mode 100644 scripts/config/standard/policy-reporter.yaml diff --git a/Makefile b/Makefile index af7d0cbe21..8371084ba3 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,7 @@ REPO_KYVERNOPRE := $(REGISTRY)/$(REPO)/$(KYVERNOPRE_IMAGE) REPO_KYVERNO := $(REGISTRY)/$(REPO)/$(KYVERNO_IMAGE) REPO_CLI := $(REGISTRY)/$(REPO)/$(CLI_IMAGE) REPO_CLEANUP := $(REGISTRY)/$(REPO)/$(KYVERNO_CLEANUP) +USE_CONFIG ?= standard ######### # TOOLS # @@ -697,7 +698,7 @@ test-perf: $(PACKAGE_SHIM) .PHONY: kind-create-cluster kind-create-cluster: $(KIND) ## Create kind cluster @echo Create kind cluster... >&2 - @$(KIND) create cluster --name $(KIND_NAME) --image $(KIND_IMAGE) --config ./scripts/kind.yaml + @$(KIND) create cluster --name $(KIND_NAME) --image $(KIND_IMAGE) --config ./scripts/config/kind.yaml .PHONY: kind-delete-cluster kind-delete-cluster: $(KIND) ## Delete kind cluster @@ -725,45 +726,76 @@ kind-load-all: kind-load-kyvernopre kind-load-kyverno kind-load-cleanup-controll .PHONY: kind-deploy-kyverno kind-deploy-kyverno: $(HELM) kind-load-all ## Build images, load them in kind cluster and deploy kyverno helm chart @echo Install kyverno chart... >&2 - @$(HELM) upgrade --install kyverno --namespace kyverno --wait --create-namespace ./charts/kyverno \ + @$(HELM) upgrade --install kyverno --namespace kyverno --create-namespace --wait ./charts/kyverno \ --set cleanupController.image.repository=$(LOCAL_CLEANUP_IMAGE) \ --set cleanupController.image.tag=$(IMAGE_TAG_DEV) \ --set image.repository=$(LOCAL_KYVERNO_IMAGE) \ --set image.tag=$(IMAGE_TAG_DEV) \ --set initImage.repository=$(LOCAL_KYVERNOPRE_IMAGE) \ --set initImage.tag=$(IMAGE_TAG_DEV) \ - --values ./scripts/kyverno.yaml + --values ./scripts/config/$(USE_CONFIG)/kyverno.yaml @echo Restart kyverno pods... >&2 @kubectl rollout restart deployment -n kyverno .PHONY: kind-deploy-kyverno-policies kind-deploy-kyverno-policies: $(HELM) ## Deploy kyverno-policies helm chart @echo Install kyverno-policies chart... >&2 - @$(HELM) upgrade --install kyverno-policies --namespace kyverno --wait --create-namespace ./charts/kyverno-policies - -.PHONY: kind-deploy-metrics-server -kind-deploy-metrics-server: $(HELM) ## Deploy metrics-server helm chart - @echo Install metrics-server chart... >&2 - @$(HELM) upgrade --install metrics-server --namespace kube-system --wait --repo https://charts.bitnami.com/bitnami metrics-server \ - --set extraArgs={--kubelet-insecure-tls=true} \ - --set apiService.create=true + @$(HELM) upgrade --install kyverno-policies --namespace kyverno --create-namespace --wait ./charts/kyverno-policies \ + --values ./scripts/config/$(USE_CONFIG)/kyverno-policies.yaml .PHONY: kind-deploy-all -kind-deploy-all: kind-deploy-metrics-server | kind-deploy-kyverno kind-deploy-kyverno-policies ## Build images, load them in kind cluster and deploy helm charts +kind-deploy-all: | kind-deploy-kyverno kind-deploy-kyverno-policies ## Build images, load them in kind cluster and deploy helm charts .PHONY: kind-deploy-reporter kind-deploy-reporter: $(HELM) ## Deploy policy-reporter helm chart @echo Install policy-reporter chart... >&2 - @$(HELM) upgrade --install policy-reporter --namespace policy-reporter --wait --repo https://kyverno.github.io/policy-reporter policy-reporter \ - --set ui.enabled=true \ - --set kyvernoPlugin.enabled=true \ - --create-namespace + @$(HELM) upgrade --install policy-reporter --namespace policy-reporter --create-namespace --wait \ + --repo https://kyverno.github.io/policy-reporter policy-reporter \ + --values ./scripts/config/standard/kyverno-reporter.yaml @kubectl port-forward -n policy-reporter services/policy-reporter-ui 8082:8080 -deploy-kube-prom-stack: $(HELM) +########### +# DEV LAB # +########### + +.PHONY: dev-lab-ingress-ngingx +dev-lab-ingress-ngingx: ## Deploy ingress-ngingx + @echo Install ingress-ngingx... >&2 + @kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml + @sleep 15 + @kubectl wait --namespace ingress-nginx --for=condition=ready pod --selector=app.kubernetes.io/component=controller --timeout=90s + +.PHONY: dev-lab-prometheus +dev-lab-prometheus: $(HELM) ## Deploy kube-prometheus-stack helm chart + @echo Install kube-prometheus-stack chart... >&2 @$(HELM) upgrade --install kube-prometheus-stack --namespace monitoring --create-namespace --wait \ --repo https://prometheus-community.github.io/helm-charts kube-prometheus-stack \ - --values ./scripts/kube-prometheus-stack.yaml + --values ./scripts/config/dev/kube-prometheus-stack.yaml + +.PHONY: dev-lab-loki +dev-lab-loki: $(HELM) ## Deploy loki-stack helm chart + @echo Install loki-stack chart... >&2 + @$(HELM) upgrade --install loki-stack --namespace monitoring --create-namespace --wait \ + --repo https://grafana.github.io/helm-charts loki-stack \ + --values ./scripts/config/dev/loki-stack.yaml + +.PHONY: dev-lab-tempo +dev-lab-tempo: $(HELM) ## Deploy tempo helm chart + @echo Install tempo chart... >&2 + @$(HELM) upgrade --install tempo --namespace monitoring --create-namespace --wait \ + --repo https://grafana.github.io/helm-charts tempo \ + --values ./scripts/config/dev/tempo.yaml + @kubectl apply -f ./scripts/config/dev/tempo-datasource.yaml + +.PHONY: dev-lab-metrics-server +dev-lab-metrics-server: $(HELM) ## Deploy metrics-server helm chart + @echo Install metrics-server chart... >&2 + @$(HELM) upgrade --install metrics-server --namespace kube-system --wait \ + --repo https://charts.bitnami.com/bitnami metrics-server \ + --values ./scripts/config/dev/metrics-server.yaml + +.PHONY: dev-lab-all +dev-lab-all: dev-lab-ingress-ngingx dev-lab-metrics-server dev-lab-prometheus dev-lab-loki dev-lab-tempo ######## # HELP # diff --git a/scripts/kube-prometheus-stack.yaml b/scripts/config/dev/kube-prometheus-stack.yaml similarity index 64% rename from scripts/kube-prometheus-stack.yaml rename to scripts/config/dev/kube-prometheus-stack.yaml index 4e8b913e6b..ff1f37f215 100644 --- a/scripts/kube-prometheus-stack.yaml +++ b/scripts/config/dev/kube-prometheus-stack.yaml @@ -2,8 +2,10 @@ kubeEtcd: service: enabled: true targetPort: 2381 + defaultRules: create: true + alertmanager: alertmanagerSpec: routePrefix: /alertmanager @@ -14,6 +16,7 @@ alertmanager: ingress: enabled: true pathType: Prefix + prometheus: prometheusSpec: externalUrl: /prometheus @@ -25,6 +28,7 @@ prometheus: ingress: enabled: true pathType: Prefix + grafana: enabled: true adminPassword: admin @@ -45,30 +49,3 @@ grafana: ingress: enabled: true path: /grafana - - -# kubectl apply -f - <