...
코드 블럭 |
---|
# Node Label 확인 kubectl get nodes --show-labels # Node Label 추가 kubectl label nodes cpw1-k8s svc=web |
2.2 Pod Selector
...
코드 블럭 | ||
---|---|---|
| ||
# yaml 파일을 적용합니다. kubectl apply -f 012.nginx08-volvolume-3hostpath.ymlyaml # 생성된 파드에서 마운트 된 경로의 파일을 확인합니다. kubectl exec -it nginx-vol-3 -- ls -l /usr/share/nginx/html total 4 -rw-r--r-- 1 root root 9 Apr 28 01:17 index.html # 파일 내용을 확인합니다. kubectl exec -it nginx-vol-3 -- cat /usr/share/nginx/html/index.html hihihihi [root@m-k8s vagrant]# kubectl get pod -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES nginx-vol-3 1/1 Running 0 107s 172.16.221.185 w1-k8s <none> <none> [root@m-k8s vagrant]# [root@m-k8s vagrant]# curl 172.16.221.185 hihihihi # node에서 생성한 파일이 pod에 hostpath를 이용해 마운트 된것을 확인 할 수 있습니다. # hostpath의 경우 권한이 다르면 사용할수 없으므로 컨테이너 내 사용자로 권한을 바꾸거나 root사용자로 구동되도록 하여야 합니다. # 실습을 위해 실습환경을 정리합니다. [root@m-k8s vagrant]# kubectl delete -f 012.nginx-vol-3.yml pod "nginx-vol-3" deleted |
...
코드 블럭 |
---|
# nfs-utils 패키지를 설치 합니다 apt install -y nfs-server # nfs 공유로 사용할 폴더를 생성하고 테스트에 사용할 index.html 파일을 생성합니다 mkdir /nfs chmod 777 /nfs echo "hihihi" > /nfs/index.html # nfs공유 설정을 해줍니다. cat <<EOF | tee /etc/exports /nfs *(rw,no_root_squash) EOF # nfs서버 서비스를 실행하고 활성화 합니다. systemctl enable nfs-server --now Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service. # 확인 # 출력값이 없으면 [systemctl restart nfs-server] 실행합니다. [root@w2-k8s ~]# exportfs /nfs w2-k8s # nfs설정이 정상인지 worker1번에서 마운트 하여 테스트 합니다 ssh w1-k8s # 모든 마스터/워커노드에서 nfs 패키지를 설치합니다. yumapt install nfs-utils -ycommon mkdir /nfs mount w2-k8s:/nfs /nfs df -h Filesystem Size Used Avail Use% Mounted on ..... 192.168.1.102:/nfs 38770304 4569856 34200448 12% /nfs ..... [root@w1-k8s /]# ll /nfs total 4 -rw-r--r--. 1 root root 6 Sep 13 12:47 index.html #nfs서버가 정상 작동되는것을 확인 했으니 이제 실습을 진행 합니다. #/nfs 폴더를 umount 해줍니다. umount /nfs 이제 설정이 완료된 nfs볼륨을 이용하여 pod를 생성하여 줍니다 |
...