각 노드는 실제 볼륨 관련 작업을 수행하므로 nfs-common 패키지를 설치해야 한다.
apt install -y nfs-common
systemctl disable firewalld --now
setenforce 0
dnf -y install nfs-utils
vi /etc/exports
# 내용 추가
/shared 211.183.3.0/24(rw,sync,no_root_squash)
chmod 777 /shared
systemctl enable nfs-server --now
showmount -e 211.183.3.99
# mypv.yml
apiVersion: v1
kind: PersistentVolume
metadata:
name: mypv
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: nfs1
nfs:
path: /shared
server: 211.183.3.99
# mypvc.yml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mypvc
spec:
resources:
requests:
storage: 1Gi
accessModes:
- ReadWriteOnce
storageClassName: nfs1
# mypod.yml
apiVersion: v1
kind: Pod
metadata:
name: mypod
labels:
app: web
spec:
containers:
- name: myctn
image: nginx
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 250m
memory: 64Mi
ports:
- containerPort: 80
name: http
volumeMounts:
- name: myvol
mountPath: /usr/share/nginx/html
volumes:
- name: myvol
persistentVolumeClaim:
claimName: mypvc
k exec -it mypod -- ls /usr/share/nginx/html
k exec -it mypod -- touch /usr/share/nginx/html/index.html
NFS 서버에서 /shared/index.html 이 존재하는지 확인
k delete pod mypod
k apply -f mypod.yml
curl <mypod IP>
index.html 이 유지되는지 확인 → PV는 그대로이고, PVC 재사용이므로 데이터 보존됨
# myResourceQuota.yml
apiVersion: v1
kind: ResourceQuota
metadata:
name: myresourcequota
spec:
hard:
persistentvolumeclaims: "5"
requests.storage: "3Gi"
k apply -f mypvc1.yml
k apply -f mypvc2.yml
k apply -f mypvc3.yml # 이 시점에서 에러 발생 (3Gi 초과)
ArgoCD 설치 및 초기 설정 (0) | 2025.04.16 |
---|---|
동적 프로비전 (Dynamic Provisioning) (0) | 2025.04.16 |
🧭 NGINX Ingress Controller + Ingress Routing 실습 정리 (0) | 2025.04.15 |
📈 Kubernetes HPA 실습: Horizontal Pod Autoscaler (0) | 2025.04.15 |
🌀 Kubernetes 실습: Blue/Green Deployment (with LoadBalancer Service) (1) | 2025.04.15 |