Last active
July 13, 2018 16:23
-
-
Save PsyDebug/c907fe6144d4029fcdfa5a2dce5e8fa0 to your computer and use it in GitHub Desktop.
mysql+PersistentVolume with our data on Kubernetes
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
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: mysql | |
namespace: mysql | |
spec: | |
ports: | |
- port: 3306 | |
selector: | |
app: mysql | |
clusterIP: None | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: mysql | |
namespace: mysql | |
spec: | |
selector: | |
matchLabels: | |
app: mysql | |
strategy: | |
type: Recreate | |
template: | |
metadata: | |
labels: | |
app: mysql | |
spec: | |
volumes: | |
- name: mysql-persistent-storage | |
persistentVolumeClaim: | |
claimName: mysql-pv-claim | |
containers: | |
- image: mariadb:10.0 | |
name: mysql | |
env: | |
- name: MYSQL_ROOT_PASSWORD | |
value: password | |
- name: MYSQL_DATABASE | |
value: mybd | |
- name: MYSQL_USER | |
value: myuser | |
- name: MYSQL_PASSWORD | |
value: mypass | |
ports: | |
- containerPort: 3306 | |
name: mysql | |
volumeMounts: | |
- name: mysql-persistent-storage | |
mountPath: /var/lib/mysql |
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
apiVersion: batch/v1 | |
kind: Job | |
metadata: | |
name: deploymysql | |
namespace: mysql | |
spec: | |
template: | |
spec: | |
volumes: | |
- name: mysql-persistent-storage | |
persistentVolumeClaim: | |
claimName: mysql-pv-claim | |
containers: | |
- name: deploymysql | |
image: alpine | |
command: ["/bin/sh","-c"] | |
args: ["wget -qO- <URL to artifact>.tar.gz | tar xvfz - -C /var/lib/"] | |
volumeMounts: | |
- name: mysql-persistent-storage | |
mountPath: /var/lib/mysql | |
restartPolicy: Never | |
backoffLimit: 1 | |
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
apiVersion: v1 | |
kind: PersistentVolumeClaim | |
metadata: | |
name: mysql-pv-claim | |
namespace: mysql | |
spec: | |
accessModes: | |
- ReadWriteOnce | |
resources: | |
requests: | |
storage: 10Gi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment