brunch

You can make anything
by writing

C.S.Lewis

by Master Seo Apr 17. 2023

8. nhn클라우드- nks -Wordpress

추가 테스트 필요


Wordpress - mysql DB 블로그

https://kubernetes.io/ko/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/



<1>  NFS 사용을 위한 설정

<2>  PV(NFS) 2개 생성

<3>  kustomization.yaml 생성 

<4> 접속 → 첫글 써보기

<5> 삭제

<6> 정리



<1>  NFS 사용을 위한 설정


kubectl create namespace wordpress

k ns wordpress


1

mkdir /nfs4-share

mkdir /nfs4-share2

echo '/nfs4-share *(rw,sync,no_root_squash)' >> /etc/exports

echo '/nfs4-share2 *(rw,sync,no_root_squash)' >> /etc/exports

systemctl restart nfs-server


# nfs 설정 정상 확인

exportfs

exportfs -v


showmount -e 127.0.0.1

ss -tnlp | head -1 ; ss -tnlp | grep 0.0.0.0:2049

yum install install nfs-common -y




<2>  PV(NFS) 2개 생성



1

cat <<EOF | kubectl create -f -

apiVersion: v1

kind: PersistentVolume

metadata:

  name: mysql-nfs-pv

spec:

  capacity:

    storage: 20Gi

  accessModes:

  - ReadWriteOnce          # ReadWriteOnce RWO (1:1 마운트, 읽기 쓰기)

  nfs:

    server: 192.168.254.200 # NFS-Server 의 IP

    path: /nfs4-share       # NFS 저장소

---

apiVersion: v1

kind: PersistentVolume

metadata:

  name: wp-nfs-pv

spec:

  capacity:

    storage: 20Gi

  accessModes:

  - ReadWriteOnce

  nfs:

    server: 192.168.254.200 # NFS-Server 의 IP

    path: /nfs4-share2      # NFS 저장소

EOF



2

nfs 서버를 worker ip 로 해봄.

쿠버네티스의 경우 master node ip 로 테스트 함.


NfsServerIP=10.0.0.20

cat <<EOF | kubectl create -f -

apiVersion: v1

kind: PersistentVolume

metadata:

  name: mysql-nfs-pv

spec:

  capacity:

    storage: 20Gi

  accessModes:

  - ReadWriteOnce

  nfs:

    server: $NfsServerIP

    path: /nfs4-share

---

apiVersion: v1

kind: PersistentVolume

metadata:

  name: wp-nfs-pv

spec:

  capacity:

    storage: 20Gi

  accessModes:

  - ReadWriteOnce

  nfs:

    server: $NfsServerIP

    path: /nfs4-share2

EOF


확인

kubectl get pv -o wide



<3>  kustomization.yaml 생성 


Mysql 파드의 시크릿 생성 정보 추가 → mysql wordpress yaml 다운로드 → 생성

kustomize 는 자주 사용되는 YAML 파일의 속성을 별도로 정의해 재사용하거나 여러 YAML 파일을 하나로 묶는 등 다양한 용도로 사용할 수 있는 기능



MysqlDbPW=qwe123


mkdir yaml && cd yaml


cat <<EOF >./kustomization.yaml

secretGenerator:

- name: mysql-pass

  literals:

  - password=$MysqlDbPW

resources:

  - mysql-deployment.yaml

  - wordpress-deployment.yaml

EOF


curl -LO https://k8s.io/examples/application/wordpress/mysql-deployment.yaml

curl -LO https://k8s.io/examples/application/wordpress/wordpress-deployment.yaml

sed -i 's/type: LoadBalancer/type: NodePort/g' wordpress-deployment.yaml

ls



<4> 접속 → 첫글 써보기




<5> 삭제


삭제

kubectl delete -k ./


kubectl delete pv --all




<6> 정리




감사합니다.



매거진의 이전글 7. nhn클라우드- nks-guestbook
작품 선택
키워드 선택 0 / 3 0
댓글여부
afliean
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari