Skip to content

Instantly share code, notes, and snippets.

@vagmi
Created January 16, 2019 20:54
Show Gist options
  • Save vagmi/0f7feacae315610fc5f9b6366a61cab9 to your computer and use it in GitHub Desktop.
Save vagmi/0f7feacae315610fc5f9b6366a61cab9 to your computer and use it in GitHub Desktop.
mysql k8s descriptors
#!/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
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
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