GKE
Kubernetes
Horizontal Pod Autoscaler
kube-controller-manager
configuration

How to change --horizontal-pod-autoscaler-sync-period field in kube-controller-manager to 5sec in gke

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

The short answer is that you cannot set --horizontal-pod-autoscaler-sync-period=5s on Google Kubernetes Engine. In GKE, the control plane is managed by Google, so flags on kube-controller-manager are not directly editable by cluster users.

That means the real task is not "how do I change the flag," but "how do I get faster or more predictable scaling behavior within GKE's constraints." Once you frame it that way, there are workable options.

Why the Flag Is Not Editable in GKE

The Horizontal Pod Autoscaler runs inside kube-controller-manager. On a self-managed cluster, you can change controller-manager flags by editing the control-plane manifest or startup configuration. GKE does not expose that component for direct customization.

In practice, this has two consequences:

  • you cannot log into the managed control plane and patch the controller manifest
  • upgrades or repairs are handled by GKE, so unsupported manual edits would not persist anyway

If you need that exact flag value, the requirement points to a self-managed Kubernetes control plane rather than GKE.

What You Can Do Instead

There are three realistic alternatives.

Tune the HPA Signal

Often the problem is not the 15-second poll interval. The problem is noisy or delayed metrics. You can improve responsiveness by using a more relevant metric and by tuning target values so scale-out happens sooner.

Example HPA using an external metric:

yaml
1apiVersion: autoscaling/v2
2kind: HorizontalPodAutoscaler
3metadata:
4  name: api-hpa
5spec:
6  scaleTargetRef:
7    apiVersion: apps/v1
8    kind: Deployment
9    name: api
10  minReplicas: 2
11  maxReplicas: 20
12  metrics:
13    - type: External
14      external:
15        metric:
16          name: requests_per_second
17        target:
18          type: AverageValue
19          averageValue: "80"
20  behavior:
21    scaleUp:
22      stabilizationWindowSeconds: 0
23      policies:
24        - type: Percent
25          value: 100
26          periodSeconds: 15

This does not change the sync period, but it can make scale-up more aggressive once a high metric is observed.

Use Event-Driven Autoscaling

If you need faster reactions to queue depth, Pub/Sub lag, or custom application signals, KEDA is often a better fit than trying to force HPA polling lower.

yaml
1apiVersion: keda.sh/v1alpha1
2kind: ScaledObject
3metadata:
4  name: worker-scaledobject
5spec:
6  scaleTargetRef:
7    name: worker
8  minReplicaCount: 1
9  maxReplicaCount: 30
10  triggers:
11    - type: cpu
12      metadata:
13        value: "70"

KEDA still works with Kubernetes primitives, but it gives you more flexible triggers than plain resource-based HPA.

Change the Platform Choice

If the requirement is strict because of a benchmark, an internal SLA, or a specialized workload, use a self-managed Kubernetes cluster where you own controller-manager flags. In that environment, the control-plane manifest can include:

yaml
- --horizontal-pod-autoscaler-sync-period=5s

That is valid on self-managed control planes, not on GKE-managed ones.

How to Inspect Current Autoscaling Behavior

Before changing architecture, inspect what the current autoscaler is doing.

bash
kubectl describe hpa api-hpa
kubectl top pods
kubectl get events --sort-by=.lastTimestamp

Those commands answer three useful questions:

  • is the HPA receiving metrics
  • are pods actually resource constrained
  • is scaling blocked by cooldown, quotas, or pending pods

Many "slow HPA" reports turn out to be image pull time, node provisioning delay, startup probes, or metrics lag rather than the controller sync interval itself.

Common Pitfalls

  • Assuming GKE exposes all upstream Kubernetes flags. Managed control planes intentionally hide many of them.
  • Chasing the 5-second sync period when the real bottleneck is pod startup time or Cluster Autoscaler delay.
  • Using CPU as the only metric for workloads that scale on queue length or request latency.
  • Making HPA more aggressive without checking whether nodes can be added quickly enough.
  • Treating a self-managed Kubernetes workaround as if it will apply to GKE. The operational model is different.

Summary

  • You cannot directly change --horizontal-pod-autoscaler-sync-period in GKE.
  • GKE manages kube-controller-manager, so that flag is not user-configurable.
  • Better options are tuning HPA metrics, adjusting scale behavior, or using KEDA.
  • Inspect autoscaling delays before assuming the poll interval is the root cause.
  • If you truly need a custom controller-manager flag, use a self-managed control plane instead of GKE.

Course illustration
Course illustration

All Rights Reserved.