Last active
August 3, 2018 12:05
-
-
Save adolli/43c20ed1677ca77f076858ce0d49ca30 to your computer and use it in GitHub Desktop.
Wordpress+mysql example with persistent storage.
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
kubectl create secret generic mysql --from-literal=password=YOUR_PASSWORD |
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: PersistentVolume | |
metadata: | |
name: nfs-mysql | |
spec: | |
capacity: | |
storage: 10Gi | |
accessModes: | |
- ReadWriteOnce | |
nfs: | |
server: <IP_OF_NFS_SERVER> | |
# Exported path of your NFS server | |
path: "/home/nfs/general/mysql" | |
--- | |
apiVersion: v1 | |
kind: PersistentVolumeClaim | |
metadata: | |
name: mysql-volumeclaim | |
spec: | |
accessModes: | |
- ReadWriteOnce | |
resources: | |
requests: | |
storage: 10Gi | |
volumeName: nfs-mysql | |
--- | |
apiVersion: extensions/v1beta1 | |
kind: Deployment | |
metadata: | |
name: mysql | |
labels: | |
app: mysql | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: mysql | |
template: | |
metadata: | |
labels: | |
app: mysql | |
spec: | |
containers: | |
- image: mysql:5.6 | |
name: mysql | |
env: | |
- name: MYSQL_ROOT_PASSWORD | |
valueFrom: | |
secretKeyRef: | |
name: mysql | |
key: password | |
ports: | |
- containerPort: 3306 | |
name: mysql | |
protocol: TCP | |
volumeMounts: | |
- name: mysql-persistent-storage | |
mountPath: /var/lib/mysql | |
volumes: | |
- name: mysql-persistent-storage | |
persistentVolumeClaim: | |
claimName: mysql-volumeclaim | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: mysql | |
labels: | |
app: mysql | |
spec: | |
type: ClusterIP | |
ports: | |
- port: 3306 | |
selector: | |
app: 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: v1 | |
kind: PersistentVolume | |
metadata: | |
name: nfs-wordpress | |
spec: | |
capacity: | |
storage: 10Gi | |
accessModes: | |
- ReadWriteMany | |
nfs: | |
server: <IP_OF_NFS_SERVER> | |
# Exported path of your NFS server | |
path: "/home/nfs/general/wordpress" | |
--- | |
kind: PersistentVolumeClaim | |
apiVersion: v1 | |
metadata: | |
name: wordpress-volumeclaim | |
spec: | |
accessModes: | |
- ReadWriteMany | |
resources: | |
requests: | |
storage: 10Gi | |
volumeName: nfs-wordpress | |
--- | |
apiVersion: extensions/v1beta1 | |
kind: Deployment | |
metadata: | |
name: wordpress | |
labels: | |
app: wordpress | |
spec: | |
replicas: 2 | |
selector: | |
matchLabels: | |
app: wordpress | |
template: | |
metadata: | |
labels: | |
app: wordpress | |
spec: | |
containers: | |
- image: wordpress | |
name: wordpress | |
env: | |
- name: WORDPRESS_DB_HOST | |
value: mysql:3306 | |
- name: WORDPRESS_DB_PASSWORD | |
valueFrom: | |
secretKeyRef: | |
name: mysql | |
key: password | |
ports: | |
- containerPort: 80 | |
name: wordpress | |
volumeMounts: | |
- name: wordpress-persistent-storage | |
mountPath: /var/www/html | |
volumes: | |
- name: wordpress-persistent-storage | |
persistentVolumeClaim: | |
claimName: wordpress-volumeclaim | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
labels: | |
app: wordpress | |
name: wordpress | |
spec: | |
type: LoadBalancer | |
ports: | |
- port: 80 | |
targetPort: 80 | |
protocol: TCP | |
selector: | |
app: wordpress |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment