Skip to content

Instantly share code, notes, and snippets.

@thebsdbox
Last active March 10, 2020 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thebsdbox/0ab84fe8de428a4d8a840a83f1da69fc to your computer and use it in GitHub Desktop.
Save thebsdbox/0ab84fe8de428a4d8a840a83f1da69fc to your computer and use it in GitHub Desktop.
Drupal manifest
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-volume-1
labels:
type: local
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /tmp/pv-1
persistentVolumeReclaimPolicy: Recycle
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-volume-2
labels:
type: local
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /tmp/pv-2
persistentVolumeReclaimPolicy: Recycle
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: drupal-claim
labels:
app: drupal
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: drupal
labels:
app: drupal
spec:
strategy:
type: Recreate
selector:
matchLabels:
app: drupal
template:
metadata:
labels:
app: drupal
tier: frontend
spec:
containers:
- image: drupal:latest
name: drupal
ports:
- containerPort: 30080
name: drupal
volumeMounts:
- name: drupal
mountPath: /var/www/html/modules
subPath: modules
- name: drupal
mountPath: /var/www/html/profiles
subPath: profiles
- name: drupal
mountPath: /var/www/html/themes
subPath: themes
volumes:
- name: drupal
persistentVolumeClaim:
claimName: drupal-claim
---
apiVersion: v1
kind: Service
metadata:
name: postgresql
labels:
app: drupal
spec:
ports:
- port: 5432
selector:
app: drupal
tier: postgreSQL
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-claim
labels:
app: postgres
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgresql
labels:
app: postgres
spec:
strategy:
type: Recreate
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
tier: postgreSQL
spec:
containers:
- image: postgres:latest
name: postgresql
env:
- name: POSTGRES_USER
value: drupal
- name: POSTGRES_DB
value: drupal_production
- name: POSTGRES_PASSWORD
value: drupal
ports:
- containerPort: 5432
name: postgresql
volumeMounts:
- name: postgresql
mountPath: /var/lib/postgresql/data
volumes:
- name: postgresql
persistentVolumeClaim:
claimName: postgres-claim
@thebsdbox
Copy link
Author

To deploy:

$ kubectl create -f https://gist.githubusercontent.com/thebsdbox/0ab84fe8de428a4d8a840a83f1da69fc/raw/4013b2376040e4b28c5b5cef9011ba5e48597109/Drupal.yaml
persistentvolume/local-volume-1 created
persistentvolume/local-volume-2 created
persistentvolumeclaim/drupal-claim created
deployment.apps/drupal created
service/postgresql created
persistentvolumeclaim/postgres-claim created
deployment.apps/postgresql created
user@controlPlane01:~/drupal$ k get pods -o wide
NAME                               READY   STATUS              RESTARTS   AGE     IP               NODE             NOMINATED NODE   READINESS GATES
drupal-588fdc7c99-82rl6            1/1     Running             0          4s      172.16.232.21    controlplane02   <none>           <none>
kube-vip-cluster-d889f5cdf-l2vhg   1/1     Running             0          5h37m   192.168.0.72     controlplane03   <none>           <none>
kube-vip-cluster-d889f5cdf-qtvrm   1/1     Running             0          5h37m   192.168.0.71     controlplane02   <none>           <none>
kube-vip-cluster-d889f5cdf-t6djh   0/1     Pending             0          5h37m   <none>           <none>           <none>           <none>
nginx-86c57db685-8bzjg             1/1     Running             0          5h32m   172.16.198.194   controlplane03   <none>           <none>
postgresql-5f6669f9d9-qzmg4        0/1     ContainerCreating   0          4s      <none>           controlplane02   <none>           <none>
recycler-for-local-volume-2        0/1     Completed           0          17s     172.16.232.19    controlplane02   <none>           <none>
user@controlPlane01:~/drupal$ k expose deployment drupal --port=80 --type=LoadBalancer --name=drupal-lb
service/drupal-lb exposed
user@controlPlane01:~/drupal$ k get service | grep drupal-lb
drupal-lb    LoadBalancer   10.96.255.65    192.168.0.84   80:31987/TCP   8s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment