K8s-deployment管理

2019-12-25  本文已影响0人  xuxin2020

Deployment

1.创建yml文件

apiVersion: apps/v1
kind: Deployment
metadata:
    name: nginx
spec:
    replicas: 2
    selector:
      matchLabels:
       app: nginx
    template:
       metadata:
        labels:
          app: nginx
       spec:
         containers:
          - name: nginx
            image: nginx
            ports:
              - containerPort: 80

2.创建
kubectl create -f xx.yml

3.查看

kubectl get deployment

4.滚动升级\回滚

kubectl set image deployment/nginx nginx=nginx:v2
kubectl rollout undo deployment/nginx

HPA

实现自动pod伸缩

kubectl autoscale deployment nginx --min=2 --max=6 --cpu-percent=80

horizontalpodautoscalers

kubectl get horizontalpodautoscalers
kubectl edit horizontalpodautoscalers  nginx

5.删除

kubectl delete deployment ngxin
上一篇 下一篇

猜你喜欢

热点阅读