metrics-server

by HelmForge

Helm chartv1.1.0App 0.9.0Apache-2.0Verified publisher

Kubernetes Metrics Server chart for autoscaling metrics with secure RBAC and k3d-friendly validation controls

About this chart

Metrics Server

Production-oriented Helm chart for Kubernetes Metrics Server using the official registry.k8s.io/metrics-server/metrics-server image. Metrics Server collects CPU and memory usage from kubelets and exposes the aggregated metrics.k8s.io/v1beta1 API used by kubectl top, Horizontal Pod Autoscaler, and Vertical Pod Autoscaler.

Features

  • Official Metrics Server image pinned to v0.9.0.
  • Explicit APIService, ServiceAccount, ClusterRole, ClusterRoleBinding, and delegated-authentication RoleBinding ownership.
  • Typed settings for common kubelet and Metrics Server flags, with metricsServer.extraArgs as a controlled escape hatch.
  • Restricted pod and container security contexts, including non-root execution, dropped capabilities, a read-only root filesystem, and RuntimeDefault seccomp.
  • Optional high availability with replicas, PodDisruptionBudget, topology spread, and host-network-aware rollout behavior.
  • Optional NetworkPolicy, Prometheus Operator ServiceMonitor, dual-stack Service configuration, and hardened Helm readiness test.
  • Guarded rendering when a Kubernetes distribution already owns the APIService or aggregated metrics reader ClusterRole.

Installation

Install from the HTTPS repository:

helm repo add helmforge https://repo.helmforge.dev
helm repo update
helm install metrics-server helmforge/metrics-server \
  --namespace kube-system \
  --create-namespace

Or install from the OCI registry:

helm install metrics-server \
  oci://ghcr.io/helmforgedev/helm/metrics-server \
  --namespace kube-system \
  --create-namespace

The upstream compatibility matrix requires Kubernetes 1.34 or newer for Metrics Server 0.9.x. This chart therefore declares kubeVersion: >=1.34.0-0. Upstream tests the last three Kubernetes minor releases; verify the matrix whenever upgrading Kubernetes or overriding the image tag.

Architecture

Metrics Server watches Kubernetes nodes and pods, connects to each kubelet resource metrics endpoint, and retains a short-lived in-memory view. The Kubernetes API aggregation layer forwards Metrics API requests to the chart Service, which targets the named https container port. The value containerPort also configures the real process listener through --secure-port; service.port remains an independent cluster-facing port.

The main pod needs its ServiceAccount token to watch Kubernetes objects and use delegated authentication. The Helm test pod does not need API access and keeps token automounting disabled. Metrics Server is not a historical monitoring store: it does not persist samples and does not replace Prometheus or another application observability system.

See DESIGN.md for resource ownership, trust boundaries, rollout behavior, known limitations, and non-goals.

Security

The default container runs as a non-root user, drops all Linux capabilities, disables privilege escalation, uses a read-only root filesystem, and applies RuntimeDefault seccomp. The main ServiceAccount token is intentionally mounted because Metrics Server must watch Kubernetes objects and participate in delegated authentication. Review cluster-scoped RBAC, APIService TLS, kubelet trust, and node-network policy as part of the platform security boundary.

Security Scan: metrics-server

FrameworkScore
MITRE + NSA + SOC289.90%

Security posture acceptable. The score is produced by the repository's local Kubescape validation and must be refreshed by CI when rendered resources or security controls change.

Production Example

Use multiple replicas, disruption protection, and topology spread. Replace the example NetworkPolicy CIDRs with the real control-plane and node networks for your platform:

replicaCount: 2

pdb:
  enabled: true
  maxUnavailable: 1
  unhealthyPodEvictionPolicy: AlwaysAllow

topologySpreadConstraints:
  - maxSkew: 1
    topologyKey: kubernetes.io/hostname
    whenUnsatisfiable: DoNotSchedule
    labelSelector:
      matchLabels:
        app.kubernetes.io/name: metrics-server

networkPolicy:
  enabled: true
  ingress:
    apiServerCidrs:
      - 10.0.0.0/24
  egress:
    enabled: true
    kubeletCidrs:
      - 10.0.0.0/16
    apiServerCidrs:
      - 10.0.0.0/24

High availability requires at least two schedulable nodes. Where configurable, enable kube-apiserver aggregator routing so requests are distributed across Metrics Server replicas. Size CPU and memory from cluster node and pod counts, scrape resolution, and observed request latency rather than treating the defaults as universal production capacity.

TLS and Local Cluster Example

Kubelet certificate validation is enabled by default. For production, mount a trusted CA and configure its path:

metricsServer:
  kubelet:
    insecureTLS: false
    certificateAuthority: /etc/kubernetes/pki/kubelet-ca.crt

extraVolumes:
  - name: kubelet-ca
    secret:
      secretName: kubelet-serving-ca

extraVolumeMounts:
  - name: kubelet-ca
    mountPath: /etc/kubernetes/pki
    readOnly: true

Local k3d and kind clusters often use kubelet certificates without address subject alternative names. The following override is suitable for local smoke testing, but it disables kubelet identity verification and should not be copied to production:

metricsServer:
  kubelet:
    insecureTLS: true

The APIService has a separate TLS boundary. Its default apiService.insecureSkipTLSVerify=true supports the self-signed serving certificate generated by Metrics Server. Platforms that inject or manage a trusted serving certificate should set apiService.caBundle and disable the skip option.

Existing Cluster Resources

Some Kubernetes distributions already provide v1beta1.metrics.k8s.io or the system:aggregated-metrics-reader ClusterRole. The chart uses cluster lookups to avoid adopting those platform-owned resources into the Helm release. When a platform owns the complete integration, disable the relevant chart resources deliberately and keep ownership documented:

apiService:
  create: false

rbac:
  create: false

The chart rejects the inconsistent combination in which it manages the APIService but RBAC creation is disabled.

Observability

Enable a ServiceMonitor when Prometheus Operator is already installed:

serviceMonitor:
  enabled: true
  additionalLabels:
    release: prometheus
  interval: 30s
  scrapeTimeout: 10s

This integration exposes Metrics Server's own process metrics. It does not export or retain the application resource metrics returned by the aggregated API. Monitor the APIService Available condition, pod readiness, scrape-error logs, and API request latency alongside process metrics.

Validation

After installation, verify both the direct serving path and the aggregation path:

helm test metrics-server --namespace kube-system
kubectl get apiservice v1beta1.metrics.k8s.io
kubectl wait --for=condition=Available \
  apiservice/v1beta1.metrics.k8s.io --timeout=120s
kubectl top nodes
kubectl top pods --all-namespaces

Metrics samples may take one or more collection intervals to appear after a fresh installation. A ready pod alone does not prove that kubelet scraping or API aggregation works.

Troubleshooting

SymptomInvestigationCorrective action
Metrics API not availableDescribe v1beta1.metrics.k8s.io and inspect Service endpoints.Correct APIService, endpoint, or control-plane-to-Service routing.
Kubelet certificate errorsCompare the node address with certificate SANs and CA trust.Repair certificate issuance or mount the trusted CA; use insecure TLS only for local testing.
HPA reports missing metricsCheck Metrics Server logs, node readiness, and kubelet connectivity.Restore kubelet auth, routing, or runtime resource metrics.
Requests time out with NetworkPolicyConfirm DNS, API server, node CIDRs, and kubelet port rules.Replace example CIDRs with cluster-specific ranges.
Host-network upgrade stallsInspect node count, pod placement, and port conflicts.Keep the chart's host-network-safe rollout or provide a compatible custom strategy.

For deployment prerequisites, security decisions, capacity guidance, and a production checklist, read the production guide.

Main Values

KeyDefaultDescription
image.repositoryregistry.k8s.io/metrics-server/metrics-serverOfficial image repository.
image.tagv0.9.0Pinned Metrics Server image tag.
replicaCount1Deployment replica count.
containerPort10250Secure process listener port.
service.port443Cluster-facing Service and APIService port.
apiService.createtrueCreate v1beta1.metrics.k8s.io.
apiService.caBundle""Trusted backend serving CA bundle.
rbac.createtrueCreate cluster and delegated-authentication RBAC.
metricsServer.metricResolution15sResource collection interval.
metricsServer.kubelet.insecureTLSfalseDisable kubelet TLS verification for local clusters.
hostNetwork.enabledfalseUse the node network namespace.
pdb.enabledfalseCreate a PodDisruptionBudget.
networkPolicy.enabledfalseCreate ingress and optional egress policy.
serviceMonitor.enabledfalseCreate a Prometheus Operator ServiceMonitor.
tests.enabledtrueCreate the Helm readiness test pod.

Documentation

Deploy metrics-server with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has metrics-server on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartmetrics-server is pinned at v1.1.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply