Kubernetes-部署h5小游戏
启动h5小游戏,使用ConfigMap
# nfs操作
[root@web01 ~]# mkdir -p /data/pvh
[root@web01 ~]# cat /etc/exports
/data/pvh 172.16.1.0/24(rw,sync,no_all_squash)
[root@web01 ~]# systemctl restart nfs
# 放入压缩包解压
[root@web01 pvh]# ll
total 18856
-rw-rw-rw- 1 root root 19304923 Sep 27 20:37 h5_games.zip
[root@web01 pvh]# unzip h5_games.zip
[root@web01 pvh]# cd h5_games/
[root@web01 h5_games]# mv * ..
[root@web01 pvh]# ll
total 18904
drwxr-xr-x 23 root root 4096 Mar 5 2015 ceshi
drwxr-xr-x 42 root root 4096 Mar 5 2015 game
drwxr-xr-x 3 root root 36 Sep 27 20:41 h5_games
-rw-rw-rw- 1 root root 19304923 Sep 27 20:37 h5_games.zip
drwxr-xr-x 2 root root 4096 Mar 5 2015 img
-rwxr-xr-x 1 root root 30312 Mar 5 2015 index.html
drwxrwxr-x 3 root root 40 May 3 2019 __MACOSX
-rwxr-xr-x 1 root root 578 Mar 5 2015 readme.txt
# 直接上资源清单
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-h5
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Recycle
storageClassName: nfs-h5
nfs:
path: /data/pvh
server: 172.16.1.91
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-h5
spec:
resources:
requests:
storage: 3Gi
storageClassName: nfs-h5
accessModes:
- ReadWriteMany
---
apiVersion: v1
kind: ConfigMap
metadata:
name: h5-cm
namespace: default
data:
www.conf: |
server{
listen 80;
server_name www.h5.com;
root /code;
index index.html;
}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-h5
spec:
replicas: 1
selector:
matchLabels:
run: nginx
template:
metadata:
name: nginx-h5
labels:
run: nginx
spec:
volumes:
- name: h5-project
configMap:
name: h5-cm
items:
- key: www.conf
path: www.conf
- name: h5-pv
persistentVolumeClaim:
claimName: pvc-h5
containers:
- name: nginx-pod-www
image: nginx:alpine
volumeMounts:
- name: h5-project
mountPath: /etc/nginx/conf.d/
- name: h5-pv
mountPath: /code
---
apiVersion: v1
kind: Service
metadata:
name: h5-svc
spec:
type: ClusterIP
selector:
run: nginx
ports:
- name: wp-port
protocol: TCP
port: 80
targetPort: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: h5-ingress
spec:
rules:
- host: www.h5.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: h5-svc
port:
number: 80
做解析,浏览器访问