Kubernetes drupal Installation (helm)

by Anish

Posted on Friday January 25, 2019

Referefce

Introduction

This sample chapter extracted from the book, Kubernetes for DevOps .

Get this book on Just $9 or Ask Author for Discount


In this article we will learn how to to setup drupal in kubernetes cluster using helm

Helm: Helm is a tool for managing Kubernetes charts. Charts are packages of pre-configured Kubernetes resources.

  • Lets Begin deploying drupal using helm in kubernetes , if you are new to helm then download and initialize helm as follows
root@kube-master:#  helm init
root@kube-master:# kubectl create serviceaccount --namespace kube-system tiller
root@kube-master:# kubectl create clusterrolebinding tiller-cluster-rule  --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
root@kube-master:#  kubectl patch deploy --namespace kube-system tiller-deploy  -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'
  • Make sure the title-deploy pod is up and running
root@kube-master:/home/ansible# kubectl get pods -n kube-system 
NAME                                  READY     STATUS    RESTARTS   AGE
coredns-78fcdf6894-jvmlb              1/1       Running   0          1h
coredns-78fcdf6894-xstbn              1/1       Running   0          1h
etcd-kube-master                      1/1       Running   0          1h
kube-apiserver-kube-master            1/1       Running   0          1h
kube-controller-manager-kube-master   1/1       Running   0          1h
kube-flannel-ds-5gzn9                 1/1       Running   0          1h
kube-flannel-ds-tlc8j                 1/1       Running   0          1h
kube-proxy-kl4fg                      1/1       Running   0          1h
kube-proxy-krt6n                      1/1       Running   0          1h
kube-scheduler-kube-master            1/1       Running   0          1h
tiller-deploy-85744d9bfb-wh98g        1/1       Running   0          1h
  • Once titler pod is up and running, deploying drupal for this we need to go and create PersistentVolume and PersistentVolumeClaim
PersistentVolume PersistentVolumeClaim Purpose
drupal-mariadb-pv drupal-mariadb-pvc for storing drupal tables
drupal-data-pv drupal-data-pvc for storing druplaa files
drupal-apache-pv helm will create for us Apache files
  • Create drupal-mariadb-pv and drupal-mariadb-pvc
root@kube-master# echo "
apiVersion: v1
kind: PersistentVolume
metadata:
  name: drupal-mariadb-pv
spec:
  capacity: 
    storage: 4Gi
  accessModes:
    - ReadWriteOnce
    - ReadOnlyMany
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: /data/
" | kubectl apply -f -

The drupal-mariadb-pvc


root@kube-master# echo "
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: data-drupal-mariadb-0
spec:
  storageClassName: ""
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
" | kubectl apply -f -
  • create drupal-data-pv and drupal-data-pvc
root@kube-master# echo "
apiVersion: v1
kind: PersistentVolume
metadata:
  name: drupal-data-pv
spec:
  capacity: 
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
    - ReadOnlyMany
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: /data/drupal
" | kubectl apply -f -

The drupal-data-pvc

root@kube-master# echo "
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: drupal-drupal-drupal
spec:
  storageClassName: ""
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
" | kubectl apply -f -
  • Create drupal-apache-pv
root@kube-master# echo "
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: drupal-drupal-drupal
spec:
  storageClassName: ""
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
" | kubectl apply -f -
  • Verify K8 pvc bounded to correct claims
root@kube-master:# kubectl get pvc
NAME                    STATUS    VOLUME              CAPACITY   ACCESS MODES   STORAGECLASS   AGE
data-drupal-mariadb-0   Bound     drupal-mariadb-pv   4Gi        RWO,ROX                       18s
drupal-drupal-drupal    Bound     drupal-data-pv      1Gi        RWO,ROX                       10s
root@kube-master:# kubectl get pv
NAME                CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM                           STORAGECLASS   REASON    AGE
drupal-apache-pv    1Gi        RWO,ROX        Retain           Available                                                            7s
drupal-data-pv      1Gi        RWO,ROX        Retain           Bound       default/drupal-drupal-drupal                             15s
drupal-mariadb-pv   4Gi        RWO,ROX        Retain           Bound       default/data-drupal-mariadb-0                            21s
  • Drupal Installation starts here, this is done through helm the kubernetes package manager,
helm install --set drupalUsername=admin,drupalPassword=mydrupalpassword,mariadb.mariadbRootPassword=secretpassword,persistence.drupal.existingClaim=drupal-drupal-drupal,mariadb.enabled=true,master.persistence.existingClaim=data-drupal-mariadb-0 --name drupal stable/drupal

This will produce lot of useful resource information related to DRUPAL

NAME:   drupal
LAST DEPLOYED: Fri Jan 25 16:25:21 2019
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/Pod(related)
NAME                            READY  STATUS             RESTARTS  AGE
drupal-drupal-7965fbcbb9-kp9v7  0/1    ContainerCreating  0         3s
drupal-mariadb-0                0/1    ContainerCreating  0         3s

==> v1/Secret
NAME            TYPE    DATA  AGE
drupal-mariadb  Opaque  2     3s
drupal-drupal   Opaque  1     3s

==> v1/ConfigMap
NAME                  DATA  AGE
drupal-mariadb        1     3s
drupal-mariadb-tests  1     3s

==> v1/PersistentVolumeClaim
NAME                  STATUS  VOLUME            CAPACITY  ACCESS MODES  STORAGECLASS  AGE
drupal-drupal-apache  Bound   drupal-apache-pv  1Gi       RWO,ROX       3s

==> v1/Service
NAME            TYPE          CLUSTER-IP      EXTERNAL-IP  PORT(S)                     AGE
drupal-mariadb  ClusterIP     10.97.114.226   <none>       3306/TCP                    3s
drupal-drupal   LoadBalancer  10.103.184.148  <pending>    80:31127/TCP,443:31178/TCP  3s

==> v1beta1/Deployment
NAME           DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE
drupal-drupal  1        1        1           0          3s

==> v1beta1/StatefulSet
NAME            DESIRED  CURRENT  AGE
drupal-mariadb  1        1        3s


NOTES:

*******************************************************************
*** PLEASE BE PATIENT: Drupal may take a few minutes to install ***
*******************************************************************

1. Get the Drupal URL:

  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        Watch the status with: 'kubectl get svc --namespace default -w drupal-drupal'

  export SERVICE_IP=$(kubectl get svc --namespace default drupal-drupal --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}")
  echo "Drupal URL: http://$SERVICE_IP/"

2. Login with the following credentials

  echo Username: admin
  echo Password: $(kubectl get secret --namespace default drupal-drupal -o jsonpath="{.data.drupal-password}" | base64 --decode)
  • Once the drupal POD is up and running , your drupal is not ready to use Yet , you have to be patient, depend on your network speed, it will take further 3-4 minutes
root@kube-master:# kubectl get pods
  • To get your drupal admin password run
root@kube-master:# kubectl get secret --namespace default drupal-drupal -o jsonpath="{.data.drupal-password}" | base64 --decode
mydrupalpassword
  • Verify the drupal service is up and running and external-ip column is no more pending
root@kube-master:/home/ansible# kubectl get svc 
NAME             TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
drupal-drupal    LoadBalancer   10.103.184.148   172.16.2.13   80:31127/TCP,443:31178/TCP   3m
drupal-mariadb   ClusterIP      10.97.114.226    <none>        3306/TCP                     3m
kubernetes       ClusterIP      10.96.0.1        <none>        443/TCP                      2d
  • Open the web browser and browse your loadbalancer ip
    enter image description here
  • Happy Helming and since its kubernetes you may encounter some issues, feel free to poke me

Video Demo


Thanku for reading !!! Give a Share for Support


Your Support Matters!

Instead of directly asking for donations, I'm thrilled to offer you all nine of my books for just $9 on leanpub By grabbing this bundle you not only help cover my coffee, beer, and Amazon bills but also play a crucial role in advancing and refining this project. Your contribution is indispensable, and I'm genuinely grateful for your involvement in this journey!

Any private key value that you enter or we generate is not stored on this site, this tool is provided via an HTTPS URL to ensure that private keys cannot be stolen, for extra security run this software on your network, no cloud dependency




python Cryptography Topics
Topics
For Coffee/ Beer/ Amazon Bill and further development of the project Support by Purchasing, The Modern Cryptography CookBook for Just $9 Coupon Price

Kubernetes for DevOps

Hello Dockerfile

Cryptography for Python Developers

Cryptography for JavaScript Developers

Go lang ryptography for Developers

Here