mirror of
https://github.com/MichaelCade/90DaysOfDevOps.git
synced 2025-01-10 07:06:38 +07:00
4ff8c158a9
Signed-off-by: Alistair Hey <alistair@heyal.co.uk>
77 lines
1.5 KiB
YAML
77 lines
1.5 KiB
YAML
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: mysql
|
|
spec:
|
|
ports:
|
|
- port: 3306
|
|
selector:
|
|
app: mysql
|
|
clusterIP: None
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: mysql
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
app: mysql
|
|
strategy:
|
|
type: Recreate
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: mysql
|
|
spec:
|
|
containers:
|
|
- image: mysql:5.6
|
|
name: mysql
|
|
env:
|
|
# Use secret in real usage
|
|
- name: MYSQL_ROOT_PASSWORD
|
|
value: password
|
|
- name: MYSQL_DATABASE
|
|
value: example
|
|
- name: MYSQL_USER
|
|
value: example
|
|
- name: MYSQL_PASSWORD
|
|
value: password
|
|
ports:
|
|
- containerPort: 3306
|
|
name: mysql
|
|
volumeMounts:
|
|
- name: mysql-persistent-storage
|
|
mountPath: /var/lib/mysql
|
|
volumes:
|
|
- name: mysql-persistent-storage
|
|
persistentVolumeClaim:
|
|
claimName: mysql-pv-claim
|
|
---
|
|
apiVersion: v1
|
|
kind: PersistentVolume
|
|
metadata:
|
|
name: mysql-pv-volume
|
|
labels:
|
|
type: local
|
|
spec:
|
|
storageClassName: manual
|
|
capacity:
|
|
storage: 20Gi
|
|
accessModes:
|
|
- ReadWriteOnce
|
|
hostPath:
|
|
path: "/mnt/data"
|
|
---
|
|
apiVersion: v1
|
|
kind: PersistentVolumeClaim
|
|
metadata:
|
|
name: mysql-pv-claim
|
|
spec:
|
|
storageClassName: manual
|
|
accessModes:
|
|
- ReadWriteOnce
|
|
resources:
|
|
requests:
|
|
storage: 10Gi
|
|
# https://kubernetes.io/docs/tasks/run-application/run-single-instance-stateful-application/ |