-
-
Save yxw/cd8c3ce7ef94aa5f6ec0792cd850ae88 to your computer and use it in GitHub Desktop.
Sample MySQL deployment to initialize from *.sql file
This file contains hidden or 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
| # Here, I am using a gcePersistentDisk disk to store my init.sql file. | |
| # You can you any Kubernetes volume such as hostPath,nfs etc. | |
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: mysql-init-demo | |
| spec: | |
| selector: | |
| matchLabels: | |
| app: mysql | |
| strategy: | |
| type: Recreate | |
| template: | |
| metadata: | |
| labels: | |
| app: mysql | |
| spec: | |
| containers: | |
| - image: mysql:5.6 | |
| name: mysql | |
| env: | |
| - name: MYSQL_ROOT_PASSWORD | |
| value: password | |
| ports: | |
| - containerPort: 3306 | |
| name: mysql | |
| volumeMounts: | |
| - name: data | |
| mountPath: /var/lib/mysql | |
| - name: init-script | |
| mountPath: /docker-entrypoint-initdb.d # we are mounting init-script volume in this directory. so init.sql file will be available here. | |
| volumes: | |
| - name: data # this volume will be used for database storage. | |
| persistentVolumeClaim: | |
| claimName: mysql-data-pvc | |
| - name: init-script # this volume holds init.sql file. | |
| gcePersistentDisk: | |
| pdName: mysql-dump-storage | |
| fsType: ext4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment