部署无状态应用程序及升级

部署无状态应用程序及升级,第1张

deployment-1-14-2.yaml

version: 1.14.2

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 2 # tells deployment to run 2 pods matching the template
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
创建deployment
kubectl apply -f deployment-1-14-2.yaml

kubectl get pod

kubectl get deployment

kubectl get pods -l app=nginx

查看deployment信息
kubectl describe deployment nginx-deployment


升级nginx deployment-1-16-1.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.16.1 # Update the version of nginx from 1.14.2 to 1.16.1
        ports:
        - containerPort: 80
执行
kubectl apply -f deployment-1-16-1.yaml



扩容

2 to 4

deployment-1-16-1.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 4  # 2 to 4
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.16.1 
        ports:
        - containerPort: 80
执行
kubectl apply -f deployment-1-16-1.yaml

官方文档

官网文档

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/757642.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-01
下一篇 2022-05-01

发表评论

登录后才能评论

评论列表(0条)

保存