Created
November 2, 2018 15:46
-
-
Save overdrive3000/5ae84fb118f49a56648c29aa1d6a8beb to your computer and use it in GitHub Desktop.
MySQL with PVC in K8S
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Persisten Volume for database | |
# it should use EBS | |
apiVersion: v1 | |
kind: PersistentVolumeClaim | |
metadata: | |
name: database | |
annotations: | |
volume.beta.kubernetes.io/storage-class: default | |
spec: | |
accessModes: | |
- ReadWriteOnce | |
resources: | |
requests: | |
storage: 10Gi | |
--- | |
# MySQL service and deployment | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: mysql | |
labels: | |
app: mysql | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: mysql | |
strategy: | |
type: Recreate | |
template: | |
metadata: | |
labels: | |
app: mysql | |
spec: | |
containers: | |
- name: database | |
image: mysql:5.7 | |
resources: | |
requests: | |
cpu: 1 | |
memory: 2Gi | |
env: | |
- name: MYSQL_ROOT_PASSWORD | |
valueFrom: | |
secretKeyRef: | |
name: mysql-root-password | |
key: MYSQL_ROOT_PASSWORD | |
livenessProbe: | |
tcpSocket: | |
port: 3306 | |
ports: | |
- containerPort: 3306 | |
volumeMounts: | |
- name: database | |
mountPath: /var/lib/mysql | |
volumes: | |
- name: database | |
persistentVolumeClaim: | |
claimName: database | |
--- | |
# Service | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: mysql | |
spec: | |
ports: | |
- port: 3306 | |
protocol: TCP | |
selector: | |
app: mysql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment