Autoscaling

Kubernetes dla każdego – sztuka konteneryzacji

Autoscaling

Manualne skalowanie podów

kubectl scale deployment <Name> --replicas=<Number>

Horizontal Pod Autoscaler

HPA - komponent automatycznie skalujący ilość podów dla wskazanych deploymentów bazując na zużyciu CPU lub metrykach

Komponenty którymi może zarządzać HPA:

kubectl get hpa
kubectl autoscale deployment <Name> --cpu-percent=50 --min=1 --max=10
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  annotations:
    autoscaling.alpha.kubernetes.io/conditions: '[{"type":"AbleToScale","status":"True","lastTransitionTime":"2019-11-09T21:36:26Z","reason":"ReadyForNewScale","message":"recommended
      size matches current size"},{"type":"ScalingActive","status":"True","lastTransitionTime":"2019-11-09T21:36:26Z","reason":"ValidMetricFound","message":"the
      HPA was able to successfully calculate a replica count from cpu resource utilization
      (percentage of request)"},{"type":"ScalingLimited","status":"True","lastTransitionTime":"2019-11-10T02:38:48Z","reason":"TooFewReplicas","message":"the
      desired replica count is increasing faster than the maximum scale rate"}]'
    autoscaling.alpha.kubernetes.io/current-metrics: '[{"type":"Resource","resource":{"name":"cpu","currentAverageUtilization":0,"currentAverageValue":"0"}}]'
  creationTimestamp: "2019-11-09T21:36:11Z"
  name: php-apache
  namespace: t9l2
  resourceVersion: "559549"
  selfLink: /apis/autoscaling/v1/namespaces/t9l2/horizontalpodautoscalers/php-apache
  uid: f2d5bfd9-0338-11ea-93fd-12ddb37137f8
spec:
  maxReplicas: 10
  minReplicas: 1
  scaleTargetRef:
    apiVersion: extensions/v1beta1
    kind: Deployment
    name: php-apache
  targetCPUUtilizationPercentage: 50
status:
  currentCPUUtilizationPercentage: 0
  currentReplicas: 1
  desiredReplicas: 1
kubectl get pod -A

Sprawdzić czy jest:

kube-system metrics-server-…

kubectl apply -f depl.yaml
kubectl autoscale deployment web --cpu-percent=30 --min=1 --max=4
apt-get update
apt-get install stress
stress -c 5

Vertical Pod Autoscaler VPA

Składa się z:

Virtual Nodes and Azure Container Instances