이번에는 mysql과 wordpress pod을 만들어 연동시켜 서비스 하는 실습을 해보겠다.
Requirement
- mysql 5.7
- wordpress
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/
Example: Deploying WordPress and MySQL with Persistent Volumes
This tutorial shows you how to deploy a WordPress site and a MySQL database using Minikube. Both applications use PersistentVolumes and PersistentVolumeClaims to store data. A PersistentVolume (PV) is a piece of storage in the cluster that has been manuall
kubernetes.io
mysql, wordpress yml 파일 작성
- mysql
apiVersion: v1
kind: Pod
metadata:
name: app-mysql
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:5.7
imagePullPolicy: Never
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: test1234!
- name: MYSQL_DATABASE
value: wordpress
- name: MYSQL_ROOT_HOST
value: "%"
- wordpress
apiVersion: v1
kind: Pod
metadata:
name: word-rep
labels:
app: word
spec:
containers:
- name: word
image: wordpress
env:
- name: WORDPRESS_DB_HOST
value: 10.38.0.1:3306 # mysql이 설치된 워커 노드의 ip
- name: WORDPRESS_DB_NAME
value: wordpress
- name: WORDPRESS_DB_USER
value: root
- name: WORDPRESS_DB_PASSWORD
value: test1234!
ports:
- containerPort: 80
이제 wordpress을 외부로 노출시키면 된다.
kubectl expose pod word-rep --type=NodePort
'Docker, k8s' 카테고리의 다른 글
k8s_ Autoscaling Metric Server(HPA) (0) | 2023.09.18 |
---|---|
k8s_NodePort , Port, TargetPort (0) | 2023.09.17 |
k8s_Volume (1) EmptyDir , hostPath (0) | 2023.09.16 |
k8s_ Ingress nginx (0) | 2023.09.15 |
k8s_helm Prometheus Grafana 연동 (0) | 2023.09.15 |