yum install nfs-utils rpcbind
systemctl enable rpcbind --now ; systemctl status rpcbind
systemctl enable nfs-server --now ; systemctl status nfs-server
systemctl enable rpc-statd ; systemctl status rpc-statd
mkdir -p /home/dame/nfs
chmod 777 /home/dame/nfs
cat <<EOF > /etc/exports
/home/dame/nfs 192.168.241.0/24(rw,sync,no_root_squash)
EOF
exportfs -r
exportfs -v
/etc/fstab에 등록
일반적인 방법이기는 하지만 위험성은 nfs를 삭제하고 깜빡하고 fstab 수정을 하지 않을 경우 부팅이 안될수 있으니 위험
/etc/rc.local 등록
rc.local에 마운트 명령어를 등록하면 부팅시 마운트하고 올라온다.
so. 설정이 잘못되어도 부팅시 문제가 되지 않아 nfs 관리로는 안정적이다.
yum install nfs-utils rpcbind
systemctl enable rpcbind --now ; systemctl status rpcbind
nfs 서버가 잘보이는지 확인
showmount -e 192.168.241.101
1./etc/fstab 등록
vim /etc/fstab
192.168.241.101:/home/dame/nfs /nfs nfs4 rw 0 0
2.[추천] /etc/rc.local 등록
rc.local 실행하는 방법
vim /etc/rc.local
mount -t nfs 192.168.241.101:/home/dame/nfs /nfs

good!

Available 상태 아직 pvc와 연결되지 않은 상태이다

Bound 상태 pv와 pvc가 연결된 상태
PV, PVC의 LifeCycle은 총 4가지 형태를 갖고 변화한다.
LifeCycle은 Available → Bound → Released → Bound ... 순으로 반복되며, Released 즉 PVC가 삭제되었을 경우 실제 스토리지에 있는 파일을 어떻게 관리할 것인지에 대한 Reclaiming(재활용) 정책을 결정할 수 있습니다.
PV, PVC의 Reclaiming 정책으로는 다음 세가지를 적용할 수 있다.
Reclaim 정책을 변경하고자 할 경우 아래와 같이 적용이 가능하다
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs-pv
labels:
name: nfs-pv
spec:
capacity:
storage: 1G
accessModes:
- ReadWriteMany
nfs:
server: 192.168.241.101
path: /home/dame/nfs
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nfs-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storages: 1G
selector:
matchLabels:
name: nfs-pv
pod의 Volume mount /data로 설정 했다.
mount를 지정할 경우 pod가 생성되면서 container 내부에 자동으로 디렉토리가 생성된다.
apiVersion: apps/v1
kind: Deployment
metadata:
name: mavel-home
spec:
replicas: 2
strategy:
type: RollingUpdate
maxSurge: 1
maxUnavailable: 0
selector:
matchLabels:
name: marvel
template:
metadata:
labels:
name: marvel
spec:
containers:
- image: smlinux/marvel
name: mavel-container
ports:
- containerPort: 80
volumeMounts:
- name: nfs-app-pvc
mountPath: /data
volumes:
- name: nfs-app-pvc
persistentVolumeClain:
clainName: nfs-pvc
---
apiVersion: v1
kind: Service
metadata;
name: marvel-service
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
name: marvel

worker node에도 nfs-utils를 반드시 설치해준다.
$ yum install nfs-utils
$ systemctl enable rpcbind --now ; systemctl status rpcbind
$ watch kubectl describe pod
##해당 에러가 사라지는지 확인한다.
## 나의 경우 바뀌지 않아서 pod를 삭제 후 재기동 했다.

pod에 접속 후 /data 디렉토리에 aaaa라는 파일 생성

pod2에도 aaaa가 보이는걸 확인할 수 있다.

nfs 서버에도 aaaa가 있는걸 확인할 수 있다.