apiVersion: apps/v1
kind: Deployment
metadata:
name: zeze-test
spec:
replicas: 1
selector:
matchLabels:
app: zeze-test
template:
metadata:
labels:
app: zeze-test
spec:
# 第1个容器,初始化容器,创建一个html页面
initContainers:
- name: alpine-write
image: alpine
volumeMounts:
- name: zeze-test
mountPath: /data
readOnly: false
command:
- sh
- -c
- " echo 'Hello, www.linuxhub.cn.' > /data/index.html "
# 第 2 个容器,业务容器
containers:
- name: nignx
image: linuxhub/nginx:1.15.5
ports:
- containerPort: 80
volumeMounts:
- name: zeze-test
mountPath: /usr/share/nginx/html
readOnly: true
# 共同挂载使用的卷
volumes:
- name: zeze-test
emptyDir: {}
---
kind: Service
apiVersion: v1
metadata:
name: zeze-test
spec:
selector:
app: zeze-test
ports:
- protocol: TCP
port: 80
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: zeze-test
spec:
rules:
- host: k8s-test.linuxhub.cn
http:
paths:
- backend:
serviceName: zeze-test
servicePort: 80
path: /
$ curl http://k8s-test.linuxhub.cn/index.html 130 ↵
Hello, www.linuxhub.cn.
网友评论