1. **Enable HA Grafana with external PostgreSQL**
Set the autoscaling toggle and non-secret database settings directly in the bundle, and use variables for credentials:
```yaml title="uds-bundle.yaml"
packages:
- name: core
repository: registry.defenseunicorns.com/public/core
ref: x.x.x-upstream
keylessVerification:
certificateIdentityRegexp: ^https://github\.com/defenseunicorns/uds-core/\.github/workflows/publish\.yaml@refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$
certificateOIDCIssuer: https://token.actions.githubusercontent.com
overrides:
grafana:
grafana:
values:
# Enable HorizontalPodAutoscaler
- path: autoscaling.enabled
value: true
uds-grafana-config:
values:
# PostgreSQL port
- path: postgresql.port
value: 5432
# Database name
- path: postgresql.database
value: "grafana"
variables:
# PostgreSQL hostname
- name: GRAFANA_PG_HOST
path: postgresql.host
# Database user
- name: GRAFANA_PG_USER
path: postgresql.user
# Database password
- name: GRAFANA_PG_PASSWORD
path: postgresql.password
sensitive: true
```
```yaml title="uds-config.yaml"
variables:
core:
GRAFANA_PG_HOST: "postgres.example.com"
GRAFANA_PG_USER: "grafana"
GRAFANA_PG_PASSWORD: "your-password"
```
> \[!TIP]
> You can also set variables as environment variables prefixed with `UDS_` (e.g., `UDS_GRAFANA_PG_PASSWORD`) instead of using a config file.
The default HPA configuration when HA is enabled:
| Setting | Default | Override Path |
| ------------------------- | --------------------- | ----------------------------------------------------------- |
| Minimum replicas | 2 | `autoscaling.minReplicas` |
| Maximum replicas | 5 | `autoscaling.maxReplicas` |
| CPU target utilization | 70% | `autoscaling.metrics[0].resource.target.averageUtilization` |
| Memory target utilization | 75% | `autoscaling.metrics[1].resource.target.averageUtilization` |
| Scale-down stabilization | 300 seconds | `autoscaling.behavior.scaleDown.stabilizationWindowSeconds` |
| Scale-down rate | 1 pod per 300 seconds | `autoscaling.behavior.scaleDown.policies[0]` |
2. **Tune Prometheus resources**
Prometheus runs as a single replica in UDS Core. For clusters with many nodes or high cardinality workloads, increase resource allocation to prevent OOM kills and slow queries. See the [Prometheus storage documentation](https://prometheus.io/docs/prometheus/latest/storage/) for guidance on resource needs relative to ingestion volume.
```yaml title="uds-bundle.yaml"
packages:
- name: core
repository: registry.defenseunicorns.com/public/core
ref: x.x.x-upstream
keylessVerification:
certificateIdentityRegexp: ^https://github\.com/defenseunicorns/uds-core/\.github/workflows/publish\.yaml@refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$
certificateOIDCIssuer: https://token.actions.githubusercontent.com
overrides:
kube-prometheus-stack:
kube-prometheus-stack:
values:
# Adjust resource values for your environment
- path: prometheus.prometheusSpec.resources
value:
requests:
cpu: 200m
memory: 1Gi
limits:
cpu: 500m
memory: 4Gi
```
> \[!TIP]
> Use Grafana's built-in Prometheus dashboards to observe actual CPU and memory usage before choosing resource values. Over-provisioning wastes cluster resources; under-provisioning causes OOM kills and metric gaps.
> \[!CAUTION]
> **Multi-replica Prometheus is not tested or recommended at this time with UDS Core.** Scaling beyond a single replica requires an external TSDB backend (e.g., Thanos, Cortex, Mimir, VictoriaMetrics) to handle deduplication, because each replica independently scrapes all targets, producing duplicate data. You would also need to reconfigure Grafana's data source to query the external backend. See the [Prometheus remote storage integrations](https://prometheus.io/docs/operating/integrations/#remote-endpoints-and-storage) for details.
3. **Configure Prometheus storage and retention**
UDS Core provisions a 50Gi PVC with 10-day retention by default. Adjust both settings based on the number of scrape targets, metrics cardinality, and how long you need to keep historical data.
| Setting | Default | Override Path |
| -------------------- | -------- | ------------------------------------------------------------------------------------------- |
| PVC size | 50Gi | `prometheus.prometheusSpec.storageSpec.volumeClaimTemplate.spec.resources.requests.storage` |
| Time-based retention | 10d | `prometheus.prometheusSpec.retention` |
| Size-based retention | Disabled | `prometheus.prometheusSpec.retentionSize` |
```yaml title="uds-bundle.yaml"
packages:
- name: core
repository: registry.defenseunicorns.com/public/core
ref: x.x.x-upstream
keylessVerification:
certificateIdentityRegexp: ^https://github\.com/defenseunicorns/uds-core/\.github/workflows/publish\.yaml@refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$
certificateOIDCIssuer: https://token.actions.githubusercontent.com
overrides:
kube-prometheus-stack:
kube-prometheus-stack:
values:
# Increase PVC size for longer retention
- path: prometheus.prometheusSpec.storageSpec.volumeClaimTemplate.spec.resources.requests.storage
value: "100Gi"
# Keep data for 30 days
- path: prometheus.prometheusSpec.retention
value: "30d"
# Safety cap: drop oldest data if disk usage exceeds this limit
- path: prometheus.prometheusSpec.retentionSize
value: "90GB"
```
> \[!NOTE]
> If you are resizing storage on an existing deployment, follow the [Resize Prometheus PVCs](/core/v1-17/operations/troubleshooting--runbooks/resize-prometheus-pvc/) runbook, because PVC resizing requires additional steps beyond updating your bundle.
To estimate disk needs, use the upstream formula from the [Prometheus storage documentation](https://prometheus.io/docs/prometheus/latest/storage/):
```text
needed_disk_space = retention_time_seconds × ingested_samples_per_second × bytes_per_sample
```
In practice, `bytes_per_sample` averages 1–2 bytes after compression. Start with the defaults, then query `prometheus_tsdb_storage_blocks_bytes` in Grafana to observe actual usage and project growth before resizing.
> \[!TIP]
> Use the `prometheus_tsdb_storage_blocks_bytes` metric in Grafana to monitor actual disk usage over time. This is the most reliable way to right-size your PVC rather than guessing upfront.
> \[!CAUTION]
> If stored data exceeds PVC capacity, Prometheus will crash-loop. Always provision PVC size with headroom above your expected retention volume. `retentionSize` acts as a safety cap: Prometheus drops the oldest blocks when this limit is reached.
4. **Create and deploy your bundle**
```bash
uds create
uds deploy uds-bundle---.tar.zst
```
## Verification
Confirm the monitoring stack is healthy:
```bash
# Check Grafana HPA status
uds zarf tools kubectl get hpa -n grafana
# Confirm multiple Grafana replicas are running
uds zarf tools kubectl get pods -n grafana -l app.kubernetes.io/name=grafana
# Check Prometheus resource allocation
uds zarf tools kubectl get pods -n monitoring -l app.kubernetes.io/name=prometheus -o jsonpath='{.items[0].spec.containers[0].resources}'
# Check Prometheus PVC size and capacity
uds zarf tools kubectl get pvc -n monitoring -l "operator.prometheus.io/name=kube-prometheus-stack-prometheus" -o custom-columns=NAME:.metadata.name,REQ:.spec.resources.requests.storage,CAP:.status.capacity.storage
```
**Success criteria:**
* Grafana HPA shows `MINPODS: 2` and current replicas >= 2
* All Grafana pods are `Running` and `Ready`
* Grafana UI loads and dashboards display data
* Prometheus pod resource limits match your configured values
* Prometheus PVC request matches your configured storage size
## Troubleshooting
### Problem: Grafana pods not starting after enabling HA
**Symptoms:** Pods in `CrashLoopBackOff` or `Error` state, logs show database connection errors.
**Solution:** Verify PostgreSQL connectivity and credentials:
```bash
uds zarf tools kubectl logs -n grafana -l app.kubernetes.io/name=grafana --tail=50
```
Ensure the PostgreSQL instance allows connections from the cluster's CIDR range.
### Problem: Dashboards show "No data" after migrating to HA
**Symptoms:** Grafana UI loads but dashboards display no data points.
**Solution:** Dashboard definitions are stored in ConfigMaps and will load automatically. If data sources are missing, check that the Grafana PostgreSQL database was initialized correctly. The Grafana migration should run automatically on first startup with the new database.
### Problem: Prometheus pod crash-looping with storage errors
**Symptoms:** Pod in `CrashLoopBackOff`, logs show `no space left on device` or TSDB compaction errors.
**Solution:** Check Prometheus logs and PVC capacity:
```bash
uds zarf tools kubectl logs -n monitoring -l app.kubernetes.io/name=prometheus --tail=50
uds zarf tools kubectl get pvc -n monitoring -l "operator.prometheus.io/name=kube-prometheus-stack-prometheus" -o custom-columns=NAME:.metadata.name,REQ:.spec.resources.requests.storage,CAP:.status.capacity.storage
```
Either lower the `retentionSize` limit to trigger faster data pruning, or expand the PVC using the [Resize Prometheus PVCs](/core/v1-17/operations/troubleshooting--runbooks/resize-prometheus-pvc/) runbook.
## Related documentation
* [Grafana: High Availability Setup](https://grafana.com/docs/grafana/latest/setup-grafana/set-up-for-high-availability/) - configuring Grafana for HA with an external database
* [Grafana: Configure a PostgreSQL Database](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#database) - database backend options for Grafana
* [Prometheus: Storage](https://prometheus.io/docs/prometheus/latest/storage/) - TSDB storage architecture and operational guidance
* [Prometheus: Remote Storage Integrations](https://prometheus.io/docs/operating/integrations/#remote-endpoints-and-storage) - Thanos, Cortex, VictoriaMetrics, and other remote storage options
* [Resize Prometheus PVCs](/core/v1-17/operations/troubleshooting--runbooks/resize-prometheus-pvc/) - runbook for expanding Prometheus storage on a running cluster
* [Configure HA for Logging](/core/v1-17/how-to-guides/high-availability/logging/) - Loki provides the log data that Grafana visualizes and also requires HA configuration.
* [Monitoring & Observability concepts](/core/v1-17/concepts/core-features/monitoring-observability/) - Background on the Prometheus, Grafana, and Alertmanager stack in UDS Core.
-----
# High Availability
> Guides for configuring high availability per component, covering redundancy, autoscaling, and fault tolerance across the UDS Core platform stack.
import { CardGrid, LinkCard } from '@astrojs/starlight/components';
Production deployments of UDS Core need redundancy, autoscaling, and fault tolerance to meet uptime requirements. This section provides per-component guides for configuring high availability across the platform stack.
These guides assume you already have UDS Core deployed and are familiar with [UDS bundle overrides](/core/v1-17/how-to-guides/packaging-applications/overview/). Where relevant, guides also cover how to adjust resource allocations for production workloads. For background on each component, see the [Core Features concepts](/core/v1-17/concepts/core-features/overview/).
## HA capabilities at a glance
| Component | HA Mechanism | External Dependency | Default Behavior |
| -------------------- | ------------------------------ | --------------------------------- | ------------------------ |
| **Keycloak** | HPA (2–5 replicas) | PostgreSQL | Single replica (devMode) |
| **Grafana** | HPA (2–5 replicas) | PostgreSQL | Single replica |
| **Loki** | Multi-replica (SimpleScalable) | S3-compatible storage | 3 replicas per tier |
| **Vector** | DaemonSet | None | One pod per node |
| **Prometheus** | Resource tuning | External TSDB (for multi-replica) | Single replica |
| **Authservice** | HPA (1–3 replicas) | Redis / Valkey | Single replica |
| **Falcosidekick** | Static replicas | None | 2 replicas |
| **Istio (istiod)** | HPA + pod anti-affinity | None | HPA (1–5 replicas) |
| **Istio (gateways)** | HPA | None | HPA (1–5 replicas) |
## Related documentation
These external resources provide foundational Kubernetes and component-specific HA guidance that complements the UDS Core guides below:
* [Kubernetes: Running in multiple zones](https://kubernetes.io/docs/setup/best-practices/multiple-zones/) - distributing workloads across failure domains
* [Kubernetes: Disruptions and PodDisruptionBudgets](https://kubernetes.io/docs/concepts/workloads/pods/disruptions/) - protecting availability during voluntary disruptions
* [Kubernetes: Horizontal Pod Autoscaling](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/) - scaling workloads based on resource utilization
* [EKS Best Practices: Reliability](https://aws.github.io/aws-eks-best-practices/reliability/docs/application/) - AWS-specific resilience patterns
* [AKS Best Practices: Reliability](https://learn.microsoft.com/en-us/azure/aks/best-practices-app-cluster-reliability) - Azure-specific resilience patterns
* [GKE Best Practices: Scalability](https://cloud.google.com/kubernetes-engine/docs/best-practices/scalability) - GCP-specific scaling and HA guidance
## Component guides