赞
踩
[root@k8s-master pod]# cat multi_pod.yaml apiVersion: v1 kind: Pod metadata: name: multi-pod labels: app: multi-pod spec: containers: - name: nginx image: nginx:latest imagePullPolicy: IfNotPresent ports: - containerPort: 80 hostPort: 80 - name: redis image: redis:latest imagePullPolicy: IfNotPresent ports: - containerPort: 6379 hostPort: 6379
启动:
kubectl apply -f multi_pod.yaml
查看
[root@k8s-master pod]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
multi-pod 2/2 Running 0 5m48s 10.244.1.21 k8s-node1 <none> <none>
到 k8s-node1 节点上查看容器:
[root@k8s-node1 ~]# docker ps|grep multi
7cb321a927ca 7614ae9453d1 "docker-entrypoint.s…" k8s_redis_multi-pod_default_cc4adb3b-7103-4ac6-981f-94d6b2ea9b20_0
4e568d0580d6 f6987c8d6ed5 "/docker-entrypoint.…" k8s_nginx_multi-pod_default_cc4adb3b-7103-4ac6-981f-94d6b2ea9b20_0
940398a790b5 k8s.gcr.io/pause:3.5 "/pause" k8s_POD_multi-pod_default_cc4adb3b-7103-4ac6-981f-94d6b2ea9b20_0
# kubectl exec -it pod_name -c pod_container_name -- bash
[root@k8s-master pod]# kubectl exec -it multi-pod -c redis -- bash
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。