Skip to content

Commit

Permalink
fix: seperated app, observability and otel in correct namespaces (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
mati007thm authored Jan 12, 2024
1 parent b1e3869 commit 852f37b
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 46 deletions.
1 change: 0 additions & 1 deletion dapr-distributed-calendar/go/go_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ func deleteEvent(w http.ResponseWriter, r *http.Request) {
}

deleteURL := stateURL + "/" + eventID.ID
log.Printf("Delete URL: %s", deleteURL)

req, err := http.NewRequest(http.MethodDelete, deleteURL, nil)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions dapr-distributed-calendar/jaeger/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: jaeger-ingress
namespace: observability
spec:
entryPoints:
- web
Expand Down
3 changes: 2 additions & 1 deletion dapr-distributed-calendar/jaeger/simplest.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apiVersion: jaegertracing.io/v1
kind: Jaeger
metadata:
name: simplest
name: simplest
namespace: observability
12 changes: 7 additions & 5 deletions dapr-distributed-calendar/kubernetes-deploy.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#!/bin/sh

# create namespace
# kubectl create namespace 12-factor-app
# create 12-factor-app namespace
kubectl create namespace 12-factor-app

# install OTel Operator
kubectl create namespace opentelemetry
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
helm repo update
helm install my-opentelemetry-operator open-telemetry/opentelemetry-operator \
--set admissionWebhooks.certManager.enabled=false \
--set admissionWebhooks.certManager.autoGenerateCert.enabled=true \
--set manager.featureGates='operator.autoinstrumentation.go' \
--namespace opentelemetry \
--wait

# create OTel collector and instrumentation
Expand Down Expand Up @@ -37,7 +39,7 @@ helm repo add prometheus-community https://prometheus-community.github.io/helm-c
helm repo update
helm install prometheus prometheus-community/kube-prometheus-stack \
--version 51.3.0 \
--namespace default \
--namespace observability \
--values prometheus/kube-prometheus-stack-values.yaml \
--wait
kubectl apply -f ./prometheus/ingress.yaml
Expand Down Expand Up @@ -67,10 +69,10 @@ helm install dapr-dashboard dapr/dapr-dashboard --namespace dapr-system --wait
# install redis
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
helm install redis bitnami/redis --wait
helm install redis bitnami/redis --namespace 12-factor-app --wait

# deploy the 12-factor-app
kubectl apply -f kubernetes/.

# get redis password (for manual interactions with the redis cli) OPTIONAL
kubectl get secret redis -o jsonpath='{.data.redis-password}' | base64 --decode
kubectl get secret redis -n 12-factor-app -o jsonpath='{.data.redis-password}' | base64 --decode
4 changes: 2 additions & 2 deletions dapr-distributed-calendar/kubernetes/appconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
# namespace: 12-factor-app
namespace: 12-factor-app
spec:
tracing:
samplingRate: "1"
stdout: true
otel:
endpointAddress: otel-dapr-collector:4317
endpointAddress: otel-dapr-collector.opentelemetry:4317
isSecure: false
protocol: grpc
4 changes: 2 additions & 2 deletions dapr-distributed-calendar/kubernetes/go-events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: go-events
# namespace: 12-factor-app
namespace: 12-factor-app
labels:
app: go-events
spec:
Expand Down Expand Up @@ -35,7 +35,7 @@ spec:
- name: DAPR_HTTP_PORT
value: "3500"
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: "http://otel-dapr-collector:4317"
value: "http://otel-dapr-collector.opentelemetry:4317"
ports:
- containerPort: 6000
imagePullPolicy: Always
Expand Down
2 changes: 1 addition & 1 deletion dapr-distributed-calendar/kubernetes/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: controller-ingress
# namespace: 12-factor-app
namespace: 12-factor-app
spec:
entryPoints:
- web
Expand Down
4 changes: 2 additions & 2 deletions dapr-distributed-calendar/kubernetes/node-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: controller
# namespace: 12-factor-app
namespace: 12-factor-app
labels:
app: controller
spec:
Expand Down Expand Up @@ -48,7 +48,7 @@ spec:
- name: APP_PORT
value: "3000"
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: "http://otel-dapr-collector:4317"
value: "http://otel-dapr-collector.opentelemetry:4317"
ports:
- containerPort: 3000
imagePullPolicy: Always
5 changes: 2 additions & 3 deletions dapr-distributed-calendar/kubernetes/python-messages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: messages
# namespace: 12-factor-app
namespace: 12-factor-app
labels:
app: messages
spec:
Expand All @@ -28,14 +28,13 @@ spec:
containers:
- name: messages
image: mati007thm/dapr-distributed-calendar_messages:manual
# image: mati007thm/dapr-distributed-calendar_messages:woOtel
env:
- name: "APP_PORT"
value: "5000"
- name: FLASK_RUN_PORT
value: "5000"
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: "http://otel-dapr-collector:4317"
value: "http://otel-dapr-collector.opentelemetry:4317"
ports:
- containerPort: 5000
imagePullPolicy: Always
4 changes: 2 additions & 2 deletions dapr-distributed-calendar/kubernetes/redis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: events
# namespace: 12-factor-app
namespace: 12-factor-app
spec:
type: state.redis
version: v1
Expand All @@ -21,7 +21,7 @@ apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: pubsub
# namespace: 12-factor-app
namespace: 12-factor-app
spec:
type: pubsub.redis
version: v1
Expand Down
2 changes: 1 addition & 1 deletion dapr-distributed-calendar/kubernetes/resiliency.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: dapr.io/v1alpha1
kind: Resiliency
metadata:
name: myresiliency
# namespace: 12-factor-app
namespace: 12-factor-app
# similar to subscription and configuration specs, scopes lists the Dapr App IDs that this
# resiliency spec can be used by.
scopes:
Expand Down
46 changes: 23 additions & 23 deletions dapr-distributed-calendar/kubernetes/secreats.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# ---
# apiVersion: rbac.authorization.k8s.io/v1
# kind: Role
# metadata:
# name: secret-reader
# namespace: 12-factor-app
# rules:
# - apiGroups: [""]
# resources: ["secrets"]
# verbs: ["get", "list"]
# ---
# kind: RoleBinding
# apiVersion: rbac.authorization.k8s.io/v1
# metadata:
# name: dapr-secret-reader
# namespace: 12-factor-app
# subjects:
# - kind: ServiceAccount
# name: default
# roleRef:
# kind: Role
# name: secret-reader
# apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: secret-reader
namespace: 12-factor-app
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "list"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: dapr-secret-reader
namespace: 12-factor-app
subjects:
- kind: ServiceAccount
name: default
roleRef:
kind: Role
name: secret-reader
apiGroup: rbac.authorization.k8s.io
5 changes: 3 additions & 2 deletions dapr-distributed-calendar/otel/otel-collector-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
name: otel-dapr
namespace: opentelemetry
annotations:
dapr_collector_demo: "true"
spec:
Expand All @@ -17,7 +18,7 @@ spec:
- job_name: otel-collector
scrape_interval: 5s
static_configs:
- targets: [controller-dapr:9090, messages-dapr:9090, go-events-dapr:9090]
- targets: [controller-dapr.12-factor-app:9090, messages-dapr.12-factor-app:9090, go-events-dapr.12-factor-app:9090]
processors:
memory_limiter:
Expand All @@ -33,7 +34,7 @@ spec:
debug:
verbosity: detailed
otlp/jaeger:
endpoint: simplest-collector:4317
endpoint: simplest-collector.observability:4317
tls:
insecure: true
prometheus:
Expand Down
1 change: 1 addition & 0 deletions dapr-distributed-calendar/prometheus/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: prometheus-ingress
namespace: observability
spec:
entryPoints:
- web
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ prometheus:
- role: pod
namespaces:
own_namespace: true
# names: [12-factor-app]
names: [opentelemetry]
relabel_configs:
- source_labels: [__meta_kubernetes_pod_annotation_dapr_collector_demo]
action: keep
Expand Down

0 comments on commit 852f37b

Please sign in to comment.