Skip to main content
This tutorial shows how to install the kube-prometheus-stack on a Kubernetes cluster using Flux v2 components and the Prometheus Community Helm chart. Follow these steps to create the Flux Git source and Kustomization, add a HelmRepository and HelmRelease for the chart, and then expose Prometheus and Grafana for a local demo. This guide follows Flux documentation patterns and includes sample manifests and commands you can adapt.

Flux example commands

The Flux documentation provides example commands to create a Git source and a Kustomization that points to a monitoring path in a Git repository. Use these as a starting point for a GitOps deployment:
These example commands create a Git source and Kustomization in your cluster. Replace the URL, branch, and path with your repository and manifest locations. For more Flux examples and options, see the Flux docs: https://fluxcd.io/docs/.
Below we adapt that flow to install the kube-prometheus-stack by creating a Git source that points to a repository containing the kube-prometheus-stack manifests and then creating a Kustomization pointing to the specific path.

Helm repository and HelmRelease (chart configuration)

The Flux examples typically include a HelmRepository that points to the Prometheus Community Helm charts. Example:
A HelmRelease installs the kube-prometheus-stack chart and configures values. In this demo Alertmanager is disabled and Prometheus retention is set:
Note: when authoring MDX content, avoid placing raw curly-brace snippets inline; keep JSON/YAML examples in fenced code blocks as shown above.

Create Flux Git source and Kustomization

On your workstation (with Flux CLI configured for the target cluster) create the Git source pointing to the repository that contains the kube-prometheus-stack manifests. The following example uses the Flux project’s repo for kube-prometheus-stack:
The exported GitRepository YAML will look like:
Create (export) a Kustomization that points at the monitoring path inside that repository:
Exported Kustomization YAML:
After exporting these manifests, either commit and push them to the Git repository Flux watches or apply them directly with:

What Flux creates (quick summary)

Once Flux reconciles the Kustomization the monitoring namespace is created and the chart manifests are applied. Typical components created by the kube-prometheus-stack include:

Inspect what was created in the monitoring namespace

A sample kubectl -n monitoring get all output soon after install (trimmed for clarity):
You will typically see a Prometheus StatefulSet, node-exporter DaemonSet, and multiple deployments and services for Grafana and state metrics.

Expose Prometheus and Grafana (NodePort for local access)

By default services are created as ClusterIP. For a local demo you can temporarily change Grafana and Prometheus to NodePort so they are accessible from your workstation browser. Warning: exposing monitoring services with NodePort is convenient for demos but not recommended for production. Use Ingress, LoadBalancer, or proper authentication in production.
Exposing Prometheus and Grafana via NodePort is suitable for local testing only. For production, secure these endpoints via ingress/load balancer and enable authentication.
Edit the services:
Change type: ClusterIP to type: NodePort and save. Verify the services:
Open Prometheus at http://localhost:<PROMETHEUS_NODEPORT> (e.g., http://localhost:30753) and Grafana at http://localhost:<GRAFANA_NODEPORT> (e.g., http://localhost:31921) — replace ports with the NodePort values shown on your node.

Grafana credentials

Grafana’s admin password is stored in a Kubernetes Secret. Retrieve and decode it:
Example secret YAML (data fields are base64-encoded):
Decode the password:
Default credentials in this demo:
  • Username: admin
  • Password: prom-operator
Log in to Grafana and explore the preinstalled dashboards (Kubernetes overview, Node metrics, Prometheus overview). Flux-specific dashboards are not included by default.

Prometheus UI — Targets for scraping

Prometheus will be running after the chart install, but you may not immediately see Flux-related targets. Open the Prometheus “Targets” page to view discovered targets and scraping status. If Flux components are not listed, add PodMonitor or ServiceMonitor resources that match Flux component labels so Prometheus can scrape them.
A screenshot of the Prometheus "Targets" page showing multiple serviceMonitors and their endpoints with labels, last scrape times, scrape durations and status indicators. One entry shows a red "DOWN" error for a kube-controller-manager endpoint while others are marked "UP."
If you need to add scraping for Flux, create a PodMonitor or ServiceMonitor that targets the Flux component pods or services and matches the selectors defined in your HelmRelease (or add new selectors).

Grafana dashboards — add Flux dashboards

Grafana displays dashboards installed by the chart. To visualize Flux metrics you must import or provision dashboards that target Flux metrics and the service/PodMonitor labels used for scraping.
A dark-themed Grafana dashboard browse page showing a list of monitoring dashboards (Alertmanager, CoreDNS, Grafana Overview, various Kubernetes dashboards) with tags and search/filter controls. The screenshot displays the sidebar and a scrollable list of dashboard entries.
Next steps:
  • Add a PodMonitor or ServiceMonitor to enable scraping of Flux components.
  • Provision or import Grafana dashboards for Flux metrics.
  • For production exposure, switch from NodePort to Ingress/LoadBalancer and secure access with authentication.

References

That’s all for this lesson — you now have kube-prometheus-stack installed via Flux and can extend scraping and dashboards to monitor Flux components.

Watch Video