三、deployment资源管理

vim  k8s_nginx_dev.yml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: 10.0.0.11:5000/oldguo/nginx:v2
        ports:
        - containerPort: 80

[root@k8s-m yml]# kubectl create -f k8s_nginx_dev.yml
[root@k8s-m yml]# kubectl get deployment

deployment滚动升级
kubectl set image deployment/nginx nginx=10.0.0.11:5000/oldguo/nginx:v1
kubectl rollout undo deployment/nginx

实现自动pod伸缩
[root@k8s-m yml]# kubectl autoscale deployment nginx --min=2 --max=6 --cpu-percent=80
horizontalpodautoscalers
kubectl get horizontalpodautoscalers
kubectl edit horizontalpodautoscalers nginx

  

posted @ 2020-05-15 16:21  zhuguoqing  阅读(157)  评论(0编辑  收藏  举报