OpenMCF logoOpenMCF

Loading...

Kubernetes Prometheus

Deploys a Prometheus monitoring instance on Kubernetes with configurable resource limits, optional persistent storage for metric data, and optional ingress for external access via a hostname.

What Gets Created

When you deploy a KubernetesPrometheus resource, OpenMCF provisions:

  • Namespace — created only when createNamespace is true
  • Prometheus Deployment — deploys Prometheus with configurable CPU, memory, replica count, and persistence settings
  • Kubernetes Service — exposes Prometheus on port 9090 within the cluster (format: {name}-prometheus)
  • PersistentVolumeClaim — created only when container.persistenceEnabled is true, sized according to container.diskSize, used to retain metric data across pod restarts
  • Ingress — created only when ingress.enabled is true, routes external traffic to Prometheus using the configured hostname

Prerequisites

  • Kubernetes credentials configured via environment variables or OpenMCF provider config
  • A Kubernetes namespace that already exists, or set createNamespace to true
  • A StorageClass available in the cluster if enabling persistence (most managed Kubernetes clusters provide a default)
  • A DNS-managed domain if enabling ingress with a hostname

Quick Start

Create a file prometheus.yaml:

apiVersion: kubernetes.openmcf.org/v1
kind: KubernetesPrometheus
metadata:
  name: my-prometheus
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: my-org
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: dev.KubernetesPrometheus.my-prometheus
spec:
  namespace: monitoring
  createNamespace: true
  container:
    replicas: 1

Deploy:

openmcf apply -f prometheus.yaml

This creates a single-replica Prometheus instance in the monitoring namespace with default resource limits (1000m CPU, 1Gi memory) and persistence disabled.

Configuration Reference

Required Fields

FieldTypeDescriptionValidation
namespacestringKubernetes namespace for the Prometheus deployment. Can reference a KubernetesNamespace resource via valueFrom.Required
containerobjectContainer specification for the Prometheus deployment.Required

Optional Fields

FieldTypeDefaultDescription
targetCluster.clusterKindenum—Kubernetes cluster kind. Valid values: AwsEksCluster, GcpGkeCluster, AzureAksCluster, DigitalOceanKubernetesCluster, CivoKubernetesCluster.
targetCluster.clusterNamestring—Name of the target Kubernetes cluster in the same environment.
createNamespaceboolfalseWhen true, creates the namespace before deploying resources.
container.replicasint321Number of Prometheus pods to deploy.
container.resources.limits.cpustring1000mMaximum CPU allocation for each Prometheus pod.
container.resources.limits.memorystring1GiMaximum memory allocation for each Prometheus pod.
container.resources.requests.cpustring50mMinimum guaranteed CPU for each Prometheus pod.
container.resources.requests.memorystring100MiMinimum guaranteed memory for each Prometheus pod.
container.persistenceEnabledboolfalseEnables persistent storage for Prometheus metric data. When enabled, data is persisted to a PersistentVolumeClaim and restored on pod restart.
container.diskSizestring—Size of the PersistentVolumeClaim attached to each Prometheus pod. Required when persistenceEnabled is true. Must be a valid Kubernetes quantity (e.g., 10Gi, 50Gi). Cannot be modified after creation.
ingress.enabledboolfalseEnables external access to the Prometheus web UI.
ingress.hostnamestring—Full hostname for external access (e.g., prometheus.example.com). Required when ingress.enabled is true.

Examples

Development Prometheus without Persistence

A lightweight Prometheus instance for development with reduced resources and no persistent storage:

apiVersion: kubernetes.openmcf.org/v1
kind: KubernetesPrometheus
metadata:
  name: dev-prometheus
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: my-org
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: dev.KubernetesPrometheus.dev-prometheus
spec:
  namespace: dev-monitoring
  createNamespace: true
  container:
    replicas: 1
    resources:
      limits:
        cpu: "500m"
        memory: "512Mi"
      requests:
        cpu: "100m"
        memory: "128Mi"

Production Prometheus with Persistent Storage

A production Prometheus instance with larger disk allocation, higher resource limits, and data persistence enabled to retain metrics across pod restarts:

apiVersion: kubernetes.openmcf.org/v1
kind: KubernetesPrometheus
metadata:
  name: prod-prometheus
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: my-org
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: prod.KubernetesPrometheus.prod-prometheus
spec:
  namespace: monitoring
  container:
    replicas: 2
    resources:
      limits:
        cpu: "2000m"
        memory: "4Gi"
      requests:
        cpu: "500m"
        memory: "1Gi"
    persistenceEnabled: true
    diskSize: "50Gi"

Prometheus with External Access

Prometheus exposed outside the cluster via ingress for access from a web browser:

apiVersion: kubernetes.openmcf.org/v1
kind: KubernetesPrometheus
metadata:
  name: shared-prometheus
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: my-org
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: prod.KubernetesPrometheus.shared-prometheus
spec:
  namespace: monitoring
  container:
    replicas: 2
    resources:
      limits:
        cpu: "2000m"
        memory: "4Gi"
      requests:
        cpu: "500m"
        memory: "1Gi"
    persistenceEnabled: true
    diskSize: "100Gi"
  ingress:
    enabled: true
    hostname: prometheus.example.com

Using Foreign Key References

Reference an OpenMCF-managed namespace instead of hardcoding the name:

apiVersion: kubernetes.openmcf.org/v1
kind: KubernetesPrometheus
metadata:
  name: metrics
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: my-org
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: prod.KubernetesPrometheus.metrics
spec:
  namespace:
    valueFrom:
      kind: KubernetesNamespace
      name: monitoring-namespace
      field: spec.name
  container:
    replicas: 1
    persistenceEnabled: true
    diskSize: "20Gi"

Stack Outputs

After deployment, the following outputs are available in status.outputs:

OutputTypeDescription
namespacestringKubernetes namespace where Prometheus is deployed
servicestringKubernetes Service name for Prometheus (format: {name}-prometheus)
port_forward_commandstringkubectl port-forward command for local access on port 9090
kube_endpointstringCluster-internal FQDN (e.g., my-prometheus-prometheus.monitoring.svc.cluster.local)
external_hostnamestringPublic hostname for external access, only set when ingress is enabled
internal_hostnamestringInternal hostname for VPC-internal access

Related Components

  • KubernetesNamespace — provides the target namespace via valueFrom reference
  • KubernetesDeployment — application deployments that send metrics to Prometheus
  • KubernetesIngressNginx — ingress controller for routing external traffic to the Prometheus web UI
  • KubernetesExternalDns — manages DNS records for the ingress hostname

Next article

Kubernetes Redis

Kubernetes Redis Deploys a Redis instance on Kubernetes using the Bitnami Helm chart in standalone architecture, with automatic password generation, optional data persistence via PersistentVolumeClaims, and optional external access through a LoadBalancer Service with external-dns integration. What Gets Created When you deploy a KubernetesRedis resource, OpenMCF provisions: Namespace — created only when createNamespace is true Random Password — a 12-character password with mixed case, numbers,...
Read next article
Presets
1 ready-to-deploy configurationView presets →