From 90da429524af3ad27256dc37b2c0e0a63c227c4d Mon Sep 17 00:00:00 2001 From: Thomas Cooper Date: Mon, 23 Mar 2026 11:05:51 +0000 Subject: [PATCH 1/4] Add prometheus metrics installation and setup * 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) Signed-off-by: Thomas Cooper --- .github/workflows/validate.yaml | 30 +++++-- README.md | 78 +++++++++++++---- base/kustomization.yaml | 7 -- .../kustomization.yaml | 0 .../apicurio-registry-operator/namespace.yaml | 0 components/core/base/kustomization.yaml | 24 +++++ .../kustomization.yaml | 13 --- .../namespace.yaml | 0 .../strimzi-operator/clusterrolebindings.yaml | 0 .../base}/strimzi-operator/kustomization.yaml | 0 .../base}/strimzi-operator/namespace.yaml | 0 .../apicurio-registry/kustomization.yaml | 0 .../stack}/apicurio-registry/registry.yaml | 0 .../core/stack}/kafka/kustomization.yaml | 0 .../core/stack}/kafka/namespace.yaml | 0 .../core/stack}/kustomization.yaml | 4 +- .../stack}/streamshub-console/console.yaml | 0 .../streamshub-console/kustomization.yaml | 0 components/metrics/base/kustomization.yaml | 5 ++ .../prometheus-operator/kustomization.yaml | 22 +++++ .../base/prometheus-operator/namespace.yaml | 4 + .../metrics/stack/console-metrics-patch.yaml | 14 +++ .../console-operator-service-monitor.yaml | 15 ++++ .../metrics/stack/kafka-metrics-patch.yaml | 8 ++ components/metrics/stack/kustomization.yaml | 23 +++++ .../cluster-operator-metrics.yaml | 15 ++++ .../pod-monitors/entity-operator-metrics.yaml | 15 ++++ .../pod-monitors/kafka-resources-metrics.yaml | 49 +++++++++++ .../stack/pod-monitors/kustomization.yaml | 14 +++ .../prometheus/cluster-role-binding.yaml | 12 +++ .../stack/prometheus/cluster-role.yaml | 19 ++++ .../prometheus/kubernetes-scrape-configs.yaml | 87 +++++++++++++++++++ .../stack/prometheus/kustomization.yaml | 17 ++++ .../metrics/stack/prometheus/namespace.yaml | 4 + .../metrics/stack/prometheus/prometheus.yaml | 17 ++++ .../stack/prometheus/service-account.yaml | 4 + install.sh | 76 +++++++++++++--- overlays/.gitkeep | 0 overlays/core/base/kustomization.yaml | 5 ++ overlays/core/stack/kustomization.yaml | 5 ++ overlays/metrics/base/kustomization.yaml | 6 ++ overlays/metrics/stack/kustomization.yaml | 6 ++ uninstall.sh | 40 +++++++-- update-version.sh | 26 ++++-- 44 files changed, 592 insertions(+), 72 deletions(-) delete mode 100644 base/kustomization.yaml rename {base => components/core/base}/apicurio-registry-operator/kustomization.yaml (100%) rename {base => components/core/base}/apicurio-registry-operator/namespace.yaml (100%) create mode 100644 components/core/base/kustomization.yaml rename {base => components/core/base}/streamshub-console-operator/kustomization.yaml (58%) rename {base => components/core/base}/streamshub-console-operator/namespace.yaml (100%) rename {base => components/core/base}/strimzi-operator/clusterrolebindings.yaml (100%) rename {base => components/core/base}/strimzi-operator/kustomization.yaml (100%) rename {base => components/core/base}/strimzi-operator/namespace.yaml (100%) rename {stack => components/core/stack}/apicurio-registry/kustomization.yaml (100%) rename {stack => components/core/stack}/apicurio-registry/registry.yaml (100%) rename {stack => components/core/stack}/kafka/kustomization.yaml (100%) rename {stack => components/core/stack}/kafka/namespace.yaml (100%) rename {stack => components/core/stack}/kustomization.yaml (51%) rename {stack => components/core/stack}/streamshub-console/console.yaml (100%) rename {stack => components/core/stack}/streamshub-console/kustomization.yaml (100%) create mode 100644 components/metrics/base/kustomization.yaml create mode 100644 components/metrics/base/prometheus-operator/kustomization.yaml create mode 100644 components/metrics/base/prometheus-operator/namespace.yaml create mode 100644 components/metrics/stack/console-metrics-patch.yaml create mode 100644 components/metrics/stack/console-operator-service-monitor.yaml create mode 100644 components/metrics/stack/kafka-metrics-patch.yaml create mode 100644 components/metrics/stack/kustomization.yaml create mode 100644 components/metrics/stack/pod-monitors/cluster-operator-metrics.yaml create mode 100644 components/metrics/stack/pod-monitors/entity-operator-metrics.yaml create mode 100644 components/metrics/stack/pod-monitors/kafka-resources-metrics.yaml create mode 100644 components/metrics/stack/pod-monitors/kustomization.yaml create mode 100644 components/metrics/stack/prometheus/cluster-role-binding.yaml create mode 100644 components/metrics/stack/prometheus/cluster-role.yaml create mode 100644 components/metrics/stack/prometheus/kubernetes-scrape-configs.yaml create mode 100644 components/metrics/stack/prometheus/kustomization.yaml create mode 100644 components/metrics/stack/prometheus/namespace.yaml create mode 100644 components/metrics/stack/prometheus/prometheus.yaml create mode 100644 components/metrics/stack/prometheus/service-account.yaml delete mode 100644 overlays/.gitkeep create mode 100644 overlays/core/base/kustomization.yaml create mode 100644 overlays/core/stack/kustomization.yaml create mode 100644 overlays/metrics/base/kustomization.yaml create mode 100644 overlays/metrics/stack/kustomization.yaml diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index b5ca400..40bf3b4 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -16,19 +16,33 @@ jobs: - name: Set up kubectl uses: azure/setup-kubectl@776406bce94f63e41d621b960d78ee25c8b76ede # v4.0.1 - - name: Build base layer - run: kubectl kustomize base/ + - name: Build core overlay base + run: kubectl kustomize overlays/core/base/ - - name: Build stack layer - run: kubectl kustomize stack/ + - name: Build core overlay stack + run: kubectl kustomize overlays/core/stack/ - - name: Verify quick-start labels in base + - name: Build metrics overlay base + run: kubectl kustomize overlays/metrics/base/ + + - name: Build metrics overlay stack + run: kubectl kustomize overlays/metrics/stack/ + + - name: Verify quick-start labels in core overlay base + run: | + kubectl kustomize overlays/core/base/ | grep -q 'app.kubernetes.io/part-of: streamshub-developer-quickstart' + + - name: Verify quick-start labels in core overlay stack + run: | + kubectl kustomize overlays/core/stack/ | grep -q 'app.kubernetes.io/part-of: streamshub-developer-quickstart' + + - name: Verify quick-start labels in metrics overlay base run: | - kubectl kustomize base/ | grep -q 'app.kubernetes.io/part-of: streamshub-developer-quickstart' + kubectl kustomize overlays/metrics/base/ | grep -q 'app.kubernetes.io/part-of: streamshub-developer-quickstart' - - name: Verify quick-start labels in stack + - name: Verify quick-start labels in metrics overlay stack run: | - kubectl kustomize stack/ | grep -q 'app.kubernetes.io/part-of: streamshub-developer-quickstart' + kubectl kustomize overlays/metrics/stack/ | grep -q 'app.kubernetes.io/part-of: streamshub-developer-quickstart' shellcheck: name: Lint shell scripts diff --git a/README.md b/README.md index 10eec81..31a1518 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ A Kustomize-based repository for deploying the StreamsHub event-streaming stack | StreamsHub Console Operator | `streamshub-console` | Manages console instances | | StreamsHub Console instance | `streamshub-console` | Web UI for Kafka management | +> **Optional:** The [metrics overlay](#install-with-metrics) adds Prometheus Operator, a Prometheus instance, and Kafka metrics collection via PodMonitors. + ## Prerequisites - `kubectl` v1.27 or later (for Kustomize v5.0 `labels` transformer support) @@ -39,6 +41,7 @@ The install script accepts the following environment variables: |----------|---------|-------------| | `REPO` | `streamshub/developer-quickstart` | GitHub repository path | | `REF` | `main` | Git ref, branch, or tag | +| `OVERLAY` | *(empty)* | Overlay to apply (e.g. `metrics`) | | `TIMEOUT` | `120s` | `kubectl wait` timeout | Example with a pinned version: @@ -47,6 +50,16 @@ Example with a pinned version: curl -sL https://raw.githubusercontent.com/streamshub/developer-quickstart/main/install.sh | REF=v1.0.0 bash ``` +### Install with Metrics + +Deploy the stack with Prometheus metrics collection: + +```shell +curl -sL https://raw.githubusercontent.com/streamshub/developer-quickstart/main/install.sh | OVERLAY=metrics bash +``` + +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. + ## Manual Install If you prefer to control each step, the stack is installed in two phases: @@ -54,7 +67,7 @@ If you prefer to control each step, the stack is installed in two phases: ### Phase 1 — Operators and CRDs ```shell -kubectl apply -k 'https://github.com/streamshub/developer-quickstart//base?ref=main' +kubectl apply -k 'https://github.com/streamshub/developer-quickstart//overlays/core/base?ref=main' ``` Wait for the operators to become ready: @@ -68,7 +81,23 @@ kubectl wait --for=condition=Available deployment/streamshub-console-operator -n ### Phase 2 — Operands ```shell -kubectl apply -k 'https://github.com/streamshub/developer-quickstart//stack?ref=main' +kubectl apply -k 'https://github.com/streamshub/developer-quickstart//overlays/core/stack?ref=main' +``` + +### Manual Install with Metrics + +To include the metrics overlay, use the `overlays/metrics` paths instead of `overlays/core`. + +```shell +# Phase 1 +kubectl create -k 'https://github.com/streamshub/developer-quickstart//overlays/metrics/base?ref=main' +kubectl wait --for=condition=Available deployment/prometheus-operator -n monitoring --timeout=120s +kubectl wait --for=condition=Available deployment/strimzi-cluster-operator -n strimzi --timeout=120s +kubectl wait --for=condition=Available deployment/apicurio-registry-operator -n apicurio-registry --timeout=120s +kubectl wait --for=condition=Available deployment/streamshub-console-operator -n streamshub-console --timeout=120s + +# Phase 2 +kubectl apply -k 'https://github.com/streamshub/developer-quickstart//overlays/metrics/stack?ref=main' ``` ## Accessing the Console @@ -142,6 +171,9 @@ The uninstall script handles safe teardown with shared-cluster safety checks: ```shell curl -sL https://raw.githubusercontent.com/streamshub/developer-quickstart/main/uninstall.sh | bash + +# If installed with the metrics overlay: +curl -sL https://raw.githubusercontent.com/streamshub/developer-quickstart/main/uninstall.sh | OVERLAY=metrics bash ``` The script: @@ -156,7 +188,7 @@ The script: **Phase 1 — Delete operands:** ```shell -kubectl delete -k 'https://github.com/streamshub/developer-quickstart//stack?ref=main' +kubectl delete -k 'https://github.com/streamshub/developer-quickstart//overlays/core/stack?ref=main' ``` 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. > ``` ```shell -kubectl delete -k 'https://github.com/streamshub/developer-quickstart//base?ref=main' +kubectl delete -k 'https://github.com/streamshub/developer-quickstart//overlays/core/base?ref=main' ``` +For the metrics overlay, use `overlays/metrics/base` and `overlays/metrics/stack` instead. + ### Finding Quick-Start Resources 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: ./update-version.sh strimzi 0.52.0 ``` -Supported components: `strimzi`, `apicurio-registry`, `streamshub-console` +Supported components: `strimzi`, `apicurio-registry`, `streamshub-console`, `prometheus-operator` ### Testing scripts locally @@ -229,17 +263,25 @@ LOCAL_DIR=/home/user/repos/developer-quickstart ./install.sh ## Repository Structure ``` -base/ # Phase 1: Operators & CRDs -├── kustomization.yaml # Composes all operator sub-components -├── strimzi-operator/ # Strimzi Kafka Operator -├── apicurio-registry-operator/ # Apicurio Registry Operator -└── streamshub-console-operator/ # StreamsHub Console Operator - -stack/ # Phase 2: Operands (Custom Resources) -├── kustomization.yaml # Composes all operand sub-components -├── kafka/ # Single-node Kafka cluster -├── apicurio-registry/ # In-memory registry instance -└── streamshub-console/ # Console instance - -overlays/ # Future: variant configurations +components/ # Reusable Kustomize components +├── core/ # Core stack component +│ ├── base/ # Operators & CRDs +│ │ ├── strimzi-operator/ # Strimzi Kafka Operator +│ │ ├── apicurio-registry-operator/ # Apicurio Registry Operator +│ │ └── streamshub-console-operator/ # StreamsHub Console Operator +│ └── stack/ # Operands (Custom Resources) +│ ├── kafka/ # Single-node Kafka cluster +│ ├── apicurio-registry/ # In-memory registry instance +│ └── streamshub-console/ # Console instance +└── metrics/ # Prometheus metrics component + ├── base/ # Prometheus Operator + └── stack/ # Prometheus instance, PodMonitors, patches + +overlays/ # Deployable configurations +├── core/ # Default install (core only) +│ ├── base/ # Phase 1: Operators & CRDs +│ └── stack/ # Phase 2: Operands +└── metrics/ # Core + Prometheus metrics + ├── base/ # Phase 1: Operators & CRDs + Prometheus Operator + └── stack/ # Phase 2: Operands + Prometheus instance & monitors ``` diff --git a/base/kustomization.yaml b/base/kustomization.yaml deleted file mode 100644 index 2651cf0..0000000 --- a/base/kustomization.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization - -resources: - - strimzi-operator - - apicurio-registry-operator - - streamshub-console-operator diff --git a/base/apicurio-registry-operator/kustomization.yaml b/components/core/base/apicurio-registry-operator/kustomization.yaml similarity index 100% rename from base/apicurio-registry-operator/kustomization.yaml rename to components/core/base/apicurio-registry-operator/kustomization.yaml diff --git a/base/apicurio-registry-operator/namespace.yaml b/components/core/base/apicurio-registry-operator/namespace.yaml similarity index 100% rename from base/apicurio-registry-operator/namespace.yaml rename to components/core/base/apicurio-registry-operator/namespace.yaml diff --git a/components/core/base/kustomization.yaml b/components/core/base/kustomization.yaml new file mode 100644 index 0000000..ea6d1ee --- /dev/null +++ b/components/core/base/kustomization.yaml @@ -0,0 +1,24 @@ +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +resources: + - strimzi-operator + - apicurio-registry-operator + - streamshub-console-operator + +patches: + # The streamshub-console-operator install YAML includes a ServiceMonitor + # that requires the Prometheus Operator CRD (monitoring.coreos.com). + # Since the base install does not include Prometheus, we remove it here. + # The metrics component re-adds monitoring via its own ServiceMonitor. + - target: + group: monitoring.coreos.com + version: v1 + kind: ServiceMonitor + name: streamshub-console-operator + patch: |- + $patch: delete + apiVersion: monitoring.coreos.com/v1 + kind: ServiceMonitor + metadata: + name: streamshub-console-operator diff --git a/base/streamshub-console-operator/kustomization.yaml b/components/core/base/streamshub-console-operator/kustomization.yaml similarity index 58% rename from base/streamshub-console-operator/kustomization.yaml rename to components/core/base/streamshub-console-operator/kustomization.yaml index f27257a..4112aaa 100644 --- a/base/streamshub-console-operator/kustomization.yaml +++ b/components/core/base/streamshub-console-operator/kustomization.yaml @@ -25,16 +25,3 @@ patches: - op: replace path: /subjects/0/namespace value: streamshub-console - # Remove ServiceMonitor — requires Prometheus Operator CRD which is not - # part of the base install. A metrics overlay will be added separately. - - target: - group: monitoring.coreos.com - version: v1 - kind: ServiceMonitor - name: streamshub-console-operator - patch: |- - $patch: delete - apiVersion: monitoring.coreos.com/v1 - kind: ServiceMonitor - metadata: - name: streamshub-console-operator diff --git a/base/streamshub-console-operator/namespace.yaml b/components/core/base/streamshub-console-operator/namespace.yaml similarity index 100% rename from base/streamshub-console-operator/namespace.yaml rename to components/core/base/streamshub-console-operator/namespace.yaml diff --git a/base/strimzi-operator/clusterrolebindings.yaml b/components/core/base/strimzi-operator/clusterrolebindings.yaml similarity index 100% rename from base/strimzi-operator/clusterrolebindings.yaml rename to components/core/base/strimzi-operator/clusterrolebindings.yaml diff --git a/base/strimzi-operator/kustomization.yaml b/components/core/base/strimzi-operator/kustomization.yaml similarity index 100% rename from base/strimzi-operator/kustomization.yaml rename to components/core/base/strimzi-operator/kustomization.yaml diff --git a/base/strimzi-operator/namespace.yaml b/components/core/base/strimzi-operator/namespace.yaml similarity index 100% rename from base/strimzi-operator/namespace.yaml rename to components/core/base/strimzi-operator/namespace.yaml diff --git a/stack/apicurio-registry/kustomization.yaml b/components/core/stack/apicurio-registry/kustomization.yaml similarity index 100% rename from stack/apicurio-registry/kustomization.yaml rename to components/core/stack/apicurio-registry/kustomization.yaml diff --git a/stack/apicurio-registry/registry.yaml b/components/core/stack/apicurio-registry/registry.yaml similarity index 100% rename from stack/apicurio-registry/registry.yaml rename to components/core/stack/apicurio-registry/registry.yaml diff --git a/stack/kafka/kustomization.yaml b/components/core/stack/kafka/kustomization.yaml similarity index 100% rename from stack/kafka/kustomization.yaml rename to components/core/stack/kafka/kustomization.yaml diff --git a/stack/kafka/namespace.yaml b/components/core/stack/kafka/namespace.yaml similarity index 100% rename from stack/kafka/namespace.yaml rename to components/core/stack/kafka/namespace.yaml diff --git a/stack/kustomization.yaml b/components/core/stack/kustomization.yaml similarity index 51% rename from stack/kustomization.yaml rename to components/core/stack/kustomization.yaml index ebc1b71..78be7d6 100644 --- a/stack/kustomization.yaml +++ b/components/core/stack/kustomization.yaml @@ -1,5 +1,5 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component resources: - kafka diff --git a/stack/streamshub-console/console.yaml b/components/core/stack/streamshub-console/console.yaml similarity index 100% rename from stack/streamshub-console/console.yaml rename to components/core/stack/streamshub-console/console.yaml diff --git a/stack/streamshub-console/kustomization.yaml b/components/core/stack/streamshub-console/kustomization.yaml similarity index 100% rename from stack/streamshub-console/kustomization.yaml rename to components/core/stack/streamshub-console/kustomization.yaml diff --git a/components/metrics/base/kustomization.yaml b/components/metrics/base/kustomization.yaml new file mode 100644 index 0000000..b59a6bc --- /dev/null +++ b/components/metrics/base/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +resources: + - prometheus-operator diff --git a/components/metrics/base/prometheus-operator/kustomization.yaml b/components/metrics/base/prometheus-operator/kustomization.yaml new file mode 100644 index 0000000..4281632 --- /dev/null +++ b/components/metrics/base/prometheus-operator/kustomization.yaml @@ -0,0 +1,22 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: monitoring + +resources: + - https://github.com/prometheus-operator/prometheus-operator/releases/download/v0.89.0/bundle.yaml + - namespace.yaml + +labels: + - pairs: + app.kubernetes.io/part-of: streamshub-developer-quickstart + includeSelectors: false + +patches: + - target: + kind: ClusterRoleBinding + name: prometheus-operator + patch: |- + - op: replace + path: /subjects/0/namespace + value: monitoring diff --git a/components/metrics/base/prometheus-operator/namespace.yaml b/components/metrics/base/prometheus-operator/namespace.yaml new file mode 100644 index 0000000..d325236 --- /dev/null +++ b/components/metrics/base/prometheus-operator/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: monitoring diff --git a/components/metrics/stack/console-metrics-patch.yaml b/components/metrics/stack/console-metrics-patch.yaml new file mode 100644 index 0000000..44da331 --- /dev/null +++ b/components/metrics/stack/console-metrics-patch.yaml @@ -0,0 +1,14 @@ +apiVersion: console.streamshub.github.com/v1alpha1 +kind: Console +metadata: + name: streamshub-console +spec: + metricsSources: + - name: prometheus + type: standalone + url: http://prometheus-operated.monitoring.svc:9090 + kafkaClusters: + - name: dev-cluster + namespace: kafka + listener: plain + metricsSource: prometheus diff --git a/components/metrics/stack/console-operator-service-monitor.yaml b/components/metrics/stack/console-operator-service-monitor.yaml new file mode 100644 index 0000000..96f95bc --- /dev/null +++ b/components/metrics/stack/console-operator-service-monitor.yaml @@ -0,0 +1,15 @@ +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + labels: + app.kubernetes.io/name: streamshub-console-operator + name: streamshub-console-operator + namespace: streamshub-console +spec: + selector: {} + endpoints: + - scheme: http + targetPort: 8080 + path: /q/metrics + interval: 10s + honorLabels: true diff --git a/components/metrics/stack/kafka-metrics-patch.yaml b/components/metrics/stack/kafka-metrics-patch.yaml new file mode 100644 index 0000000..287a51a --- /dev/null +++ b/components/metrics/stack/kafka-metrics-patch.yaml @@ -0,0 +1,8 @@ +apiVersion: kafka.strimzi.io/v1 +kind: Kafka +metadata: + name: dev-cluster +spec: + kafka: + metricsConfig: + type: strimziMetricsReporter diff --git a/components/metrics/stack/kustomization.yaml b/components/metrics/stack/kustomization.yaml new file mode 100644 index 0000000..cb4eefd --- /dev/null +++ b/components/metrics/stack/kustomization.yaml @@ -0,0 +1,23 @@ +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +resources: + - prometheus + - pod-monitors + - console-operator-service-monitor.yaml + +patches: + # Add metricsConfig to Kafka CR + - target: + group: kafka.strimzi.io + version: v1 + kind: Kafka + name: dev-cluster + path: kafka-metrics-patch.yaml + # Add metricsSources to Console CR + - target: + group: console.streamshub.github.com + version: v1alpha1 + kind: Console + name: streamshub-console + path: console-metrics-patch.yaml diff --git a/components/metrics/stack/pod-monitors/cluster-operator-metrics.yaml b/components/metrics/stack/pod-monitors/cluster-operator-metrics.yaml new file mode 100644 index 0000000..8b45333 --- /dev/null +++ b/components/metrics/stack/pod-monitors/cluster-operator-metrics.yaml @@ -0,0 +1,15 @@ +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: cluster-operator-metrics + labels: + app: strimzi +spec: + selector: + matchLabels: + strimzi.io/kind: cluster-operator + namespaceSelector: + any: true + podMetricsEndpoints: + - path: /metrics + port: http diff --git a/components/metrics/stack/pod-monitors/entity-operator-metrics.yaml b/components/metrics/stack/pod-monitors/entity-operator-metrics.yaml new file mode 100644 index 0000000..5b36bea --- /dev/null +++ b/components/metrics/stack/pod-monitors/entity-operator-metrics.yaml @@ -0,0 +1,15 @@ +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: entity-operator-metrics + labels: + app: strimzi +spec: + selector: + matchLabels: + app.kubernetes.io/name: entity-operator + namespaceSelector: + any: true + podMetricsEndpoints: + - path: /metrics + port: healthcheck diff --git a/components/metrics/stack/pod-monitors/kafka-resources-metrics.yaml b/components/metrics/stack/pod-monitors/kafka-resources-metrics.yaml new file mode 100644 index 0000000..8167963 --- /dev/null +++ b/components/metrics/stack/pod-monitors/kafka-resources-metrics.yaml @@ -0,0 +1,49 @@ +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: kafka-resources-metrics + labels: + app: strimzi +spec: + selector: + matchExpressions: + - key: strimzi.io/kind + operator: In + values: + - Kafka + - KafkaConnect + - KafkaMirrorMaker2 + namespaceSelector: + any: true + podMetricsEndpoints: + - path: /metrics + port: tcp-prometheus + relabelings: + - separator: ; + regex: __meta_kubernetes_pod_label_(strimzi_io_.+) + replacement: $1 + action: labelmap + - sourceLabels: [__meta_kubernetes_namespace] + separator: ; + regex: (.*) + targetLabel: namespace + replacement: $1 + action: replace + - sourceLabels: [__meta_kubernetes_pod_name] + separator: ; + regex: (.*) + targetLabel: kubernetes_pod_name + replacement: $1 + action: replace + - sourceLabels: [__meta_kubernetes_pod_node_name] + separator: ; + regex: (.*) + targetLabel: node_name + replacement: $1 + action: replace + - sourceLabels: [__meta_kubernetes_pod_host_ip] + separator: ; + regex: (.*) + targetLabel: node_ip + replacement: $1 + action: replace diff --git a/components/metrics/stack/pod-monitors/kustomization.yaml b/components/metrics/stack/pod-monitors/kustomization.yaml new file mode 100644 index 0000000..d028712 --- /dev/null +++ b/components/metrics/stack/pod-monitors/kustomization.yaml @@ -0,0 +1,14 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: monitoring + +resources: + - kafka-resources-metrics.yaml + - cluster-operator-metrics.yaml + - entity-operator-metrics.yaml + +labels: + - pairs: + app.kubernetes.io/part-of: streamshub-developer-quickstart + includeSelectors: false diff --git a/components/metrics/stack/prometheus/cluster-role-binding.yaml b/components/metrics/stack/prometheus/cluster-role-binding.yaml new file mode 100644 index 0000000..84fea72 --- /dev/null +++ b/components/metrics/stack/prometheus/cluster-role-binding.yaml @@ -0,0 +1,12 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: prometheus-server +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: prometheus-server +subjects: + - kind: ServiceAccount + name: prometheus-server + namespace: monitoring diff --git a/components/metrics/stack/prometheus/cluster-role.yaml b/components/metrics/stack/prometheus/cluster-role.yaml new file mode 100644 index 0000000..59f2359 --- /dev/null +++ b/components/metrics/stack/prometheus/cluster-role.yaml @@ -0,0 +1,19 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: prometheus-server +rules: + - apiGroups: [""] + resources: + - nodes + - nodes/proxy + - services + - endpoints + - pods + verbs: ["get", "list", "watch"] + - apiGroups: ["extensions"] + resources: + - ingresses + verbs: ["get", "list", "watch"] + - nonResourceURLs: ["/metrics"] + verbs: ["get"] diff --git a/components/metrics/stack/prometheus/kubernetes-scrape-configs.yaml b/components/metrics/stack/prometheus/kubernetes-scrape-configs.yaml new file mode 100644 index 0000000..bf5b941 --- /dev/null +++ b/components/metrics/stack/prometheus/kubernetes-scrape-configs.yaml @@ -0,0 +1,87 @@ +apiVersion: v1 +kind: Secret +metadata: + name: kubernetes-scrape-configs +type: Opaque +stringData: + prometheus-additional.yaml: | + - job_name: kubernetes-cadvisor + honor_labels: true + scrape_interval: 10s + scrape_timeout: 10s + metrics_path: /metrics/cadvisor + scheme: https + kubernetes_sd_configs: + - role: node + namespaces: + names: [] + bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token + tls_config: + ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt + insecure_skip_verify: true + relabel_configs: + - separator: ; + regex: __meta_kubernetes_node_label_(.+) + replacement: $1 + action: labelmap + - separator: ; + regex: (.*) + target_label: __address__ + replacement: kubernetes.default.svc:443 + action: replace + - source_labels: [__meta_kubernetes_node_name] + separator: ; + regex: (.+) + target_label: __metrics_path__ + replacement: /api/v1/nodes/${1}/proxy/metrics/cadvisor + action: replace + - source_labels: [__meta_kubernetes_node_name] + separator: ; + regex: (.*) + target_label: node_name + replacement: $1 + action: replace + - source_labels: [__meta_kubernetes_node_address_InternalIP] + separator: ; + regex: (.*) + target_label: node_ip + replacement: $1 + action: replace + metric_relabel_configs: + - source_labels: [__name__] + separator: ; + regex: container_(network_tcp_usage_total|tasks_state|memory_failures_total|network_udp_usage_total) + replacement: $1 + action: drop + # On minikube/Docker, cAdvisor does not populate the container label. + # Set container="kafka" for pod-level Kafka metrics so the console can + # match them. On containerd clusters, container is already set and this + # rule will not match. + - source_labels: [container, namespace, pod] + separator: ; + regex: ;kafka;(.+-.+-\d+) + target_label: container + replacement: kafka + action: replace + + - job_name: kubernetes-nodes-kubelet + scrape_interval: 10s + scrape_timeout: 10s + scheme: https + kubernetes_sd_configs: + - role: node + namespaces: + names: [] + bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token + tls_config: + ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt + insecure_skip_verify: true + relabel_configs: + - action: labelmap + regex: __meta_kubernetes_node_label_(.+) + - target_label: __address__ + replacement: kubernetes.default.svc:443 + - source_labels: [__meta_kubernetes_node_name] + regex: (.+) + target_label: __metrics_path__ + replacement: /api/v1/nodes/${1}/proxy/metrics diff --git a/components/metrics/stack/prometheus/kustomization.yaml b/components/metrics/stack/prometheus/kustomization.yaml new file mode 100644 index 0000000..da42884 --- /dev/null +++ b/components/metrics/stack/prometheus/kustomization.yaml @@ -0,0 +1,17 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: monitoring + +resources: + - namespace.yaml + - prometheus.yaml + - service-account.yaml + - cluster-role.yaml + - cluster-role-binding.yaml + - kubernetes-scrape-configs.yaml + +labels: + - pairs: + app.kubernetes.io/part-of: streamshub-developer-quickstart + includeSelectors: false diff --git a/components/metrics/stack/prometheus/namespace.yaml b/components/metrics/stack/prometheus/namespace.yaml new file mode 100644 index 0000000..d325236 --- /dev/null +++ b/components/metrics/stack/prometheus/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: monitoring diff --git a/components/metrics/stack/prometheus/prometheus.yaml b/components/metrics/stack/prometheus/prometheus.yaml new file mode 100644 index 0000000..be2b52e --- /dev/null +++ b/components/metrics/stack/prometheus/prometheus.yaml @@ -0,0 +1,17 @@ +apiVersion: monitoring.coreos.com/v1 +kind: Prometheus +metadata: + name: prometheus +spec: + replicas: 1 + resources: + requests: + memory: 400Mi + serviceAccountName: prometheus-server + podMonitorSelector: + matchLabels: + app: strimzi + serviceMonitorSelector: {} + additionalScrapeConfigs: + name: kubernetes-scrape-configs + key: prometheus-additional.yaml diff --git a/components/metrics/stack/prometheus/service-account.yaml b/components/metrics/stack/prometheus/service-account.yaml new file mode 100644 index 0000000..3e2c9a7 --- /dev/null +++ b/components/metrics/stack/prometheus/service-account.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: prometheus-server diff --git a/install.sh b/install.sh index fdd2ae5..26a2c60 100755 --- a/install.sh +++ b/install.sh @@ -13,10 +13,14 @@ # curl -sL https://raw.githubusercontent.com/streamshub/developer-quickstart/main/install.sh | REF=v1.0.0 bash # curl -sL https://raw.githubusercontent.com/streamshub/developer-quickstart/main/install.sh | REPO=myuser/developer-quickstart bash # +# # Install with Prometheus metrics overlay +# curl -sL https://raw.githubusercontent.com/streamshub/developer-quickstart/main/install.sh | OVERLAY=metrics bash +# # Environment variables: # LOCAL_DIR - Use local directory instead of GitHub (e.g. LOCAL_DIR=.) # REPO - GitHub repo path (default: streamshub/developer-quickstart) # REF - Git ref/branch/tag (default: main) +# OVERLAY - Overlay to apply (e.g. metrics). Empty = base install # TIMEOUT - kubectl wait timeout (default: 120s) # @@ -26,6 +30,7 @@ set -euo pipefail LOCAL_DIR="${LOCAL_DIR:-}" REPO="${REPO:-streamshub/developer-quickstart}" REF="${REF:-main}" +OVERLAY="${OVERLAY:-}" TIMEOUT="${TIMEOUT:-120s}" # Color output helpers @@ -73,8 +78,25 @@ check_prerequisites() { } main() { + # Compute kustomize paths based on overlay + local base_path="overlays/core/base" + local stack_path="overlays/core/stack" + if [ -n "${OVERLAY}" ]; then + base_path="overlays/${OVERLAY}/base" + stack_path="overlays/${OVERLAY}/stack" + fi + + # Compute total steps based on overlay + local total_steps=5 + if [ "${OVERLAY}" = "metrics" ]; then + total_steps=6 + fi + echo "" info "Installing StreamsHub developer quick-start stack" + if [ -n "${OVERLAY}" ]; then + info "Overlay: ${OVERLAY}" + fi if [ -n "${LOCAL_DIR}" ]; then info "Dir: ${LOCAL_DIR} | Timeout: ${TIMEOUT}" else @@ -86,39 +108,58 @@ main() { check_prerequisites echo "" - # --- Step 1: Install operators (base layer) --- + local step=1 + + # --- Step: Install operators (base layer) --- local base_url - base_url=$(kustomize_url "base") - info "Step 1/5: Installing operators and CRDs..." + base_url=$(kustomize_url "${base_path}") + info "Step ${step}/${total_steps}: Installing operators and CRDs..." info "Applying: ${base_url}" - kubectl apply -k "${base_url}" + # Server-side apply avoids annotation size limits with large CRDs + # (e.g. Prometheus Operator CRDs exceed the 262144-byte limit for + # the kubectl.kubernetes.io/last-applied-configuration annotation). + kubectl apply --server-side --force-conflicts -k "${base_url}" echo "" - # --- Step 2: Wait for Strimzi operator --- - info "Step 2/5: Waiting for strimzi-cluster-operator to be ready (timeout: ${TIMEOUT})..." + # --- Step: Wait for prometheus-operator (metrics overlay only) --- + if [ "${OVERLAY}" = "metrics" ]; then + step=$((step + 1)) + info "Step ${step}/${total_steps}: Waiting for prometheus-operator to be ready (timeout: ${TIMEOUT})..." + kubectl wait --for=condition=Available deployment/prometheus-operator \ + -n monitoring --timeout="${TIMEOUT}" + info "Prometheus operator is ready" + echo "" + fi + + # --- Step: Wait for Strimzi operator --- + step=$((step + 1)) + info "Step ${step}/${total_steps}: Waiting for strimzi-cluster-operator to be ready (timeout: ${TIMEOUT})..." kubectl wait --for=condition=Available deployment/strimzi-cluster-operator \ -n strimzi --timeout="${TIMEOUT}" info "Strimzi operator is ready" echo "" - # --- Step 3: Wait for Apicurio Registry operator --- - info "Step 3/5: Waiting for apicurio-registry-operator to be ready (timeout: ${TIMEOUT})..." + # --- Step: Wait for Apicurio Registry operator --- + step=$((step + 1)) + info "Step ${step}/${total_steps}: Waiting for apicurio-registry-operator to be ready (timeout: ${TIMEOUT})..." kubectl wait --for=condition=Available deployment/apicurio-registry-operator \ -n apicurio-registry --timeout="${TIMEOUT}" info "Apicurio Registry operator is ready" echo "" - # --- Step 4: Wait for StreamsHub Console operator --- - info "Step 4/5: Waiting for console-operator to be ready (timeout: ${TIMEOUT})..." + # --- Step: Wait for StreamsHub Console operator --- + step=$((step + 1)) + info "Step ${step}/${total_steps}: Waiting for console-operator to be ready (timeout: ${TIMEOUT})..." kubectl wait --for=condition=Available deployment/streamshub-console-operator \ -n streamshub-console --timeout="${TIMEOUT}" info "StreamsHub Console operator is ready" echo "" - # --- Step 5: Install operands (stack layer) --- + # --- Step: Install operands (stack layer) --- + step=$((step + 1)) local stack_url - stack_url=$(kustomize_url "stack") - info "Step 5/5: Installing operands (Kafka cluster, Registry instance, Console)..." + stack_url=$(kustomize_url "${stack_path}") + info "Step ${step}/${total_steps}: Installing operands (Kafka cluster, Registry instance, Console)..." info "Applying: ${stack_url}" kubectl apply -k "${stack_url}" echo "" @@ -133,6 +174,11 @@ main() { echo " - Apicurio Registry instance (namespace: apicurio-registry, storage: in-memory)" echo " - StreamsHub Console operator (namespace: streamshub-console)" echo " - StreamsHub Console instance (namespace: streamshub-console)" + if [ "${OVERLAY}" = "metrics" ]; then + echo " - Prometheus operator (namespace: monitoring)" + echo " - Prometheus instance (namespace: monitoring)" + echo " - Kafka metrics (PodMonitors) (namespace: monitoring)" + fi echo "" echo "Verify with:" echo " kubectl get deployment -n strimzi strimzi-cluster-operator" @@ -141,6 +187,10 @@ main() { echo " kubectl get apicurioregistry3 -n apicurio-registry" echo " kubectl get deployment -n streamshub-console console-operator" echo " kubectl get console -n streamshub-console" + if [ "${OVERLAY}" = "metrics" ]; then + echo " kubectl get prometheus -n monitoring" + echo " kubectl get podmonitor -n monitoring" + fi } main diff --git a/overlays/.gitkeep b/overlays/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/overlays/core/base/kustomization.yaml b/overlays/core/base/kustomization.yaml new file mode 100644 index 0000000..dbf71e8 --- /dev/null +++ b/overlays/core/base/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +components: + - ../../../components/core/base diff --git a/overlays/core/stack/kustomization.yaml b/overlays/core/stack/kustomization.yaml new file mode 100644 index 0000000..e8f1b9b --- /dev/null +++ b/overlays/core/stack/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +components: + - ../../../components/core/stack diff --git a/overlays/metrics/base/kustomization.yaml b/overlays/metrics/base/kustomization.yaml new file mode 100644 index 0000000..1c1fa4f --- /dev/null +++ b/overlays/metrics/base/kustomization.yaml @@ -0,0 +1,6 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +components: + - ../../../components/core/base + - ../../../components/metrics/base diff --git a/overlays/metrics/stack/kustomization.yaml b/overlays/metrics/stack/kustomization.yaml new file mode 100644 index 0000000..d7e0e43 --- /dev/null +++ b/overlays/metrics/stack/kustomization.yaml @@ -0,0 +1,6 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +components: + - ../../../components/core/stack + - ../../../components/metrics/stack diff --git a/uninstall.sh b/uninstall.sh index fc1523e..372e102 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -14,10 +14,14 @@ # curl -sL https://raw.githubusercontent.com/streamshub/developer-quickstart/main/uninstall.sh | REF=v1.0.0 bash # curl -sL https://raw.githubusercontent.com/streamshub/developer-quickstart/main/uninstall.sh | REPO=myuser/developer-quickstart bash # +# # Uninstall metrics overlay +# curl -sL https://raw.githubusercontent.com/streamshub/developer-quickstart/main/uninstall.sh | OVERLAY=metrics bash +# # Environment variables: # LOCAL_DIR - Use local directory instead of GitHub (e.g. LOCAL_DIR=.) # REPO - GitHub repo path (default: streamshub/developer-quickstart) # REF - Git ref/branch/tag (default: main) +# OVERLAY - Overlay to uninstall (e.g. metrics). Empty = base install # TIMEOUT - kubectl wait/poll timeout (default: 120s) # @@ -27,6 +31,7 @@ set -euo pipefail LOCAL_DIR="${LOCAL_DIR:-}" REPO="${REPO:-streamshub/developer-quickstart}" REF="${REF:-main}" +OVERLAY="${OVERLAY:-}" TIMEOUT="${TIMEOUT:-120s}" QUICKSTART_LABEL="app.kubernetes.io/part-of=streamshub-developer-quickstart" @@ -207,10 +212,22 @@ has_unlabeled_crs() { STRIMZI_API_GROUP_SUFFIX="strimzi.io" APICURIO_API_GROUP_SUFFIX="apicur.io" CONSOLE_API_GROUP_SUFFIX="streamshub.github.com" +PROMETHEUS_API_GROUP_SUFFIX="monitoring.coreos.com" main() { + # Compute kustomize paths based on overlay + local base_path="overlays/core/base" + local stack_path="overlays/core/stack" + if [ -n "${OVERLAY}" ]; then + base_path="overlays/${OVERLAY}/base" + stack_path="overlays/${OVERLAY}/stack" + fi + echo "" info "Uninstalling StreamsHub developer quick-start stack" + if [ -n "${OVERLAY}" ]; then + info "Overlay: ${OVERLAY}" + fi if [ -n "${LOCAL_DIR}" ]; then info "Dir: ${LOCAL_DIR} | Timeout: ${TIMEOUT}" else @@ -227,11 +244,15 @@ main() { STRIMZI_CR_TYPES=$(filter_cr_types "$STRIMZI_API_GROUP_SUFFIX" "$all_crds") APICURIO_CR_TYPES=$(filter_cr_types "$APICURIO_API_GROUP_SUFFIX" "$all_crds") CONSOLE_CR_TYPES=$(filter_cr_types "$CONSOLE_API_GROUP_SUFFIX" "$all_crds") + PROMETHEUS_CR_TYPES=$(filter_cr_types "$PROMETHEUS_API_GROUP_SUFFIX" "$all_crds") info "Discovered CR types:" info " Strimzi: ${STRIMZI_CR_TYPES:-}" info " Apicurio Registry: ${APICURIO_CR_TYPES:-}" info " StreamsHub Console: ${CONSOLE_CR_TYPES:-}" + if [ -n "${PROMETHEUS_CR_TYPES}" ]; then + info " Prometheus: ${PROMETHEUS_CR_TYPES}" + fi echo "" # Catch Ctrl+C so the shell doesn't silently exit before reaching interactive prompts @@ -342,7 +363,7 @@ main() { # --- Phase 2: Delete operands (stack layer) --- local stack_url - stack_url=$(kustomize_url "stack") + stack_url=$(kustomize_url "${stack_path}") info "Phase 2: Deleting operands..." info "Deleting: ${stack_url}" kubectl delete -k "${stack_url}" --ignore-not-found=true --wait=false 2>/dev/null || true @@ -421,7 +442,7 @@ main() { if [ "$strimzi_shared" = false ] && [ "$apicurio_shared" = false ] && [ "$console_shared" = false ]; then # No shared CRDs — safe to delete the entire base layer local base_url - base_url=$(kustomize_url "base") + base_url=$(kustomize_url "${base_path}") info "Phase 4: Deleting operators and CRDs (no shared usage detected)..." info "Deleting: ${base_url}" kubectl delete -k "${base_url}" --ignore-not-found=true 2>/dev/null || true @@ -432,7 +453,7 @@ main() { if [ "$strimzi_shared" = false ]; then info " Removing Strimzi operator (full removal including CRDs)..." local strimzi_url - strimzi_url=$(kustomize_url "base/strimzi-operator") + strimzi_url=$(kustomize_url "components/core/base/strimzi-operator") kubectl delete -k "${strimzi_url}" --ignore-not-found=true 2>/dev/null || true else warn " Strimzi: Removing operator deployment only (retaining CRDs)..." @@ -444,7 +465,7 @@ main() { if [ "$apicurio_shared" = false ]; then info " Removing Apicurio Registry operator (full removal including CRDs)..." local apicurio_url - apicurio_url=$(kustomize_url "base/apicurio-registry-operator") + apicurio_url=$(kustomize_url "components/core/base/apicurio-registry-operator") kubectl delete -k "${apicurio_url}" --ignore-not-found=true 2>/dev/null || true else warn " Apicurio Registry: Removing operator deployment only (retaining CRDs)..." @@ -455,13 +476,21 @@ main() { if [ "$console_shared" = false ]; then info " Removing StreamsHub Console operator (full removal including CRDs)..." local console_url - console_url=$(kustomize_url "base/streamshub-console-operator") + console_url=$(kustomize_url "components/core/base/streamshub-console-operator") kubectl delete -k "${console_url}" --ignore-not-found=true 2>/dev/null || true else warn " StreamsHub Console: Removing operator deployment only (retaining CRDs)..." kubectl delete deployment console-operator -n streamshub-console --ignore-not-found=true 2>/dev/null || true kubectl delete serviceaccount console-operator -n streamshub-console --ignore-not-found=true 2>/dev/null || true fi + + # Remove prometheus-operator if metrics overlay was used + if [ "${OVERLAY}" = "metrics" ]; then + info " Removing Prometheus operator..." + local prom_url + prom_url=$(kustomize_url "components/metrics/base/prometheus-operator") + kubectl delete -k "${prom_url}" --ignore-not-found=true 2>/dev/null || true + fi fi echo "" @@ -475,6 +504,7 @@ main() { [ "$strimzi_shared" = true ] && echo " - Strimzi CRDs (non-quick-start Kafka resources exist on the cluster)" [ "$apicurio_shared" = true ] && echo " - Apicurio Registry CRDs (non-quick-start Registry resources exist on the cluster)" [ "$console_shared" = true ] && echo " - StreamsHub Console CRDs (non-quick-start Console resources exist on the cluster)" + true # ensure block doesn't fail if all conditions are false echo "" echo "To manually remove retained CRDs after verifying no resources depend on them:" echo " kubectl get crds -l ${QUICKSTART_LABEL}" diff --git a/update-version.sh b/update-version.sh index 517e601..40b3007 100755 --- a/update-version.sh +++ b/update-version.sh @@ -47,8 +47,8 @@ setup_strimzi() { GITHUB_REPO="strimzi/strimzi-kafka-operator" VERSION_REGEX='releases/download/\K[0-9]+\.[0-9]+\.[0-9]+' COMPONENT_FILES=( - "${SCRIPT_DIR}/base/strimzi-operator/kustomization.yaml" - "${SCRIPT_DIR}/stack/kafka/kustomization.yaml" + "${SCRIPT_DIR}/components/core/base/strimzi-operator/kustomization.yaml" + "${SCRIPT_DIR}/components/core/stack/kafka/kustomization.yaml" ) } @@ -57,7 +57,7 @@ setup_apicurio_registry() { GITHUB_REPO="Apicurio/apicurio-registry" VERSION_REGEX='Apicurio/apicurio-registry/\K[0-9]+\.[0-9]+\.[0-9]+' COMPONENT_FILES=( - "${SCRIPT_DIR}/base/apicurio-registry-operator/kustomization.yaml" + "${SCRIPT_DIR}/components/core/base/apicurio-registry-operator/kustomization.yaml" ) } @@ -66,7 +66,16 @@ setup_streamshub_console() { GITHUB_REPO="streamshub/console" VERSION_REGEX='releases/download/\K[0-9]+\.[0-9]+\.[0-9]+' COMPONENT_FILES=( - "${SCRIPT_DIR}/base/streamshub-console-operator/kustomization.yaml" + "${SCRIPT_DIR}/components/core/base/streamshub-console-operator/kustomization.yaml" + ) +} + +setup_prometheus_operator() { + COMPONENT_LABEL="Prometheus Operator" + GITHUB_REPO="prometheus-operator/prometheus-operator" + VERSION_REGEX='releases/download/v\K[0-9]+\.[0-9]+\.[0-9]+' + COMPONENT_FILES=( + "${SCRIPT_DIR}/components/metrics/base/prometheus-operator/kustomization.yaml" ) } @@ -80,6 +89,7 @@ Components: strimzi Strimzi Kafka Operator apicurio-registry Apicurio Registry Operator streamshub-console StreamsHub Console Operator + prometheus-operator Prometheus Operator (metrics overlay) Arguments: component The component to update @@ -99,6 +109,7 @@ Examples: $(basename "$0") strimzi 0.51.0 # Update Strimzi to version $(basename "$0") apicurio-registry 3.1.8 # Update Apicurio Registry $(basename "$0") streamshub-console 0.12.0 # Update StreamsHub Console + $(basename "$0") prometheus-operator 0.90.0 # Update Prometheus Operator EOF exit 0 } @@ -116,9 +127,12 @@ setup_component() { streamshub-console) setup_streamshub_console ;; + prometheus-operator) + setup_prometheus_operator + ;; *) error "Unknown component: ${component}" - error "Valid components: strimzi, apicurio-registry, streamshub-console" + error "Valid components: strimzi, apicurio-registry, streamshub-console, prometheus-operator" exit 1 ;; esac @@ -386,7 +400,7 @@ main() { echo "" info "Next steps:" echo " 1. Review the changes: git diff" - echo " 2. Test the deployment: kubectl kustomize base/ && kubectl kustomize stack/" + echo " 2. Test the deployment: kubectl kustomize overlays/core/base/ && kubectl kustomize overlays/core/stack/" echo " 3. Commit the changes: git add -A && git commit -m 'Update ${COMPONENT_LABEL} to ${new_version}'" fi } From 094eca24017f0819119bbc63c5020ada109de627 Mon Sep 17 00:00:00 2001 From: Thomas Cooper Date: Thu, 26 Mar 2026 11:36:05 +0000 Subject: [PATCH 2/4] Add metrics overlay to smoke tests Signed-off-by: Thomas Cooper --- .github/actions/smoke-test/action.yaml | 4 +++- .github/config/overlays/{base.env => core.env} | 4 ++-- .github/config/overlays/metrics.env | 11 +++++++++++ .github/scripts/debug.sh | 4 ++-- .github/scripts/verify-install.sh | 4 ++-- .github/workflows/integration.yaml | 16 ++++++++++++++-- 6 files changed, 34 insertions(+), 9 deletions(-) rename .github/config/overlays/{base.env => core.env} (83%) create mode 100644 .github/config/overlays/metrics.env diff --git a/.github/actions/smoke-test/action.yaml b/.github/actions/smoke-test/action.yaml index 32bb91a..b2250e7 100644 --- a/.github/actions/smoke-test/action.yaml +++ b/.github/actions/smoke-test/action.yaml @@ -9,7 +9,7 @@ inputs: overlay: description: 'Overlay name for component verification (matches .github/config/overlays/.env)' required: false - default: 'base' + default: 'core' runs: using: 'composite' @@ -18,6 +18,7 @@ runs: shell: bash env: LOCAL_DIR: . + OVERLAY: ${{ inputs.overlay }} TIMEOUT: ${{ inputs.timeout }} run: ./install.sh @@ -31,6 +32,7 @@ runs: shell: bash env: LOCAL_DIR: . + OVERLAY: ${{ inputs.overlay }} TIMEOUT: ${{ inputs.timeout }} run: ./uninstall.sh diff --git a/.github/config/overlays/base.env b/.github/config/overlays/core.env similarity index 83% rename from .github/config/overlays/base.env rename to .github/config/overlays/core.env index e2ffc68..496d066 100644 --- a/.github/config/overlays/base.env +++ b/.github/config/overlays/core.env @@ -1,5 +1,5 @@ -# Components expected in the base (default) deployment. -# Used by verify-install.sh, verify-uninstall.sh, and debug.sh. +# Components expected in the core (default) deployment. +# Used by verify-install.sh and debug.sh. # # Format: # OPERATORS - "namespace:deployment" pairs (space-separated) diff --git a/.github/config/overlays/metrics.env b/.github/config/overlays/metrics.env new file mode 100644 index 0000000..39d9783 --- /dev/null +++ b/.github/config/overlays/metrics.env @@ -0,0 +1,11 @@ +# Components expected in the metrics overlay deployment. +# Used by verify-install.sh and debug.sh. +# +# Format: +# OPERATORS - "namespace:deployment" pairs (space-separated) +# CUSTOM_RESOURCES - "namespace:resource" pairs (space-separated) +# NAMESPACES - namespaces to inspect on failure (space-separated) + +OPERATORS="strimzi:strimzi-cluster-operator apicurio-registry:apicurio-registry-operator streamshub-console:streamshub-console-operator monitoring:prometheus-operator" +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" +NAMESPACES="strimzi kafka apicurio-registry streamshub-console monitoring" diff --git a/.github/scripts/debug.sh b/.github/scripts/debug.sh index 58c65ec..b165492 100755 --- a/.github/scripts/debug.sh +++ b/.github/scripts/debug.sh @@ -4,12 +4,12 @@ # Reads component definitions from an overlay config file. # # Environment variables: -# OVERLAY - overlay name (default: "base") +# OVERLAY - overlay name (default: "core") # set +e -OVERLAY="${OVERLAY:-base}" +OVERLAY="${OVERLAY:-core}" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" CONFIG_FILE="${SCRIPT_DIR}/../config/overlays/${OVERLAY}.env" diff --git a/.github/scripts/verify-install.sh b/.github/scripts/verify-install.sh index 2418ee2..3ac0869 100755 --- a/.github/scripts/verify-install.sh +++ b/.github/scripts/verify-install.sh @@ -4,13 +4,13 @@ # Reads component definitions from an overlay config file. # # Environment variables: -# OVERLAY - overlay name (default: "base") +# OVERLAY - overlay name (default: "core") # TIMEOUT - kubectl wait timeout (default: "600s") # set -euo pipefail -OVERLAY="${OVERLAY:-base}" +OVERLAY="${OVERLAY:-core}" TIMEOUT="${TIMEOUT:-600s}" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" CONFIG_FILE="${SCRIPT_DIR}/../config/overlays/${OVERLAY}.env" diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index b7eb86f..f9999d6 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -8,8 +8,12 @@ on: jobs: smoke-minikube: - name: smoke-minikube + name: smoke-minikube (${{ matrix.overlay }}) runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + overlay: [core, metrics] steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -24,10 +28,16 @@ jobs: - name: Smoke test uses: ./.github/actions/smoke-test + with: + overlay: ${{ matrix.overlay }} smoke-kind: - name: smoke-kind + name: smoke-kind (${{ matrix.overlay }}) runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + overlay: [core, metrics] steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -46,3 +56,5 @@ jobs: - name: Smoke test uses: ./.github/actions/smoke-test + with: + overlay: ${{ matrix.overlay }} From 164c5fae0232737969b1a5fd0d1473be76a70258 Mon Sep 17 00:00:00 2001 From: Thomas Cooper Date: Thu, 26 Mar 2026 17:07:25 +0000 Subject: [PATCH 3/4] Increase timeout for verify scripts Signed-off-by: Thomas Cooper --- .github/actions/smoke-test/action.yaml | 3 +++ .github/workflows/integration.yaml | 2 ++ 2 files changed, 5 insertions(+) diff --git a/.github/actions/smoke-test/action.yaml b/.github/actions/smoke-test/action.yaml index b2250e7..885b7e7 100644 --- a/.github/actions/smoke-test/action.yaml +++ b/.github/actions/smoke-test/action.yaml @@ -26,6 +26,7 @@ runs: shell: bash env: OVERLAY: ${{ inputs.overlay }} + TIMEOUT: ${{ inputs.timeout }} run: .github/scripts/verify-install.sh - name: Run uninstall script @@ -38,6 +39,8 @@ runs: - name: Verify uninstall shell: bash + env: + TIMEOUT: ${{ inputs.timeout }} run: .github/scripts/verify-uninstall.sh - name: Debug on failure diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index f9999d6..695e09c 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -29,6 +29,7 @@ jobs: - name: Smoke test uses: ./.github/actions/smoke-test with: + timeout: 300s overlay: ${{ matrix.overlay }} smoke-kind: @@ -57,4 +58,5 @@ jobs: - name: Smoke test uses: ./.github/actions/smoke-test with: + timeout: 300s overlay: ${{ matrix.overlay }} From a33e774280f831f930ec9c8472de532182f759d7 Mon Sep 17 00:00:00 2001 From: Thomas Cooper Date: Thu, 26 Mar 2026 17:44:18 +0000 Subject: [PATCH 4/4] Make the wait condition for the verify scripts an optional argument Signed-off-by: Thomas Cooper --- .github/config/overlays/core.env | 2 +- .github/config/overlays/metrics.env | 4 ++-- .github/scripts/verify-install.sh | 10 ++++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/config/overlays/core.env b/.github/config/overlays/core.env index 496d066..3ba3d49 100644 --- a/.github/config/overlays/core.env +++ b/.github/config/overlays/core.env @@ -3,7 +3,7 @@ # # Format: # OPERATORS - "namespace:deployment" pairs (space-separated) -# CUSTOM_RESOURCES - "namespace:resource" pairs (space-separated) +# CUSTOM_RESOURCES - "namespace:resource[:condition]" pairs (space-separated, condition defaults to Ready) # NAMESPACES - namespaces to inspect on failure (space-separated) OPERATORS="strimzi:strimzi-cluster-operator apicurio-registry:apicurio-registry-operator streamshub-console:streamshub-console-operator" diff --git a/.github/config/overlays/metrics.env b/.github/config/overlays/metrics.env index 39d9783..ba003a7 100644 --- a/.github/config/overlays/metrics.env +++ b/.github/config/overlays/metrics.env @@ -3,9 +3,9 @@ # # Format: # OPERATORS - "namespace:deployment" pairs (space-separated) -# CUSTOM_RESOURCES - "namespace:resource" pairs (space-separated) +# CUSTOM_RESOURCES - "namespace:resource[:condition]" pairs (space-separated, condition defaults to Ready) # NAMESPACES - namespaces to inspect on failure (space-separated) OPERATORS="strimzi:strimzi-cluster-operator apicurio-registry:apicurio-registry-operator streamshub-console:streamshub-console-operator monitoring:prometheus-operator" -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" +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" NAMESPACES="strimzi kafka apicurio-registry streamshub-console monitoring" diff --git a/.github/scripts/verify-install.sh b/.github/scripts/verify-install.sh index 3ac0869..903a9b1 100755 --- a/.github/scripts/verify-install.sh +++ b/.github/scripts/verify-install.sh @@ -37,7 +37,13 @@ echo "" for entry in ${CUSTOM_RESOURCES}; do ns="${entry%%:*}" - resource="${entry#*:}" + rest="${entry#*:}" + resource="${rest%:*}" + if [ "${rest}" != "${resource}" ]; then + condition="${rest##*:}" + else + condition="Ready" + fi echo "--- ${resource} (${ns}) ---" - kubectl wait "${resource}" --for=condition=Ready -n "${ns}" --timeout="${TIMEOUT}" + kubectl wait "${resource}" --for=condition="${condition}" -n "${ns}" --timeout="${TIMEOUT}" done