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.yamlapiVersion: 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
官方文档
官网文档
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)