Drupal manifests for kubernetes deployment.
- Ansible Template Generated Manifests
- Ansible Hosts File Configuration
- Sample Data
- Blazemeter Load Testing
- VMware PKS LoadBalancer
- Tectonic Ingress
- Rolling Deployments
Uses ansible templates to generate Drupal yaml manifests based on configuration information supplied via an ansible inventory file.
In the deployments folder create a sub-folder that matches the name of the deployment/stack name (see the example in the drupal7-example folder).
Run the ansible playbook to generate the Kubernetes YAML deployment manifests:
$ ansible-playbook -i deployments/my-deploy/drupal.conf drupal-template.yml
This will create a set of output manifest files in the deployment package folder that can then be used for deployment to Kubernetes:
From within the deployment package folder package folder apply the generated manifest:
kubectl apply -f drupal.yml
You can then access the drupal site via the NodePort specified, using the load balanced ingress address to the k8s cluster (or any worker node): Eg. http://core-ingress.idstudios.io:30200
Front end proxying and ingress via Traefik, Nginx or Tectonic Ingress is left as an excercise for the user.
Fairly self explanatory, adjust to your environment:
[all:vars]
drupal_stack_name=drupal7
drupal_stack_namespace=web
drupal_docker_image=idstudios/drupal:plain
drupal_nodeport=30200
drupal_domain=drupal-internal.idstudios.io
drupal_files_nfs_server=192.168.1.107
drupal_files_nfs_path="/idstudios-files-drupal-test"
drupal_files_volume_size=10Gi
drupal_db_host=staging-galera-haproxy
drupal_db_name=drupaldb
drupal_db_user=root
drupal_db_password=Fender2000
[template_target]
localhost
[all:vars]
drupal_stack_name=drupal7
drupal_stack_namespace=web
drupal_docker_image=idstudios/drupal:plain
drupal_domain=drupal-nsx.onprem.idstudios.io
drupal_service_port=8000
drupal_files_nfs_server=192.168.1.107
drupal_files_nfs_path="/idstudios-files-drupal-test"
drupal_files_volume_size=10Gi
drupal_db_host=pks-galera-haproxy
drupal_db_name=drupaldb
drupal_db_user=root
drupal_db_password=Fender2000
[template_target]
localhost
This values supplied in this file will generate the resulting manifest using the ansible j2 template.
Note that drupal_domain is the site domain name used for host header routing via the ingress proxy.
The template_target inventory group should always contain localhost as the location of the template generation takes place locally. A future Helm chart will deprecate the use of ansible.
Note that with the new image
drupal_docker_image=idstudios/drupal:plain
you do not need to perform the manual data loads, or unpack the sample image files to the NFS share, the image will take care of this automatically at startup. Replicas has been set to 1 so that the intialization does not enter race, make sure to scale up for load tests.
In the data folder there is a drupadb_sample.sql file that will load a sample drupal data set into a drupaldb database. This can be done by connecting to the NodePort (CoreOS) or Load Balancer (PKS) that exposes the MariaDB:
mysql -h <ingress url> --port <node port> -u <mysql user> -p < drupaldb_sample.sql
Eg.
mysql -h core-ingress.idstudios.io --port 31306 -u root -p < drupaldb_sample.sql
The sample Drupal7 database data is paired with some sample image uploads, that are expected to reside on the shared NFS volume that holds the file uploads (shared among all of the front end instances of Drupal). These sample files are located in the data directory, as drupal_files.tar.gz.
Expand the drupal_files.tar.gz on the host mounted NFS share and then ensure that the deployment configuration references that folder as the shared host mounted NFS share:
In the deployment configuration file, the settings for the NFS mapping are as follows:
drupal_files_nfs_server=<nfs server>
drupal_files_nfs_path="/<nfs path to drupal files folder>"
drupal_files_volume_size=<size of volume allocation> (eg. 10Gi)
Unfortunately this requires the manual step of pre-configuring the sample files on the target NFS share before drupal stack deployment.
A sample VMware PKS LoadBalancer manifest is created that will create a dedicated load balancer exposing drupal_service_port (SSL termination coming soon).
kubectl apply -f drupal-pks-lb.yml
And then check for the assigned IP address:
kubectl get svc
You should see the assigned Drupal LB hosted on the designated drupal_service_port.
A sample Tectonic Ingress manifest is created that will do host header routing for the drupal_domain over port 80 (SSL termination coming soon).
kubectl apply -f drupal-tectonic-ingress.yml
Example Blazemeter scripts are created based on the configured drupal_domain and sample data URLs to exert moderate and heavy load on the drupal stack.
bzt loadtests/med_load.yml
or
bzt loadtests/heavy_load.yml
These can be adjusted and extended as needed and serve as examples.
Simply updating the image to the themed variant is a good way to test rolling deployments. Manually edit the generated drupal.yml file and change the image/tag:
Eg.
containers:
- name: test-drupal
image: idstudios/drupal:themed
And then simply apply the changes:
kubectl apply -f drupal.yml
You can use the idstudios/drupal:themed variant to test a deployment.
The deployment will begin a rolling update, as this is what Deployments do by default in Kubernetes.
Combining the Blazemeter load testing with a rolling deployment really demonstrates what makes Kubernetes so amazing!