Comprendre l'autoscaling vertical des pods dans Kubernetes

Et pourquoi vous ne devriez pas l'utiliser en mode automatique









(Vertical Pod Autoscaling) — Kubernetes, . .

Kubernetes , - . , .







, , , , . , , , , .







Kubernetes , (, , ). . , — .







, , . , , , .







Kubernetes . , . , .







(Vertical Pod Autoscaler, VPA)



VPA , . :







  • VPA .
  • , VPA , , .
  • VPA ( ). , .


— . , , (Max Resource, MR) VPA.







VPA



VPA:







apiVersion: autoscaling.k8s.io/v1beta2
kind: VerticalPodAutoscaler
metadata:
  name: nginx-vpa
spec:
  targetRef:
    apiVersion: "apps/v1"
    kind:       Deployment
    name:       nginx
  updatePolicy:
    updateMode: "On"
  resourcePolicy:
    containerPolicies:
    - containerName: "nginx"
      minAllowed:
        cpu: "250m"
        memory: "100Mi"
      maxAllowed:
        cpu: "2000m"
        memory: "2048Mi"
    - containerName: "istio-proxy"
      mode: "Off"
      
      





, apiVersion



, kind



, metadata



spec



.







spec



targetRef



, , VPA. updatePolicy



, VPA , updateMode



. updateMode



Auto



, , Off



, .







resourcePolicy



containerPolicies



minAllowed



maxAllowed



. , . , Istio InitContainers



.







! -. .









, , .







.







, (Horizontal Pod Autoscaler, HPA), HPA CPU , . , HPA, .







.







, . VPA , , . stateful-, . HPA , VPA.







— 250 MiB.







VPA 250 MiB , . , VPA , .







VPA .







VPA Deployments, StatefulSets, DaemonSets, ReplicaSets .. , . , , .







VPA



VPA — . , .







, Kubernetes Kubectl , Prometheus, Grafana ELK, .







, , . .







VPA , , . - , VPA . , , VPA .







VPA , . , , , .









GKE VPA. GKE VPA .







, , VPA Admission, , , .







, . deployment Nginx c 250 MiB 100m CPU.







$ cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
 labels:
   app: nginx
 name: nginx
spec:
 replicas: 2
 selector:
   matchLabels:
     app: nginx
 strategy: {}
 template:
   metadata:
     labels:
       app: nginx
   spec:
     containers:
     - image: nginx
       name: nginx
       resources:
         requests:
           cpu: 100m
           memory: 250Mi
EOF
      
      





deployment LoadBalancer



.







kubectl expose deployment nginx --type=LoadBalancer --port 80
      
      





, IP .







$ kubectl get svc nginx
NAME    TYPE           CLUSTER-IP   EXTERNAL-IP      PORT(S)        AGE
nginx   LoadBalancer   10.4.1.4     34.121.204.234   80:30750/TCP   46s
      
      





VPA updateMode: "Off"



. , .







$ cat <<EOF | kubectl apply -f
apiVersion: autoscaling.k8s.io/v1beta2
kind: VerticalPodAutoscaler
metadata:
 name: nginx-vpa
spec:
 targetRef:
   apiVersion: "apps/v1"
   kind:       Deployment
   name:       nginx
 updatePolicy:
   updateMode: "Off"
 resourcePolicy:
  containerPolicies:
   - containerName: "nginx"
    minAllowed:
       cpu: "250m"
       memory: "100Mi"
     maxAllowed:
       cpu: "2000m"
       memory: "2048Mi"
EOF
      
      





, , . hey



:







hey -z 300s -c 1000 http://34.121.204.234
      
      





300 1000 — .







, VPA:







kubectl describe vpa nginx-vpa
      
      





VPA, , :













, .







  • (Target): , VPA , . , .
  • (Lower Bound): , . , VPA .
  • (Upper Bound): . , VPA .
  • (Uncapped Target): , VPA.


, , updateMode



Auto



. :







$ cat <<EOF | kubectl apply -f -
apiVersion: autoscaling.k8s.io/v1beta2
kind: VerticalPodAutoscaler
metadata:
 name: nginx-vpa
spec:
 targetRef:
  apiVersion: "apps/v1"
   kind:       Deployment
   name:       nginx
 updatePolicy:
   updateMode: "Auto"
 resourcePolicy:
   containerPolicies:
   - containerName: "nginx"
     minAllowed:
       cpu: "250m"
       memory: "100Mi"
     maxAllowed:
       cpu: "2000m"
       memory: "2048Mi"
EOF
      
      





. , .















— Kubernetes. stateful- . , .







N.B. stateful- Kubernetes .



All Articles