Skip to content

HYPERFLEET-1362 - feat: add kube-prometheus-stack observability stack#74

Open
Ruclo wants to merge 1 commit into
openshift-hyperfleet:mainfrom
Ruclo:HYPERFLEET-1362-feat-observability-stack
Open

HYPERFLEET-1362 - feat: add kube-prometheus-stack observability stack#74
Ruclo wants to merge 1 commit into
openshift-hyperfleet:mainfrom
Ruclo:HYPERFLEET-1362-feat-observability-stack

Conversation

@Ruclo

@Ruclo Ruclo commented Jul 22, 2026

Copy link
Copy Markdown

Summary

  • Add kube-prometheus-stack observability stack via separate helmfile/observability.yaml.gotmpl
  • Add OBSERVABILITY_ENABLED env var toggle (default false) controlling stack deployment and ServiceMonitor/PrometheusRule creation
  • Add install-grafana / uninstall-grafana Makefile targets, chained into local-up-kind and local-up-gcp

Details

The observability helmfile is separate from the main helmfile to keep the monitoring lifecycle independent — install-hyperfleet / uninstall-hyperfleet won't touch monitoring.

When OBSERVABILITY_ENABLED=true:

  • install-grafana deploys kube-prometheus-stack (Prometheus, Grafana, Operator, CRDs, node-exporter, kube-state-metrics)
  • ServiceMonitors are created for API, Sentinel, and Adapter
  • PrometheusRules are created for API and Sentinel
  • Prometheus scrapes all ServiceMonitors regardless of labels

Alertmanager and control plane scrapers (etcd, scheduler, controller-manager, proxy) are disabled. Grafana admin credentials are stored in a Kubernetes Secret.

Note: The ServiceMonitor values path is inconsistent across component charts — API and Adapter use serviceMonitor.* while Sentinel uses monitoring.serviceMonitor.*. This should be unified under monitoring.* in all three component charts in a follow-up.

Test plan

  • OBSERVABILITY_ENABLED=true HELMFILE_ENV=kind make install-grafana deploys the stack
  • kubectl get pods -n monitoring shows Prometheus, Grafana, operator, node-exporter, kube-state-metrics running
  • OBSERVABILITY_ENABLED=true HELMFILE_ENV=kind make install-hyperfleet creates ServiceMonitors and PrometheusRules
  • Port-forward Grafana (kubectl port-forward svc/kube-prometheus-stack-grafana 3000:80 -n monitoring) and verify HyperFleet metrics in Explore
  • HELMFILE_ENV=kind make uninstall-grafana tears down everything including namespace

🤖 Generated with Claude Code

@openshift-ci
openshift-ci Bot requested review from mbrudnoy and vkareh July 22, 2026 14:56
@openshift-ci

openshift-ci Bot commented Jul 22, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign ciaranroche for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 1bd3739a-4419-4036-aa2b-153dd8c9b3bb

📥 Commits

Reviewing files that changed from the base of the PR and between ca8e0d5 and 11375b3.

📒 Files selected for processing (8)
  • Makefile
  • env.gcp
  • env.kind
  • helmfile/observability.yaml.gotmpl
  • helmfile/values/base-adapter.yaml.gotmpl
  • helmfile/values/base-api.yaml.gotmpl
  • helmfile/values/base-kube-prometheus-stack.yaml.gotmpl
  • helmfile/values/base-sentinel.yaml.gotmpl
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)
🚧 Files skipped from review as they are similar to previous changes (7)
  • helmfile/values/base-api.yaml.gotmpl
  • env.kind
  • helmfile/values/base-kube-prometheus-stack.yaml.gotmpl
  • helmfile/values/base-sentinel.yaml.gotmpl
  • helmfile/values/base-adapter.yaml.gotmpl
  • env.gcp
  • helmfile/observability.yaml.gotmpl

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added optional Grafana/Prometheus observability support for local Kind and GKE environments.
    • Introduced commands to install, remove, and check the monitoring stack, including expanded status output (Helm releases and pods).
    • Added configurable monitoring namespace plus automatic Grafana admin credentials setup.
    • When enabled, deploys the kube-prometheus-stack and activates ServiceMonitors and Prometheus rules across supported apps.
  • Configuration
    • Observability is disabled by default; enable per environment via OBSERVABILITY_ENABLED.
    • Grafana admin password is required when installing.

Walkthrough

Adds opt-in observability configuration for Kind and GCP environments. Helmfile deploys kube-prometheus-stack with Grafana Secret references, Prometheus selector settings, and selected component exclusions. API, Adapter, and Sentinel values conditionally enable monitoring resources. Makefile targets manage installation, removal, status reporting, and local setup integration.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant LocalSetup
  participant Makefile
  participant Helmfile
  participant Kubernetes
  LocalSetup->>Makefile: invoke local setup
  Makefile->>Makefile: check OBSERVABILITY_ENABLED
  Makefile->>Kubernetes: create Grafana credentials Secret
  Makefile->>Helmfile: apply observability release
  Helmfile->>Kubernetes: deploy kube-prometheus-stack
  Kubernetes-->>Makefile: return monitoring release and pod status
Loading

Suggested reviewers: mbrudnoy, vkareh

🚥 Pre-merge checks | ✅ 10 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
No Injection Vectors ⚠️ Warning CWE-78: install-grafana/uninstall-grafana interpolate unquoted MONITORING_NAMESPACE and GRAFANA_ADMIN_* into shell recipes; only a non-empty check exists. Quote/escape all recipe args, validate namespace/admin-user with a strict regex, and avoid unquoted $(VAR) in kubectl/helmfile commands.
✅ Passed checks (10 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly names the kube-prometheus-stack observability stack being added.
Description check ✅ Passed The description directly matches the observability stack, toggle, and Makefile target changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Sec-02: Secrets In Log Output ✅ Passed No slog/logr/zap/fmt.Print* call exposes token/password/credential/secret; CWE-532 not triggered.
No Hardcoded Secrets ✅ Passed No new hardcoded creds/base64/embedded auth URLs in added lines; Grafana password is env-supplied and written to a K8s Secret (CWE-798).
No Weak Cryptography ✅ Passed No CWE-327/328 issue: changed files only add observability/Makefile logic; scans found no crypto/md5, crypto/des, crypto/rc4, SHA1-for-security, ECB, or secret comparisons.
No Privileged Containers ✅ Passed Touched manifests/templates/Dockerfiles contain no privileged/root flags, host namespace settings, or SYS_ADMIN; CWE-732/CWE-266 not implicated.
No Pii Or Sensitive Data In Logs ✅ Passed No new slog/log/fmt.Print* statements in changed files; only benign echo messages and config templates. No CWE-532 exposure found.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@helmfile/observability.yaml.gotmpl`:
- Around line 33-42: Gate the kube-prometheus-stack release in the Helmfile
template using the observability enablement flag, so it is rendered only when
OBSERVABILITY_ENABLED is exactly "true"; otherwise omit the release or fail
closed. Update the release definition under kube-prometheus-stack without
changing its existing chart, version, namespace, or values.
- Around line 28-37: Enable provenance verification for the
kube-prometheus-stack release by configuring Helm chart signature verification
with a trusted keyring and the appropriate verification setting. Keep the
existing chart repository and version pin unless switching this release to a
digest-pinned OCI artifact is required by the project’s available trust
configuration.

In `@helmfile/values/base-kube-prometheus-stack.yaml.gotmpl`:
- Around line 14-16: Update the Prometheus selector configuration in the
kube-prometheus-stack values to restrict discovery to HyperFleet-owned
ServiceMonitors, PodMonitors, and PrometheusRules. Replace the nil-selector
Helm-value overrides with explicit HyperFleet label selectors and an allowlisted
namespace selector, ensuring all three resource types are limited to the
intended namespaces and ownership labels.

In `@Makefile`:
- Around line 312-313: Update the cleanup target around the MONITORING_NAMESPACE
deletion so it never unconditionally removes a caller-selected namespace.
Require and validate a dedicated target-owned namespace, verify its ownership
label with kubectl before deletion, and skip namespace deletion when the label
is absent or does not match; retain secret cleanup without affecting unrelated
resources.
- Around line 291-292: Remove the hardcoded default from GRAFANA_ADMIN_PASSWORD
in the Makefile. Require the password to be supplied through approved secure
input or secret-manager integration, and fail closed when it is absent; keep
GRAFANA_ADMIN_USER unchanged.
- Around line 301-306: Validate and safely quote all external configuration at
each interpreter boundary: in Makefile lines 301-306, pass validated shell
variables with safe quoting and avoid placing passwords directly in command
arguments; in Makefile lines 311-313, quote HELMFILE_ENV and
MONITORING_NAMESPACE and validate the namespace before deletion; in Makefile
lines 443-448, quote MONITORING_NAMESPACE in status commands; and in
helmfile/observability.yaml.gotmpl lines 10-11, DNS-1123-validate and quote
MONITORING_NAMESPACE before rendering YAML.
- Line 311: Update the kube-prometheus-stack teardown command in the Makefile to
pass Helmfile’s --skip-charts option, ensuring destroy does not resolve remote
charts or templates while preserving the existing environment and component
selector.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 75388998-65a4-4111-93fe-1b220326b68d

📥 Commits

Reviewing files that changed from the base of the PR and between 8737d30 and 2c2f468.

📒 Files selected for processing (8)
  • Makefile
  • env.gcp
  • env.kind
  • helmfile/observability.yaml.gotmpl
  • helmfile/values/base-adapter.yaml.gotmpl
  • helmfile/values/base-api.yaml.gotmpl
  • helmfile/values/base-kube-prometheus-stack.yaml.gotmpl
  • helmfile/values/base-sentinel.yaml.gotmpl
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)

Comment thread helmfile/observability.yaml.gotmpl Outdated
Comment thread helmfile/observability.yaml.gotmpl
Comment thread helmfile/values/base-kube-prometheus-stack.yaml.gotmpl
Comment thread Makefile Outdated
Comment thread Makefile
Comment thread Makefile

.PHONY: uninstall-grafana
uninstall-grafana: check-kubectl-context ## Uninstall kube-prometheus-stack
helmfile -f $(OBSERVABILITY_HELMFILE) -e $(HELMFILE_ENV) -l component=kube-prometheus-stack destroy

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

git ls-files Makefile
wc -l Makefile
sed -n '280,330p' Makefile

Repository: openshift-hyperfleet/hyperfleet-infra

Length of output: 1950


🌐 Web query:

helmfile destroy skip-charts docs destroy fetch charts templates

💡 Result:

In Helmfile, the --skip-charts flag is available for the destroy command to prevent the command from fetching and templating charts before performing the uninstallation [1][2][3]. By default, when you run helmfile destroy without this flag, Helmfile prepares all releases by fetching their charts and running templates [1][3]. This process can cause the destroy operation to fail if the charts are no longer accessible or if chart dependencies cannot be resolved [4]. To bypass this chart preparation step, you can execute the command with the flag: helmfile destroy --skip-charts When this flag is used, Helmfile proceeds to uninstall and purge the releases defined in your manifest without attempting to fetch or template the associated charts [1][2]. Note that helmfile destroy is designed to uninstall and purge all target releases, effectively running helm uninstall --purge for each [1][5].

Citations:


🏁 Script executed (no clone):

#!/bin/bash
set -euo pipefail
python3 - <<'PY'
import urllib.request, re
url='https://helmfile.readthedocs.io/en/latest/cli/'
print('fetching', url)
data=urllib.request.urlopen(url, timeout=20).read().decode('utf-8', 'replace')
for pat in ['skip-charts', 'destroy', 'fetch charts', 'templates']:
    print('\nPATTERN', pat)
    for m in re.finditer(pat, data, re.I):
        start=max(0, m.start()-200); end=min(len(data), m.end()+300)
        print(data[start:end].replace('\n',' ')[:500])
        break
PY

Length of output: 109


Decouple teardown from remote charts. helmfile destroy still resolves charts/templates here, so a repo outage or upstream chart change can block cleanup and keep this path tied to untrusted remote content (CWE-829/CWE-494). Add --skip-charts, or switch to a local pinned chart cache.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Makefile` at line 311, Update the kube-prometheus-stack teardown command in
the Makefile to pass Helmfile’s --skip-charts option, ensuring destroy does not
resolve remote charts or templates while preserving the existing environment and
component selector.

Sources: Path instructions, MCP tools

Comment thread Makefile Outdated
@Ruclo
Ruclo force-pushed the HYPERFLEET-1362-feat-observability-stack branch from 2c2f468 to ca8e0d5 Compare July 22, 2026 15:18
Add observability helmfile and Makefile targets for deploying kube-prometheus-stack,
gated behind OBSERVABILITY_ENABLED env var to conditionally deploy ServiceMonitors
and PrometheusRules for HyperFleet components.

- Add helmfile/observability.yaml.gotmpl with kube-prometheus-stack release
- Add install-grafana/uninstall-grafana targets, chained into local-up-kind/local-up-gcp
- Add OBSERVABILITY_ENABLED toggle to env.kind and env.gcp
- Enable ServiceMonitors for API, Sentinel, and Adapter when toggle is on
- Enable PrometheusRules for API and Sentinel when toggle is on
- Disable alertmanager and control plane scrapers
- Store Grafana credentials in Kubernetes Secret
- Add monitoring namespace to status target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant