Created
January 16, 2019 20:54
-
-
Save vagmi/0f7feacae315610fc5f9b6366a61cab9 to your computer and use it in GitHub Desktop.
mysql k8s descriptors
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
#!/bin/bash | |
if [ -z "$DB_PASS" ]; then | |
echo "DB_PASS environment variable unset" | |
exit 1 | |
fi | |
kubectl create secret generic mysql-pass --from-literal=password=$DB_PASS |
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: apps/v1 | |
kind: StatefulSet | |
metadata: | |
name: mysql | |
spec: | |
serviceName: mysql | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: mysql | |
template: | |
metadata: | |
labels: | |
app: mysql | |
spec: | |
containers: | |
- name: mysql | |
image: mariadb:10.1 | |
env: | |
- name: MYSQL_ROOT_PASSWORD | |
valueFrom: | |
secretKeyRef: | |
name: mysql-pass | |
key: password | |
ports: | |
- containerPort: 3306 | |
name: db | |
volumeMounts: | |
- name: data | |
mountPath: /var/lib/mysql | |
volumeClaimTemplates: | |
- metadata: | |
name: data | |
spec: | |
accessModes: ["ReadWriteOnce"] | |
resources: | |
requests: | |
storage: 5Gi | |
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 | |
labels: | |
app: mysql | |
spec: | |
ports: | |
- port: 3306 | |
clusterIP: None | |
selector: | |
app: mysql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment