vpa of k8s resource

Keywords: git github Kubernetes Nginx

Publish a k8s deployment video: https://edu.csdn.net/course/detail/26967

Course Content: Various k8s deployment modes.Includes minikube deployment, kubeadm deployment, kubeasz deployment, rancher deployment, k3s deployment.Includes development test environment deployment k8s and production environment deployment k8s.

Tencent Classroom Connection Address https://ke.qq.com/course/478827?Taid=4373109931462251&tuin=ba64518

Second video release. https://edu.csdn.net/course/detail/27109

Describes the main k8s resource usage configuration and commands.Includes configmap, pod, service, replicaset, namespace, deployment, daemonset, ingress, pv, pvc, sc, role, rolebinding, cluster role, cluster rolebinding, secret, service account, statefulset, job, cronjob, podDisruptionbudget, podSecurityPolicy,networkPolicy,resourceQuota, limitrange, endpoint, event, conponentstatus, node, nodeApiservice, controllerRevision, etc.
--------

vpa

* The full name of VPA, Vertical Pod Autoscaler, is Vertical Pod Autoscaler, which automatically expands and scales the CPU and memory requests based on container resource usage, allowing proper scheduling on nodes to provide the appropriate resources for each Pod.It can either shrink containers that over-request resources or increase the capacity of under-resourced resources whenever they are used.

Deployment:

git clone https://github.com/kubernetes/autoscaler.git

cd vertical-pod-autoscaler/

./hack/vpa-up.sh

VPA has four update strategies:

* Initial: Modify resource requests only when a Pod is created and never later.

* Auto: Default policy that modifies resource requests when a Pod is created and also when a Pod is updated.

Recreate: Like Auto, resource requests are modified when a Pod is created and updated, except that VPA expels the Pod and restarts it with a new recommendation as long as the request value in the Pod is different from the new one.Therefore, this strategy is generally not used, but rather Auto, unless you really need to ensure that the requested value is the latest recommended value.

Off: does not change Pod's resource request, but still sets the recommended value for the resource in VPA.

recommand:

[root@master01 recommend]# cat ./*
apiVersion: autoscaling.k8s.io/v1beta2
kind: VerticalPodAutoscaler
metadata:
  name: my-rec-vpa
spec:
  targetRef:
    apiVersion: "apps/v1"
    kind: Deployment
    name: my-rec-deployment
  updatePolicy:
    updateMode: "Off"
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-rec-deployment
  labels:
    purpose: try-recommend
spec:
  selector:
    matchLabels:
      purpose: try-recommend
  replicas: 2
  template:
    metadata:
      labels:
        purpose: try-recommend
    spec:
      containers:
      - name: my-rec-container
        image: nginx:latest

auto:

[root@master01 try-auto-requests]# cat ./*
apiVersion: autoscaling.k8s.io/v1beta2
kind: VerticalPodAutoscaler
metadata:
  name: my-rec-vpa
spec:
  targetRef:
    apiVersion: "apps/v1"
    kind: Deployment
    name: my-deployment
  updatePolicy:
    updateMode: "Auto"
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
  labels:
    purpose: try-auto-requests
spec:
  replicas: 2
  selector:
    matchLabels:
      purpose: try-auto-requests
  template:
    metadata:
      labels:
        purpose: try-auto-requests
    spec:
      containers:
      - name: my-container
        image: alpine:latest
        resources:
          requests:
            cpu: 100m
            memory: 50Mi
        command: ["/bin/sh"]
        args: ["-c", "while true; do timeout 0.5s yes >/dev/null; sleep 0.5s; done"]

VPA mainly consists of three components:

•Admission Controller

•Recommender

•Updater

 

 

390 original articles published, 382 praised, 3.8 million visits+
His message board follow

Posted by alfieshooter on Mon, 20 Jan 2020 20:02:17 -0800