Kubernetes HPA - CloudCommandos/JohnChan GitHub Wiki

Horizontal Pod Auto-scaling

Add these two lines into the /etc/kubernetes/manifests/kube-controller-manager.yaml to configure HPA delays:

containers:
  - command:
    - kube-controller-manager
    - --horizontal-pod-autoscaler-downscale-delay=2m0s #Time delay between HPA replica deletion determination
    - --horizontal-pod-autoscaler-upscale-delay=2m0s #Time delay between HPA replica creation determination
    - --address=127.0.0.1
    - --allocate-node-cidrs=true
    ...

Only Deployments/StatefulSets... with resource requests and/or limits configured are applicable for HPA. For example:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx
        name: nginx
        imagePullPolicy: IfNotPresent
        resources:
          requests:
            cpu: "0.1"
          limits:
            cpu: "0.2"
        ports:
        - containerPort: 80
          name: nginx