[root@hdss7-200 volume]# showmount -e # 待挂载nfs磁盘
Export list for hdss7-200.host.com:
/tmp/data/volume 10.4.7.0/24
[root@hdss7-200 volume]# hostname > /tmp/data/volume/index.html
[root@hdss7-200 volume]# vim /data/k8s-yaml/base_resource/volume/nfs.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nfs-deploy
namespace: app
labels:
tier: volume
role: nfs
spec:
replicas: 2
selector:
matchLabels:
tier: volume
role: nfs
template:
metadata:
labels:
tier: volume
role: nfs
spec:
containers:
- name: main-container
image: harbor.od.com/public/busybox:v1.31.1
volumeMounts:
- name: web-root
mountPath: /data/web/html
command:
- httpd
args:
- -f
- -h
- "/data/web/html"
volumes:
- name: web-root
nfs:
server: hdss7-200
path: /tmp/data/volume
[root@hdss7-21 ~]# kubectl apply -f http://k8s-yaml.od.com/base_resource/volume/nfs.yaml
deployment.apps/nfs-deploy created
[root@hdss7-21 ~]# kubectl get pods -n app -l role=nfs -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nfs-deploy-8585f6765f-qbkzg 1/1 Running 0 25s 172.7.21.12 hdss7-21.host.com <none> <none>
nfs-deploy-8585f6765f-vhmhs 1/1 Running 0 25s 172.7.22.8 hdss7-22.host.com <none> <none>
[root@hdss7-21 ~]# curl -s 172.7.21.12; curl -s 172.7.22.8
hdss7-200.host.com
hdss7-200.host.com