Skip to content

Commit 17ec06c

Browse files
authored
Add prometheus metics component and overlay (#8)
* Refactor base install components into "core" kustomize component * Add metrics kustomize component which installs prometheus operator, server and configures Kafka metrics and console * Add core and metrics overlays * Update install/uninstall scripts and README with new layout and overlay options (via OVERLAY env var) * Add metrics overlay to smoke tests * Increase timeout for verify scripts * Make the wait condition for the verify scripts an optional argument Signed-off-by: Thomas Cooper <code@tomcooper.dev>
1 parent 184f6bf commit 17ec06c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+640
-84
lines changed

.github/actions/smoke-test/action.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ inputs:
99
overlay:
1010
description: 'Overlay name for component verification (matches .github/config/overlays/<name>.env)'
1111
required: false
12-
default: 'base'
12+
default: 'core'
1313

1414
runs:
1515
using: 'composite'
@@ -18,24 +18,29 @@ runs:
1818
shell: bash
1919
env:
2020
LOCAL_DIR: .
21+
OVERLAY: ${{ inputs.overlay }}
2122
TIMEOUT: ${{ inputs.timeout }}
2223
run: ./install.sh
2324

2425
- name: Verify deployments
2526
shell: bash
2627
env:
2728
OVERLAY: ${{ inputs.overlay }}
29+
TIMEOUT: ${{ inputs.timeout }}
2830
run: .github/scripts/verify-install.sh
2931

3032
- name: Run uninstall script
3133
shell: bash
3234
env:
3335
LOCAL_DIR: .
36+
OVERLAY: ${{ inputs.overlay }}
3437
TIMEOUT: ${{ inputs.timeout }}
3538
run: ./uninstall.sh
3639

3740
- name: Verify uninstall
3841
shell: bash
42+
env:
43+
TIMEOUT: ${{ inputs.timeout }}
3944
run: .github/scripts/verify-uninstall.sh
4045

4146
- name: Debug on failure
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Components expected in the base (default) deployment.
2-
# Used by verify-install.sh, verify-uninstall.sh, and debug.sh.
1+
# Components expected in the core (default) deployment.
2+
# Used by verify-install.sh and debug.sh.
33
#
44
# Format:
55
# OPERATORS - "namespace:deployment" pairs (space-separated)
6-
# CUSTOM_RESOURCES - "namespace:resource" pairs (space-separated)
6+
# CUSTOM_RESOURCES - "namespace:resource[:condition]" pairs (space-separated, condition defaults to Ready)
77
# NAMESPACES - namespaces to inspect on failure (space-separated)
88

99
OPERATORS="strimzi:strimzi-cluster-operator apicurio-registry:apicurio-registry-operator streamshub-console:streamshub-console-operator"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Components expected in the metrics overlay deployment.
2+
# Used by verify-install.sh and debug.sh.
3+
#
4+
# Format:
5+
# OPERATORS - "namespace:deployment" pairs (space-separated)
6+
# CUSTOM_RESOURCES - "namespace:resource[:condition]" pairs (space-separated, condition defaults to Ready)
7+
# NAMESPACES - namespaces to inspect on failure (space-separated)
8+
9+
OPERATORS="strimzi:strimzi-cluster-operator apicurio-registry:apicurio-registry-operator streamshub-console:streamshub-console-operator monitoring:prometheus-operator"
10+
CUSTOM_RESOURCES="kafka:kafka/dev-cluster apicurio-registry:apicurioregistry3/apicurio-registry streamshub-console:console.console.streamshub.github.com/streamshub-console monitoring:prometheus.monitoring.coreos.com/prometheus:Available"
11+
NAMESPACES="strimzi kafka apicurio-registry streamshub-console monitoring"

.github/scripts/debug.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
# Reads component definitions from an overlay config file.
55
#
66
# Environment variables:
7-
# OVERLAY - overlay name (default: "base")
7+
# OVERLAY - overlay name (default: "core")
88
#
99

1010
set +e
1111

12-
OVERLAY="${OVERLAY:-base}"
12+
OVERLAY="${OVERLAY:-core}"
1313
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
1414
CONFIG_FILE="${SCRIPT_DIR}/../config/overlays/${OVERLAY}.env"
1515

.github/scripts/verify-install.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
# Reads component definitions from an overlay config file.
55
#
66
# Environment variables:
7-
# OVERLAY - overlay name (default: "base")
7+
# OVERLAY - overlay name (default: "core")
88
# TIMEOUT - kubectl wait timeout (default: "600s")
99
#
1010

1111
set -euo pipefail
1212

13-
OVERLAY="${OVERLAY:-base}"
13+
OVERLAY="${OVERLAY:-core}"
1414
TIMEOUT="${TIMEOUT:-600s}"
1515
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
1616
CONFIG_FILE="${SCRIPT_DIR}/../config/overlays/${OVERLAY}.env"
@@ -37,7 +37,13 @@ echo ""
3737

3838
for entry in ${CUSTOM_RESOURCES}; do
3939
ns="${entry%%:*}"
40-
resource="${entry#*:}"
40+
rest="${entry#*:}"
41+
resource="${rest%:*}"
42+
if [ "${rest}" != "${resource}" ]; then
43+
condition="${rest##*:}"
44+
else
45+
condition="Ready"
46+
fi
4147
echo "--- ${resource} (${ns}) ---"
42-
kubectl wait "${resource}" --for=condition=Ready -n "${ns}" --timeout="${TIMEOUT}"
48+
kubectl wait "${resource}" --for=condition="${condition}" -n "${ns}" --timeout="${TIMEOUT}"
4349
done

.github/workflows/integration.yaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ on:
88

99
jobs:
1010
smoke-minikube:
11-
name: smoke-minikube
11+
name: smoke-minikube (${{ matrix.overlay }})
1212
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
overlay: [core, metrics]
1317
steps:
1418
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1519

@@ -24,10 +28,17 @@ jobs:
2428

2529
- name: Smoke test
2630
uses: ./.github/actions/smoke-test
31+
with:
32+
timeout: 300s
33+
overlay: ${{ matrix.overlay }}
2734

2835
smoke-kind:
29-
name: smoke-kind
36+
name: smoke-kind (${{ matrix.overlay }})
3037
runs-on: ubuntu-latest
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
overlay: [core, metrics]
3142
steps:
3243
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3344

@@ -46,3 +57,6 @@ jobs:
4657
4758
- name: Smoke test
4859
uses: ./.github/actions/smoke-test
60+
with:
61+
timeout: 300s
62+
overlay: ${{ matrix.overlay }}

.github/workflows/validate.yaml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,33 @@ jobs:
1616
- name: Set up kubectl
1717
uses: azure/setup-kubectl@776406bce94f63e41d621b960d78ee25c8b76ede # v4.0.1
1818

19-
- name: Build base layer
20-
run: kubectl kustomize base/
19+
- name: Build core overlay base
20+
run: kubectl kustomize overlays/core/base/
2121

22-
- name: Build stack layer
23-
run: kubectl kustomize stack/
22+
- name: Build core overlay stack
23+
run: kubectl kustomize overlays/core/stack/
2424

25-
- name: Verify quick-start labels in base
25+
- name: Build metrics overlay base
26+
run: kubectl kustomize overlays/metrics/base/
27+
28+
- name: Build metrics overlay stack
29+
run: kubectl kustomize overlays/metrics/stack/
30+
31+
- name: Verify quick-start labels in core overlay base
32+
run: |
33+
kubectl kustomize overlays/core/base/ | grep -q 'app.kubernetes.io/part-of: streamshub-developer-quickstart'
34+
35+
- name: Verify quick-start labels in core overlay stack
36+
run: |
37+
kubectl kustomize overlays/core/stack/ | grep -q 'app.kubernetes.io/part-of: streamshub-developer-quickstart'
38+
39+
- name: Verify quick-start labels in metrics overlay base
2640
run: |
27-
kubectl kustomize base/ | grep -q 'app.kubernetes.io/part-of: streamshub-developer-quickstart'
41+
kubectl kustomize overlays/metrics/base/ | grep -q 'app.kubernetes.io/part-of: streamshub-developer-quickstart'
2842
29-
- name: Verify quick-start labels in stack
43+
- name: Verify quick-start labels in metrics overlay stack
3044
run: |
31-
kubectl kustomize stack/ | grep -q 'app.kubernetes.io/part-of: streamshub-developer-quickstart'
45+
kubectl kustomize overlays/metrics/stack/ | grep -q 'app.kubernetes.io/part-of: streamshub-developer-quickstart'
3246
3347
shellcheck:
3448
name: Lint shell scripts

README.md

Lines changed: 60 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ A Kustomize-based repository for deploying the StreamsHub event-streaming stack
1515
| StreamsHub Console Operator | `streamshub-console` | Manages console instances |
1616
| StreamsHub Console instance | `streamshub-console` | Web UI for Kafka management |
1717

18+
> **Optional:** The [metrics overlay](#install-with-metrics) adds Prometheus Operator, a Prometheus instance, and Kafka metrics collection via PodMonitors.
19+
1820
## Prerequisites
1921

2022
- `kubectl` v1.27 or later (for Kustomize v5.0 `labels` transformer support)
@@ -39,6 +41,7 @@ The install script accepts the following environment variables:
3941
|----------|---------|-------------|
4042
| `REPO` | `streamshub/developer-quickstart` | GitHub repository path |
4143
| `REF` | `main` | Git ref, branch, or tag |
44+
| `OVERLAY` | *(empty)* | Overlay to apply (e.g. `metrics`) |
4245
| `TIMEOUT` | `120s` | `kubectl wait` timeout |
4346

4447
Example with a pinned version:
@@ -47,14 +50,24 @@ Example with a pinned version:
4750
curl -sL https://raw.githubusercontent.com/streamshub/developer-quickstart/main/install.sh | REF=v1.0.0 bash
4851
```
4952

53+
### Install with Metrics
54+
55+
Deploy the stack with Prometheus metrics collection:
56+
57+
```shell
58+
curl -sL https://raw.githubusercontent.com/streamshub/developer-quickstart/main/install.sh | OVERLAY=metrics bash
59+
```
60+
61+
This adds the Prometheus Operator and a Prometheus instance (namespace: `monitoring`), enables Kafka metrics via [Strimzi Metrics Reporter](https://strimzi.io/docs/operators/latest/deploying#proc-metrics-kafka-str), and wires Console to display metrics.
62+
5063
## Manual Install
5164

5265
If you prefer to control each step, the stack is installed in two phases:
5366

5467
### Phase 1 — Operators and CRDs
5568

5669
```shell
57-
kubectl apply -k 'https://github.com/streamshub/developer-quickstart//base?ref=main'
70+
kubectl apply -k 'https://github.com/streamshub/developer-quickstart//overlays/core/base?ref=main'
5871
```
5972

6073
Wait for the operators to become ready:
@@ -68,7 +81,23 @@ kubectl wait --for=condition=Available deployment/streamshub-console-operator -n
6881
### Phase 2 — Operands
6982

7083
```shell
71-
kubectl apply -k 'https://github.com/streamshub/developer-quickstart//stack?ref=main'
84+
kubectl apply -k 'https://github.com/streamshub/developer-quickstart//overlays/core/stack?ref=main'
85+
```
86+
87+
### Manual Install with Metrics
88+
89+
To include the metrics overlay, use the `overlays/metrics` paths instead of `overlays/core`.
90+
91+
```shell
92+
# Phase 1
93+
kubectl create -k 'https://github.com/streamshub/developer-quickstart//overlays/metrics/base?ref=main'
94+
kubectl wait --for=condition=Available deployment/prometheus-operator -n monitoring --timeout=120s
95+
kubectl wait --for=condition=Available deployment/strimzi-cluster-operator -n strimzi --timeout=120s
96+
kubectl wait --for=condition=Available deployment/apicurio-registry-operator -n apicurio-registry --timeout=120s
97+
kubectl wait --for=condition=Available deployment/streamshub-console-operator -n streamshub-console --timeout=120s
98+
99+
# Phase 2
100+
kubectl apply -k 'https://github.com/streamshub/developer-quickstart//overlays/metrics/stack?ref=main'
72101
```
73102

74103
## Accessing the Console
@@ -142,6 +171,9 @@ The uninstall script handles safe teardown with shared-cluster safety checks:
142171

143172
```shell
144173
curl -sL https://raw.githubusercontent.com/streamshub/developer-quickstart/main/uninstall.sh | bash
174+
175+
# If installed with the metrics overlay:
176+
curl -sL https://raw.githubusercontent.com/streamshub/developer-quickstart/main/uninstall.sh | OVERLAY=metrics bash
145177
```
146178

147179
The script:
@@ -156,7 +188,7 @@ The script:
156188
**Phase 1 — Delete operands:**
157189

158190
```shell
159-
kubectl delete -k 'https://github.com/streamshub/developer-quickstart//stack?ref=main'
191+
kubectl delete -k 'https://github.com/streamshub/developer-quickstart//overlays/core/stack?ref=main'
160192
```
161193

162194
Wait for all custom resources to be fully removed before proceeding.
@@ -169,9 +201,11 @@ Wait for all custom resources to be fully removed before proceeding.
169201
> ```
170202
171203
```shell
172-
kubectl delete -k 'https://github.com/streamshub/developer-quickstart//base?ref=main'
204+
kubectl delete -k 'https://github.com/streamshub/developer-quickstart//overlays/core/base?ref=main'
173205
```
174206
207+
For the metrics overlay, use `overlays/metrics/base` and `overlays/metrics/stack` instead.
208+
175209
### Finding Quick-Start Resources
176210

177211
All resources carry the label `app.kubernetes.io/part-of=streamshub-developer-quickstart`:
@@ -201,7 +235,7 @@ Use the `update-version.sh` script to update component versions:
201235
./update-version.sh strimzi 0.52.0
202236
```
203237

204-
Supported components: `strimzi`, `apicurio-registry`, `streamshub-console`
238+
Supported components: `strimzi`, `apicurio-registry`, `streamshub-console`, `prometheus-operator`
205239

206240
### Testing scripts locally
207241

@@ -229,17 +263,25 @@ LOCAL_DIR=/home/user/repos/developer-quickstart ./install.sh
229263
## Repository Structure
230264

231265
```
232-
base/ # Phase 1: Operators & CRDs
233-
├── kustomization.yaml # Composes all operator sub-components
234-
├── strimzi-operator/ # Strimzi Kafka Operator
235-
├── apicurio-registry-operator/ # Apicurio Registry Operator
236-
└── streamshub-console-operator/ # StreamsHub Console Operator
237-
238-
stack/ # Phase 2: Operands (Custom Resources)
239-
├── kustomization.yaml # Composes all operand sub-components
240-
├── kafka/ # Single-node Kafka cluster
241-
├── apicurio-registry/ # In-memory registry instance
242-
└── streamshub-console/ # Console instance
243-
244-
overlays/ # Future: variant configurations
266+
components/ # Reusable Kustomize components
267+
├── core/ # Core stack component
268+
│ ├── base/ # Operators & CRDs
269+
│ │ ├── strimzi-operator/ # Strimzi Kafka Operator
270+
│ │ ├── apicurio-registry-operator/ # Apicurio Registry Operator
271+
│ │ └── streamshub-console-operator/ # StreamsHub Console Operator
272+
│ └── stack/ # Operands (Custom Resources)
273+
│ ├── kafka/ # Single-node Kafka cluster
274+
│ ├── apicurio-registry/ # In-memory registry instance
275+
│ └── streamshub-console/ # Console instance
276+
└── metrics/ # Prometheus metrics component
277+
├── base/ # Prometheus Operator
278+
└── stack/ # Prometheus instance, PodMonitors, patches
279+
280+
overlays/ # Deployable configurations
281+
├── core/ # Default install (core only)
282+
│ ├── base/ # Phase 1: Operators & CRDs
283+
│ └── stack/ # Phase 2: Operands
284+
└── metrics/ # Core + Prometheus metrics
285+
├── base/ # Phase 1: Operators & CRDs + Prometheus Operator
286+
└── stack/ # Phase 2: Operands + Prometheus instance & monitors
245287
```

base/kustomization.yaml

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

base/apicurio-registry-operator/kustomization.yaml renamed to components/core/base/apicurio-registry-operator/kustomization.yaml

File renamed without changes.

0 commit comments

Comments
 (0)