Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud

1,694 views

Published on

In this presentation I explain using video examples how kubernetes works and how this can be used to host your Drupal 7 or 8 site. There are obviously also gotcha's and I'd like to warn you to not use this in production until you've verified it

Published in: Internet

Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud

  1. 1. Drupal 8 on Kubernetes using Google Cloud ship-shipping ship, shipping shipping ships
  2. 2. 2 Drupal 8 on Kubernetes using Google Cloud Nick Veenhof A lot of credit goes to @tpryan to give all these awesome sessions regarding kubernetes. Please thank him instead of me :)
  3. 3. 3 Who are you?
  4. 4. 4 What is our goal?
  5. 5. 5 Deploying Drupal 8 in a scalable manner, preferring code over infrastructure
  6. 6. 6 Standard LAMP Stack
  7. 7. 7 DB GIT/Apache Video/Images/tmp/…
  8. 8. 8 • Create a server • Linux • Apache • PHP • MySQL • Get starting schema and content on it • Initialize system Fairly Default Process
  9. 9. 9 # Request Machine gcloud compute instances create $(MYSQL_HOSTNAME) --zone $(ZONE) --machine-type "f1-micro" --image-family="debian-8" --image-project="debian-cloud" --tags "http-server","https-server"
 # Install Apache + PHP apt-get update -y apt-get install apache2 php5 curl php5-curl -y
 # Install MySQL and PHP libratries DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server mysql-client php5-mysqlnd php-pear -y
 /etc/init.d/apache2 restart
 … Create a server
  10. 10. 10 3-Tier version of LAMP Stack
  11. 11. 11 • Create an Apache Server • Create a Mysql Server • Create a filesystem server (NFS/…) • Get starting schema on Mysql Server • Get Git repo on Apache server and link sites/default/files to file server • Get files on file server Somewhat Default Process
  12. 12. 12 DB Video/Images/tmp/… Git/Apache
  13. 13. 13 Containerized
  14. 14. FROM php:7.0-apache
 RUN apt-get update && apt-get install -y php5-mysqlnd
 RUN docker-php-ext-install mysqli
 RUN a2enmod rewrite && a2enmod headers && service apache2 restart
 COPY app/ /var/www/html/ EXPOSE 80 FROM ubuntu:xenial RUN apt-get update && apt-get install -y —no-install- recommends netbase nfs-kernel-server && rm -rf /var/lib/apt/ lists/* RUN mkdir -p /exports VOLUME /exports FROM mysql/mysql-server:5.6 ADD sql/load.sql /docker-entrypoint-initdb.d/load.sql EXPOSE 3306 14
  15. 15. docker run --name=3tier_drupal --link 3tier_db:mysql --link 3tier_nfs:nfs -d -p 80:80 3tier_drupal docker run --name=3tier_nfs -d -p 2049:2049 3tier_frontend docker run --name=3tier_db -d -p 3306:3306 3tier_db 15 Startup Scripts
  16. 16. 16 Kubernetes
  17. 17. FROM php:7.0-apache
 RUN apt-get update && apt-get install -y php5-mysqlnd RUN docker-php-ext-install mysqli ADD www /var/www/
 RUN a2enmod rewrite && a2enmod headers && service apache2 restart COPY app/ /var/www/html/ FROM ubuntu:xenial RUN apt-get update && apt-get install -y —no-install- recommends netbase nfs-kernel-server && rm -rf /var/lib/apt/ lists/* RUN mkdir -p /exports VOLUME /exports FROM mysql/mysql-server:5.6
 ADD sql/load.sql /docker-entrypoint-initdb.d/load.sql 
 EXPOSE 3306 17
  18. 18. 18 DB GIT Video/Images/tmp/…
  19. 19. 19 DB Apache Video/Images/tmp/…
  20. 20. 20 DB Apache Video/Images/tmp/…
  21. 21. 21 DB Apache Video/Images/tmp/…
  22. 22. 22 That’s a lot to manage…
  23. 23. 23 Kubernetes Container Orchestration System Open Source Started by Google Contributed to by others Google offers hosted kubernetes
  24. 24. 24 DB - Google Cloud Managed SQL NFS Server - gcr.io/google_containers/volume-nfs:0.8 Apache - wodby/php container images
  25. 25. 25 Demo of the interface
  26. 26. 26 https://youtu.be/LWA7coiMOLg
  27. 27. 27 Setting up the NFS server
  28. 28. 28 Services A Kubernetes Service is an abstraction which defines a logical set of Pods and a policy by which to access them - sometimes called a micro-service.
  29. 29. 29 kind: Service apiVersion: v1 metadata: name: nfs-shared1-server spec: ports: - name: nfs port: 2049 - name: mountd port: 20048 - name: rpcbind port: 111 selector: role: nfs-shared1-server
  30. 30. 30 PersistentVolumeClaim
  31. 31. 31 apiVersion: v1 kind: PersistentVolumeClaim metadata: name: nfs-shared1-200gb annotations: volume.alpha.kubernetes.io/storage-class: standard spec: accessModes: [ "ReadWriteOnce" ] resources: requests: storage: 200Gi
  32. 32. 32 ReplicationController A ReplicationController ensures that a specified number of pod “replicas” are running at any one time.
  33. 33. 33 apiVersion: v1 kind: ReplicationController metadata: name: nfs-shared1-server spec: replicas: 1 selector: role: nfs-shared1-server template: metadata: labels: role: nfs-shared1-server spec: containers: - name: nfs-shared1-server image: gcr.io/google_containers/volume-nfs:0.8 resources: limits: cpu: 0.01 ports: - name: nfs
  34. 34. 34 Setting up the Lamp stack
  35. 35. 35 Services
  36. 36. 36 apiVersion: v1 kind: Service metadata: name: nickveenhofbe labels: site: nickveenhofbe spec: type: LoadBalancer ports: - name: http port: 80 targetPort: 80 protocol: TCP - name: https port: 443 targetPort: 80 protocol: TCP selector: service: nickveenhofbe
  37. 37. 37 PersistentVolume A PersistentVolume (PV) is a piece of networked storage in the cluster that has been provisioned by an administrator.
  38. 38. 38 apiVersion: v1 kind: PersistentVolume metadata: name: nvbenfs labels: site: nickveenhofbe spec: capacity: storage: 10Gi accessModes: - ReadWriteMany nfs: # FIXME: use the right IP server: 10.3.247.140 path: "/nickveenhofbe"
  39. 39. 39 PersistentVolumeClaim
  40. 40. 40 kind: PersistentVolumeClaim apiVersion: v1 metadata: name: nvbenfs labels: site: nickveenhofbe spec: accessModes: - ReadWriteMany resources: requests: storage: 10Gi
  41. 41. 41 Pods/Deployment A pod (as in a pod of whales or pea pod) is a group of one or more containers (such as Docker containers), the shared storage for those containers, and options about how to run the containers. A Deployment provides declarative updates for Pods and ReplicaSets (the next- generation ReplicationController).
  42. 42. 42 Building on the shoulders of giants https://wodby.com/ https://github.com/wodby/drupal-php/ https://github.com/wodby/drupal-nginx
  43. 43. 43 apiVersion: extensions/v1beta1 kind: Deployment metadata: creationTimestamp: null name: nickveenhofbe labels: site: nickveenhofbe spec: replicas: 2 strategy: type: Recreate template: metadata: creationTimestamp: null labels: site: nickveenhofbe service: nickveenhofbe spec: containers: - image: nickveenhof/drupal-docker-with-volume:5.6
  44. 44. 44 A Little Slower? Let’s take a look at that code https://github.com/nickveenhof/drupal-docker-with-volume/blob/master/gcloud_instructions/nickveenhofbe/ pods.yaml
  45. 45. 45 How do we deploy this? Let’s take a look!
  46. 46. 46 https://youtu.be/cBtNz67AAbA
  47. 47. 47 Conclusion?
  48. 48. 48 Industrialisation of hosting services is happening
  49. 49. 49 All in one boxes are a liability
  50. 50. 50 Massive technology shift
  51. 51. 51 1. Servers are a commodity. 2. Managing services is a commodity 3. Do not make the mistake thinking you know better. Caveat: For Drupal, the one massive pain holding us back from going all in with Google Cloud is not having a managed distributed file system like Amazon EFS.
  52. 52. 52 Do it yourselves? https://github.com/nickveenhof/drupal- docker-with-volume
  53. 53. Making Digital Business Easier Want to help transform businesses using the cloud, open platforms and open source? jobs@dropsolid.com
  54. 54. 54 8-9 September 2017 drupalcamp.be
  55. 55. Thank you

×