Kubernetes-deployment的创建
因版本原因replicas=3不能用#命令格式: kubectl run deployment名称[参数]#--image指定pod的镜像#--port指定端口# --replicas指定创建pod数量#--namespace指定namespace[ root@master ~]# kubectl run nginx --image=nginx:1.17.1 --port=80 --replica
·
因版本原因replicas=3不能用
#命令格式: kubectl run deployment名称[参数]
#--image指定pod的镜像
#--port指定端口
# --replicas指定创建pod数量
#--namespace指定namespace
[ root@master ~]# kubectl run nginx --image=nginx:1.17.1 --port=80 --replicas=3 -n dev
deployment.apps/nginx created
是因为在K8S v1.18.0以后,–replicas已弃用 ,推荐用 deployment 创建 pods
vim nginx-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
namespace: policy-demo
labels:
app: nginx
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
kubectl apply -f nginx-deployment.yaml
[root@master ~]# kubectl get pod,deployment -n dev -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/nginx-7848d4b86f-96vsj 1/1 Running 0 84s 10.244.1.6 node3 <none> <none>
pod/nginx-7848d4b86f-l6872 1/1 Running 0 84s 10.244.2.10 node2 <none> <none>
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
deployment.apps/nginx 2/2 2 2 85s nginx nginx app=nginx
更多推荐
已为社区贡献2条内容
所有评论(0)