From a48e506165e2c2d6a92ffed448ddce5dd1f766bf Mon Sep 17 00:00:00 2001 From: Thomas Stringer Date: Mon, 11 Mar 2024 09:06:44 -0400 Subject: [PATCH] Organize in different namespaces (#119) Closes #117. --- Makefile | 29 ++++++++++++++++------- charts/otel-shopping-cart/values.yaml | 2 +- scripts/jaeger_install.sh | 3 +-- scripts/kube-prometheus-stack_install.sh | 1 + scripts/opentelemetry_operator_install.sh | 8 ++++--- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index ba88092..fa6c3ec 100644 --- a/Makefile +++ b/Makefile @@ -47,10 +47,14 @@ install-tools-and-app: install-tools install-app install-tools-and-app-local: install-tools-local install-app-local .PHONY: install-tools-local -install-tools-local: install-cert-manager install-jaeger install-kube-prometheus-stack install-opentelemetry-operator install-opentelemetry-collector-local +install-tools-local: create-namespace-observability install-cert-manager install-jaeger install-kube-prometheus-stack install-opentelemetry-operator install-opentelemetry-collector-local .PHONY: install-tools -install-tools: install-cert-manager install-jaeger install-kube-prometheus-stack install-opentelemetry-operator install-opentelemetry-collector +install-tools: create-namespace-observability install-cert-manager install-jaeger install-kube-prometheus-stack install-opentelemetry-operator install-opentelemetry-collector + +.PHONY: create-namespace-observability +create-namespace-observability: + if ! kubectl get ns observability; then kubectl create ns observability; fi .PHONY: install-cert-manager install-cert-manager: @@ -70,19 +74,26 @@ install-opentelemetry-operator: .PHONY: install-opentelemetry-collector-local install-opentelemetry-collector-local: - helm upgrade --install otel ./collector/opentelemetry + helm upgrade --install -n observability otel ./collector/opentelemetry .PHONY: install-opentelemetry-collector install-opentelemetry-collector: helm upgrade \ + -n observability \ --install \ --set collector.image.repository=ghcr.io/trstringer/otel-shopping-cart-collector \ otel \ ./collector/opentelemetry +.PHONY: create-namespace-app +create-namespace-app: + if ! kubectl get ns app; then kubectl create ns app; fi + + .PHONY: install-app -install-app: +install-app: create-namespace-app helm upgrade \ + -n app \ --install \ --set cart.image.repository=ghcr.io/trstringer/otel-shopping-cart-cart \ --set user.image.repository=ghcr.io/trstringer/otel-shopping-cart-users \ @@ -94,8 +105,8 @@ install-app: ./charts/otel-shopping-cart .PHONY: install-app-local -install-app-local: build-images push-images - helm upgrade --install otel-shopping-cart ./charts/otel-shopping-cart +install-app-local: create-namespace-app build-images push-images + helm upgrade -n app --install otel-shopping-cart ./charts/otel-shopping-cart .PHONY: build-images build-images: build-collector @@ -123,17 +134,17 @@ push-images: .PHONY: port-forward-jaeger port-forward-jaeger: - kubectl port-forward svc/jaeger-query 16686 + kubectl port-forward -n observability svc/jaeger-query 16686 @echo "Navigate to http://localhost:16686" .PHONY: port-forward-grafana port-forward-grafana: - kubectl port-forward svc/prometheus-grafana 8080:80 + kubectl port-forward -n observability svc/prometheus-grafana 8080:80 @echo "Navigate to http://localhost:8080" .PHONY: port-forward-prometheus port-forward-prometheus: - kubectl port-forward svc/prometheus-kube-prometheus-prometheus 9090 + kubectl port-forward -n observability svc/prometheus-kube-prometheus-prometheus 9090 @echo "Navigate to http://localhost:9090" .PHONY: e2e diff --git a/charts/otel-shopping-cart/values.yaml b/charts/otel-shopping-cart/values.yaml index 35b2501..4a77640 100644 --- a/charts/otel-shopping-cart/values.yaml +++ b/charts/otel-shopping-cart/values.yaml @@ -55,4 +55,4 @@ interrupter: pullPolicy: Always replicas: 1 -otelReceiver: otel-collector-collector +otelReceiver: otel-collector-collector.observability.svc diff --git a/scripts/jaeger_install.sh b/scripts/jaeger_install.sh index 8c23915..0eb8d2c 100755 --- a/scripts/jaeger_install.sh +++ b/scripts/jaeger_install.sh @@ -1,6 +1,5 @@ #!/bin/bash -kubectl create namespace observability JAEGER_OPERATOR_URI="https://github.com/jaegertracing/jaeger-operator/releases/download/v1.49.0/jaeger-operator.yaml" until kubectl create -f "$JAEGER_OPERATOR_URI" -n observability; do kubectl delete -f "$JAEGER_OPERATOR_URI" -n observability @@ -8,7 +7,7 @@ until kubectl create -f "$JAEGER_OPERATOR_URI" -n observability; do sleep 5 done -until kubectl create -f ./kubernetes/jaeger.yaml; do +until kubectl create -n observability -f ./kubernetes/jaeger.yaml; do echo "Waiting for jaeger to install successfully..." sleep 5 done diff --git a/scripts/kube-prometheus-stack_install.sh b/scripts/kube-prometheus-stack_install.sh index 2bdd301..40989df 100755 --- a/scripts/kube-prometheus-stack_install.sh +++ b/scripts/kube-prometheus-stack_install.sh @@ -6,6 +6,7 @@ if ! helm repo list | grep promethues-community; then fi helm upgrade \ + -n observability \ --install \ --set "grafana.grafana\.ini.auth\.anonymous.enabled=true" \ --set "grafana.grafana\.ini.auth\.anonymous.org_role=Editor" \ diff --git a/scripts/opentelemetry_operator_install.sh b/scripts/opentelemetry_operator_install.sh index 2c62eb9..04d744f 100755 --- a/scripts/opentelemetry_operator_install.sh +++ b/scripts/opentelemetry_operator_install.sh @@ -7,6 +7,7 @@ if ! helm repo list | grep promethues-community; then fi helm upgrade \ + -n observability \ --install \ otel-operator \ open-telemetry/opentelemetry-operator @@ -29,6 +30,7 @@ apiVersion: v1 kind: ServiceAccount metadata: name: otelcol + namespace: observability --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole @@ -50,7 +52,7 @@ metadata: subjects: - kind: ServiceAccount name: otelcol - namespace: default + namespace: observability roleRef: kind: ClusterRole name: opentelemetry-targetallocator-cr-role @@ -95,14 +97,14 @@ metadata: subjects: - kind: ServiceAccount name: otelcol - namespace: default + namespace: observability roleRef: kind: ClusterRole name: opentelemetry-targetallocator-role apiGroup: rbac.authorization.k8s.io EOF -while [[ $(kubectl get po -l app.kubernetes.io/name=opentelemetry-operator -o jsonpath='{.items[0].status.phase}') != "Running" ]]; do +while [[ $(kubectl get po -n observability -l app.kubernetes.io/name=opentelemetry-operator -o jsonpath='{.items[0].status.phase}') != "Running" ]]; do echo "Waiting for the operator to come up" sleep 5 done