标签:mat 查看 match cto nta auto min spec data
HPA自动收缩 autoscale 自动调整一个 Deployment, ReplicaSet, 或者 ReplicationController 的副本数量 #创建一个replicaset测试 [root@k8s-m ~]# cat my-replicaset.yaml apiVersion: apps/v1 kind: ReplicaSet metadata: name: myreplicaset namespace: default spec: replicas: 2 selector: matchLabels: test_node: k8s-node1 template: metadata: name: my-replicaset-pod labels: test_node: k8s-node1 spec: containers: - name: my-rep image: nginx ports: - name: http containerPort: 80 resources: requests: cpu: "100m" memory: "64Mi" limits: memory: "64Mi" cpu: "100m" #导入 kubectl apply -f my-replicaset.yaml #查看 [root@k8s-m ~]# kubectl get pod NAME READY STATUS RESTARTS AGE myreplicaset-8prkv 1/1 Running 0 55s myreplicaset-8sbgs 1/1 Running 0 55s #设置自动伸缩 #设置myreplicaset 最少1个,最多10个,cpu资源最多使用40% kubectl autoscale replicaset myreplicaset --min=1 --max=10 --cpu-percent=40 #查看hpa [root@k8s-m ~]# kubectl get hpa NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE myreplicaset ReplicaSet/myreplicaset <unknown>/40% 1 10 0 29s
标签:mat 查看 match cto nta auto min spec data
原文地址:https://www.cnblogs.com/zhangb8042/p/10204984.html