---
kind: List
apiVersion: v1
items:
- kind: ReplicationController
apiVersion: v1
metadata:
name: rc-nginx-meta
labels:
name: rc-nginx
spec:
replicas: 1
# 必须跟 template 里面的 labels 匹配
selector:
name: pod-nginx
template:
metadata:
labels:
name: pod-nginx
spec:
containers:
- name: nginx-docker-images
image: nginx:1.10
# 开放端口数组
ports:
- containerPort: 80
protocol: TCP
# 环境变量数组
env:
- name: NGINX_PORT
value: "888"
# 加载卷数组,容器内不存在的路径会被新建
volumeMounts:
- mountPath: /test-pd
name: test-volume
volumes:
- name: test-volume
# 这里用主机路径类型的卷
hostPath:
path: /tmp
- kind: Service
apiVersion: v1
metadata:
name: svc-nginx-meta
labels:
name: svc-nginx
spec:
type: NodePort
ports:
- protocol: TCP
# 集群内端口
port: 80
# 容器端口,对应上面的 containerPort
targetPort: 80
# 在所有 Node 上都开放此端口
nodePort: 32000
selector:
# 匹配 Pod 的标签
name: pod-nginx