Deploying Drupal 8 onto Google Cloud using Kubernetes
A month ago I received the honour to present at DrupalJam 2017. What a wonderful event! I had been invited to talk about deploying Drupal 8 onto kubernetes, which can be found as a hosted service in Google Cloud.
Our move to Google
Recently, we made the decision at Dropsolid to move from regular virtual machine instances in Gandi towards instances and services in Google Cloud, as we believe that the capabilities of such a cloud provider offer possibilities that are unprecedented. GC is not only offering affordable virtual machines (instances) but also affordable and competitive offerings regarding hosted MySQL. But that’s not all... Since we like our R&D environment and are looking for achieving greater and bigger goals, it is in our interest to see that Google is publishing new AI and data-analysis APIs at a pace that we don’t see anywhere else.
So... Back to the technicalities. I wanted to run an experiment on how I could run Drupal on an infrastructure that did not need any humans behind the wheel, nor any maintenance. I found this in the way of three components:
- Kubernetes as a service
- Pre-built Docker/LXC containers from Wodby, including a webserver stack (PHP, Nginx)
- MySQL as a service
An overview of Kubernetes and the setup can be seen in the following video:
One component that I found to be missing, was a shared filesystem between the two ‘Pods’ (Containers). Drupal relies on user files or images and these should be stored somewhere. We do not want to alter the behaviour of Drupal or get into the application itself, as that introduces risk. Not all the websites that we would like to host, are modifiable.
- We could map the folder to an AWS S3 bucket or Google Cloud Storage bucket, but that would be too slow for our needs. What we actually wanted is a competitor of AWS EFS, but unfortunately Google Cloud did not have this available.
- We can work our way around it by setting up a NFS server or Gluster server in kubernetes, but that drives us away from our initial goal - less maintenance, so we can focus on building awesome experiences, which is the Drupal application.
If you are interested how I did the setup of the NFS, the slides go into deep detail how to set up this NFS cluster. The code is also available at https://github.com/nickveenhof/drupal-docker-with-volume
I recorded a video how this deployment works. Caution, I did speed it up quite a bit.
Now, what is the key take-away from all this? That I moved the particular website back to regular hosting, eg a shared space with a human behind the wheels here at Dropsolid. The reason was that for a single site, the cost outweigh the benefits and even though it is claimed to be fault-tolerant, I had numerous occasions where my pod did not want to recover, since the ‘failed’ one refused to be deleted. This ate up precious CPU space - on a server that barely had enough CPU. This can be solved with throwing more money at it, but that was not the intent.
I also discovered that constraining a pod to a fixed amount of CPU is not very useful when sharing a single server between multiple Drupal sites. Websites can have variable load and for small to medium sites with little traffic it is hard to justify the cost of pre-allocating those resources. I am curious to explore and test the Vertical Pod Autoscaling once they are finished, as this could certainly help applications with burstable workloads.
Having said that, I did learn a lot about what the future could hold. Going towards a system like this gets us really close to the 12-factor app ideology and I am completely in favour of a future like that.
Comments, questions? I'm curious to find out your take on this. Let me know in the comments box below or reach out directly on Twitter via @Nick_vh
Make sure to check out my the slides from this presentation here:
Want to learn how Dropsolid Platform can help your organization increase its customer lifetime value?
Request a free trial now and get started with the Dropsolid Experience Cloud under the guidance of our CTO Nick Veenhof and our customer support teams.