without haste but without rest

MySQL on K8s template 본문

Database/MySQL

MySQL on K8s template

JinungKim 2022. 1. 24. 10:05

MySQL 컨테이너에 영구 볼륨을 요청해서 배포하는 yaml 파일 템플릿

# PVC
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-claim
spec:
  accessModes:
  - ReadWriteOnce
  storageClassName: standard
  resources:
    requests:
      storage: 10Gi
---
#Service
apiVersion: v1
kind: Service
metadata:
  name: mysql-service
spec:
  type: NodePort
  selector:
    app: mysql
  ports:
  - name: mysql
    protocol: TCP
    port: 3306
---
# Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql-deploy
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql
  template:
    metadata:
      labels:
        app: mysql
    spec:
      volumes:
      - name: mysql-claim
        persistentVolumeClaim:
          claimName: mysql-claim
      containers:
      - name: mysql-pod
        image: mysql
        ports:
        - name: edge
          containerPort: 3306
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: jinung
        volumeMounts:
        - name: mysql-claim
          mountPath: /var/lib/mysql
      restartPolicy: Always

 

'Database > MySQL' 카테고리의 다른 글

MySQL 5.7 docker-compose template feat:한글 깨짐  (0) 2022.03.24
MySQL allowPublicKeyRetrieval Option  (0) 2022.02.13
MySQL binary log 출력 예제  (0) 2022.01.05
Comments