Skip to content

Commit

Permalink
Organize in different namespaces (#119)
Browse files Browse the repository at this point in the history
Closes #117.
  • Loading branch information
trstringer authored Mar 11, 2024
1 parent 58278db commit a48e506
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 15 deletions.
29 changes: 20 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 \
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/otel-shopping-cart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ interrupter:
pullPolicy: Always
replicas: 1

otelReceiver: otel-collector-collector
otelReceiver: otel-collector-collector.observability.svc
3 changes: 1 addition & 2 deletions scripts/jaeger_install.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/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
echo "Waiting for jaeger operator to come up..."
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
1 change: 1 addition & 0 deletions scripts/kube-prometheus-stack_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
8 changes: 5 additions & 3 deletions scripts/opentelemetry_operator_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if ! helm repo list | grep promethues-community; then
fi

helm upgrade \
-n observability \
--install \
otel-operator \
open-telemetry/opentelemetry-operator
Expand All @@ -29,6 +30,7 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: otelcol
namespace: observability
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand All @@ -50,7 +52,7 @@ metadata:
subjects:
- kind: ServiceAccount
name: otelcol
namespace: default
namespace: observability
roleRef:
kind: ClusterRole
name: opentelemetry-targetallocator-cr-role
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a48e506

Please sign in to comment.