Pod的资源清单
一个简单的pod资源清单
K8S资源清单大集合: http://k8s.driverzeng.com/v1.19/
[root@master01 ~]# vim nginx.yaml
apiVersion: v1 ## K8S资源接口
kind: Pod ## 资源类型
metadata: ## 资源的元数据
name: nginx-pod ## POD名字
namespace: default ## 资源启动在哪个名称空间
spec: ## 容器相关信息
containers: ## 容器信息
- image: nginx:alpine ## 指定容器的镜像
imagePullPolicy: IfNotPresent ## 镜像拉取规则 IfNotPresent:不存在则拉取
name: nginx-containers ## 容器名字
Always:总是拉取镜像,不管当前机器上是否有该镜像都拉取 nginx:latest
Never:从不拉取镜像,需要提前docker pull
IfNotPresent:如果镜像不存在,则拉取
手动写一个双容器 一个ns的 Pod 资源清单
vim nginx.yaml
apiVersion: "v1"
kind: "Namespace"
metadata:
name: nginx
---
apiVersion: v1
kind: Pod
metadata:
name: centos-nginx-pod
namespace: nginx
spec:
containers:
- image: nginx:alpine
imagePullPolicy: IfNotPresent
name: nginx-containers
- image: centos:7
imagePullPolicy: IfNotPresent
name: centos7-containers
command:
- /bin/tail
- -f
- /etc/hosts
### 运行
[root@master ~]# kubectl apply -f nginx.yaml
namespace/lll unchanged
pod/centos-nginx-pod unchanged
# 创建
[root@master ~]# kubectl create -f nginx.yaml
namespace/lll unchanged
pod/centos-nginx-pod unchanged