어려운 일은 앞에서 다 했으니 이젠 쉬운 일밖에 없다.
MySQL 서버를 만들 때 docker 대비 한 가지 달라진 점은 비밀번호를 평문으로 저장할 수 없다는 점이다.
secret을 통해서 base64 인코딩된 비밀번호를 사용해야 한다.
그 점만 제외하면 다른 것이 없다.
1. MySQL 구축
필자는 기존에 구축한 NFS 기반 PV를 이용해 MySQL을 구축할 것이다.
매니페스트 파일 내용은 다음과 같다.
---
# Secret 생성 (패스워드 base64 인코딩 필요)
apiVersion: v1
kind: Secret
metadata:
name: mysql-secret
namespace: db
type: Opaque
data:
root-password: UGFzc3dvcmQxMjM= # 사용할 PW를 base64로 인코딩해서 넣기
---
# PVC 생성
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pvc
namespace: db
spec:
accessModes:
- ReadWriteMany
storageClassName: nfs-csi
resources:
requests:
storage: 10Gi
---
# Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql-deployment
namespace: db
spec:
selector:
matchLabels:
app: mysql
strategy:
type: Recreate
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:8.0
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-secret
key: root-password
ports:
- containerPort: 3306
volumeMounts:
- name: mysql-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-storage
persistentVolumeClaim:
claimName: mysql-pvc
---
# Service (LoadBalancer)
apiVersion: v1
kind: Service
metadata:
name: mysql-service
namespace: db
spec:
type: LoadBalancer
# loadBalancerIP: 필요하다면 IP 고정
ports:
- port: 3306
targetPort: 3306
selector:
app: mysql
끝이다.
이제 사용하면 된다.
필자는 loadBalancer 형태로 고정 IP를 부여해 사용했지만 당연히 ClusterIP나 NodePort를 사용해도 무방하다.
Interesting points about game integrity! Understanding RTP and RNG is crucial for smart play. Just explored gbets login – seems they prioritize fair gaming too, which is a big plus for any platform. Good read!