OpenShift Guide

Day 10 — FinOps & Sustainability

Cost attribution, rightsizing, carbon metrics, and platform decommission

FinOps Foundations on OpenShift

Day 10 closes the loop: after you've built, secured, and scaled the platform, the last discipline is financial accountability. FinOps on OpenShift means making cloud spend visible, attributed, and actionable — connecting infrastructure cost to business value.

Inform

Visibility into current spend by team, namespace, workload. No optimization without measurement first.

Optimize

Rightsizing, idle resource cleanup, spot/preemptible node pools, and scheduled scale-down for dev environments.

Operate

Automated budget alerts, chargeback invoices to cost centers, and continuous efficiency targets baked into team OKRs.

OpenCost — Real-Time Cost Allocation

# Install OpenCost (works with GCP, AWS, Azure, and on-prem)
helm repo add opencost https://opencost.github.io/opencost-helm-chart
helm install opencost opencost/opencost   --namespace opencost   --create-namespace   --set opencost.exporter.cloudProviderApiKey=""   --set opencost.ui.enabled=true

# Annotate namespaces with cost center for attribution
oc annotate namespace team-alpha   "opencost.io/allocation-owner=Engineering"   "opencost.io/cost-center=CC-1042"

# Prometheus query: hourly cost per namespace
sum by (namespace) (
  opencost_namespace_allocation_cost_hourly
)

# Monthly cost per team (30-day window)
sum by (namespace) (
  increase(opencost_namespace_allocation_cost_hourly[720h])
)

Budget Alerts via Alertmanager

- alert: NamespaceBudgetExceeded
  expr: |
    sum by (namespace) (
      increase(opencost_namespace_allocation_cost_hourly[720h])
    ) > on(namespace) group_left()
    kube_namespace_annotations{annotation_budget_monthly_usd!=""}
    * on(namespace) group_left()
    kube_namespace_annotations
    | label_replace(
        kube_namespace_annotations,
        "budget",
        "$1",
        "annotation_budget_monthly_usd",
        "(.*)"
      )
  labels:
    severity: warning
  annotations:
    summary: "Namespace {{ $labels.namespace }} exceeded monthly budget"
    description: "Spent ${{ $value | humanize }} — check OpenCost dashboard"