Skip to content

Commit 5d15cbf

Browse files
committed
chore: add local monitoring environment
Signed-off-by: Oliver Bähler <[email protected]>
1 parent 7110e7b commit 5d15cbf

File tree

20 files changed

+5895
-56
lines changed

20 files changed

+5895
-56
lines changed

.github/workflows/e2e-internal.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/e2e.yml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,45 @@ concurrency:
2323

2424
jobs:
2525
e2e:
26-
name: E2E Testing
26+
name: E2E Testing (CE)
2727
runs-on:
2828
labels: ubuntu-latest-8-cores
2929
steps:
3030
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
3131
with:
3232
fetch-depth: 0
33+
3334
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
3435
with:
3536
go-version-file: 'go.mod'
37+
3638
- uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4
37-
with:
38-
version: v3.14.2
39+
3940
- name: e2e
4041
run: sudo make e2e
42+
run-e2e:
43+
name: E2E Testing
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
k8s-version:
48+
- '1.30.0'
49+
- '1.31.0'
50+
- '1.32.0'
51+
- '1.33.0'
52+
runs-on:
53+
labels: ubuntu-latest-8-cores
54+
steps:
55+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
56+
with:
57+
repository: ${{ github.event.client_payload.repo }}
58+
ref: ${{ github.event.client_payload.sha }}
59+
60+
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
61+
with:
62+
go-version-file: 'go.mod'
63+
64+
- uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4
65+
66+
- name: e2e (Enterprise)
67+
run: KUBERNETES_SUPPORTED_VERSION=${{ matrix.k8s-version }} sudo make e2e

.github/workflows/lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
go-version-file: 'go.mod'
2424
- name: Generate manifests
2525
run: |
26+
make generate
2627
make manifests
2728
if [[ $(git diff --stat) != '' ]]; then
2829
echo -e '\033[0;31mManifests outdated! (Run make manifests locally and commit)\033[0m ❌'

DEVELOPMENT.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,13 @@ $ make deploy
7070
# To retrieve your laptop's IP and execute `make dev-setup` to setup dev env
7171
# For example: LAPTOP_HOST_IP=192.168.10.101 make dev-setup
7272
$ LAPTOP_HOST_IP="<YOUR_LAPTOP_IP>" make dev-setup
73+
74+
75+
# Monitoring Setup (Grafana/Prometheus/Pyroscope)
76+
$ LAPTOP_HOST_IP="<YOUR_LAPTOP_IP>" make dev-setup-monitoring
7377
```
7478

75-
### Explenation
79+
### Setup
7680

7781
We recommend to setup the development environment with the make `dev-setup` target. However here is a step by step guide to setup the development environment for understanding.
7882

Makefile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ helm-test: kind
9797
@$(KIND) delete cluster --name capsule-charts
9898

9999
helm-test-exec: ct helm-controller-version ko-build-all
100-
$(MAKE) docker-build-capsule-trace
101100
$(MAKE) e2e-load-image CLUSTER_NAME=capsule-charts IMAGE=$(CAPSULE_IMG) VERSION=v0.0.0
102-
$(MAKE) e2e-load-image CLUSTER_NAME=capsule-charts IMAGE=$(CAPSULE_IMG) VERSION=tracing
103101
@$(KUBECTL) create ns capsule-system || true
104102
@$(KUBECTL) apply --force-conflicts --server-side=true -f https://github.com/grafana/grafana-operator/releases/download/v5.18.0/crds.yaml
105103
@$(KUBECTL) apply --force-conflicts --server-side=true -f https://github.com/cert-manager/cert-manager/releases/download/v1.9.1/cert-manager.crds.yaml
@@ -160,6 +158,26 @@ dev-setup:
160158
./charts/capsule
161159
$(KUBECTL) -n capsule-system scale deployment capsule-controller-manager --replicas=0 || true
162160

161+
setup-monitoring: dev-setup-fluxcd
162+
@$(KUBECTL) kustomize --load-restrictor='LoadRestrictionsNone' hack/distro/monitoring | envsubst | kubectl apply -f -
163+
@$(KUBECTL) kustomize --load-restrictor='LoadRestrictionsNone' hack/distro/monitoring/dashboards | kubectl apply -f -
164+
@$(MAKE) wait-for-helmreleases
165+
@printf "\n\033[32mAccess Grafana:\033[0m\n\n"
166+
@printf " \033[1mkubectl port-forward svc/kube-prometheus-stack-grafana 9090:80 -n monitoring-system\033[0m\n\n"
167+
168+
dev-setup-monitoring: setup-monitoring
169+
@$(KUBECTL) kustomize --load-restrictor='LoadRestrictionsNone' hack/distro/host-proxy | envsubst | kubectl apply -f -
170+
171+
dev-setup-fluxcd:
172+
@$(KUBECTL) kustomize --load-restrictor='LoadRestrictionsNone' hack/distro/fluxcd | envsubst | kubectl apply -f -
173+
174+
wait-for-helmreleases:
175+
@ echo "Waiting for all HelmReleases to have observedGeneration >= 0..."
176+
@while [ "$$($(KUBECTL) get helmrelease -A -o jsonpath='{range .items[?(@.status.observedGeneration<0)]}{.metadata.namespace}{" "}{.metadata.name}{"\n"}{end}' | wc -l)" -ne 0 ]; do \
177+
sleep 5; \
178+
done
179+
180+
163181
####################
164182
# -- Docker
165183
####################

charts/capsule/templates/crd-lifecycle/job.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ spec:
8787
# piping stderr to stdout means kubectl's errors are surfaced
8888
# in the pod's logs.
8989
90-
kubectl apply --server-side=true --overwrite=true --force-conflicts=true -f /data/ 2>&1
90+
kubectl apply --server-side=true --overwrite=true --force-conflicts=true --field-manager='capsule/crd-lifecycle' -f /data/ 2>&1
9191
volumeMounts:
9292
{{- range $path, $_ := .Files.Glob "crds/**.yaml" }}
9393
- name: {{ $path | base | trimSuffix ".yaml" | regexFind "[^_]+$" }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
resources:
4+
- https://github.com/fluxcd/flux2/releases/download/v2.4.0/install.yaml
5+
patches:
6+
- patch: |
7+
- op: add
8+
path: /spec/template/spec/containers/0/args/-
9+
value: --no-cross-namespace-refs=true
10+
target:
11+
kind: Deployment
12+
name: "(kustomize-controller|helm-controller|notification-controller|image-reflector-controller|image-automation-controller)"
13+
- patch: |
14+
- op: add
15+
path: /spec/template/spec/containers/0/args/-
16+
value: --no-remote-bases=true
17+
target:
18+
kind: Deployment
19+
name: "kustomize-controller"
20+
- patch: |
21+
- op: add
22+
path: /spec/template/spec/containers/0/args/-
23+
value: --default-service-account=default
24+
target:
25+
kind: Deployment
26+
name: "(kustomize-controller|helm-controller)"
27+
- patch: |
28+
- op: replace
29+
path: /spec/replicas
30+
value: 0
31+
target:
32+
kind: Deployment
33+
name: "(notification-controller|image-reflector-controller|image-automation-controller)"

hack/distro/host-proxy/deploy.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: capsule
5+
namespace: monitoring-system
6+
labels:
7+
app: capsule
8+
spec:
9+
replicas: 1
10+
selector:
11+
matchLabels:
12+
app: capsule
13+
template:
14+
metadata:
15+
labels:
16+
app: capsule
17+
annotations:
18+
prometheus.io/scrape: 'true'
19+
prometheus.io/path: '/metrics'
20+
prometheus.io/port: '8080'
21+
profiles.grafana.com/memory.scrape: "true"
22+
profiles.grafana.com/memory.port: "8082"
23+
profiles.grafana.com/cpu.scrape: "true"
24+
profiles.grafana.com/cpu.port: "8082"
25+
profiles.grafana.com/goroutine.scrape: "true"
26+
profiles.grafana.com/goroutine.port: "8082"
27+
spec:
28+
containers:
29+
- name: tcp-proxy
30+
image: alpine/socat
31+
ports:
32+
- containerPort: 8080
33+
- containerPort: 8082
34+
command: ["sh", "-c"]
35+
args:
36+
- |
37+
set -e
38+
echo "Starting TCP proxy to ${LAPTOP_HOST_IP}..."
39+
# Forward 8080 -> TARGET_HOST:8080
40+
socat TCP-LISTEN:8080,fork,reuseaddr TCP:${LAPTOP_HOST_IP}:8080 &
41+
# Forward 8082 -> TARGET_HOST:8082
42+
socat TCP-LISTEN:8082,fork,reuseaddr TCP:${LAPTOP_HOST_IP}:8082 &
43+
wait
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
resources:
4+
- deploy.yaml
5+
- servicemonitor.yaml
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: capsule
6+
namespace: monitoring-system
7+
labels:
8+
app: capsule
9+
release: kube-prometheus-stack
10+
spec:
11+
selector:
12+
app: capsule
13+
ports:
14+
- name: metrics
15+
port: 8080
16+
targetPort: 8080
17+
protocol: TCP
18+
---
19+
apiVersion: monitoring.coreos.com/v1
20+
kind: ServiceMonitor
21+
metadata:
22+
name: capsule
23+
namespace: monitoring-system
24+
labels:
25+
release: kube-prometheus-stack
26+
spec:
27+
selector:
28+
matchLabels:
29+
app: capsule
30+
endpoints:
31+
- port: metrics
32+
path: /metrics
33+
interval: 5s

0 commit comments

Comments
 (0)