“Hpa”的版本间的差异
跳到导航
跳到搜索
(→直接命令运行) |
(→直接命令运行) |
||
第55行: | 第55行: | ||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE | NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE | ||
nginx-server ClusterIP 10.233.205.227 <none> 80/TCP 2m26s | nginx-server ClusterIP 10.233.205.227 <none> 80/TCP 2m26s | ||
+ | |||
+ | |||
+ | root@ubuntu-200430-1:~/oct29# while true; do wget -q -o- http://10.233.205.227 > /dev/null; done | ||
+ | |||
+ | |||
+ | |||
+ | root@ubuntu-200430-1:~# kubectl get hpa | ||
+ | NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE | ||
+ | nginx-server Deployment/nginx-server 0%/10% 1 10 2 3m43s | ||
+ | root@ubuntu-200430-1:~# kubectl get po | ||
+ | NAME READY STATUS RESTARTS AGE | ||
+ | debug-pod 2/2 Running 0 27m | ||
+ | debug-podd 2/2 Running 1 (16m ago) 26m | ||
+ | nginx-deployment-574699d69d-ggwl5 1/1 Running 0 35m | ||
+ | nginx-server-67bd9db47f-54bfn 1/1 Running 0 5m25s | ||
+ | nginx-server-67bd9db47f-8g54j 1/1 Running 0 5m25s | ||
+ | nginx-server-67bd9db47f-sw55d 1/1 Running 0 10s | ||
+ | nginx-server-67bd9db47f-wqrqm 1/1 Running 0 10s | ||
2023年10月29日 (日) 14:29的最新版本
==
apiVersion: apps/v1 kind: Deployment metadata: name: mydep spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.25.2-alpine imagePullPolicy: IfNotPresent resources: requests: cpu: 50m root@ubuntu-200470-1:~/hpa# kubectl get pod | grep mydep mydep-759989964c-8gvxv 1/1 Running 0 6m34s mydep-759989964c-8kxnw 1/1 Running 0 6m19s mydep-759989964c-9rbsc 1/1 Running 0 6m34s mydep-759989964c-f8ztl 1/1 Running 0 6m49s mydep-759989964c-tdf5l 1/1 Running 0 20m 停止压力测试后 过一阵 root@ubuntu-200470-1:~/hpa# kubectl get pod | grep mydep mydep-759989964c-tdf5l 1/1 Running 0 41m root@ubuntu-200470-1:~/hpa#
直接命令运行
#还是建议写成yml的 root@ubuntu-200430-1:~/oct29# kubectl expose deployment nginx-server --port=80 service/nginx-server exposed root@ubuntu-200430-1:~/oct29# kubectl autoscale deployment nginx-server --cpu-percent=10 --min=1 --max=10 horizontalpodautoscaler.autoscaling/nginx-server autoscaled root@ubuntu-200430-1:~/oct29# kubectl get hpa NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE nginx-server Deployment/nginx-server 0%/10% 1 10 2 57s root@ubuntu-200430-1:~/oct29# kubectl get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE nginx-server ClusterIP 10.233.205.227 <none> 80/TCP 2m26s root@ubuntu-200430-1:~/oct29# while true; do wget -q -o- http://10.233.205.227 > /dev/null; done root@ubuntu-200430-1:~# kubectl get hpa NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE nginx-server Deployment/nginx-server 0%/10% 1 10 2 3m43s root@ubuntu-200430-1:~# kubectl get po NAME READY STATUS RESTARTS AGE debug-pod 2/2 Running 0 27m debug-podd 2/2 Running 1 (16m ago) 26m nginx-deployment-574699d69d-ggwl5 1/1 Running 0 35m nginx-server-67bd9db47f-54bfn 1/1 Running 0 5m25s nginx-server-67bd9db47f-8g54j 1/1 Running 0 5m25s nginx-server-67bd9db47f-sw55d 1/1 Running 0 10s nginx-server-67bd9db47f-wqrqm 1/1 Running 0 10s