Creating Terraform Templates on OpenStack¶
Overview¶
This advanced tutorial will guide you through setting up a Terraform project and deploying virtual machines (VMs) with Docker & lightweight Kubernetes (Rancher K3s).
Goals
Understand how to install software and provision multiple VMs
Understand how Terraform is used to orchestrate VMs together
Ability to create a Terraform deployment for a multi-node JupyterHub
Ability to re-provisioning an already deployed cluster on OpenStack through Terraform
Things we won't cover
Basic management of Kubernetes clusters (that is a different lesson)
All of Terraform's features
Prerequisites¶
-
Basic understanding of OpenStack and Terraform as was covered in the prior lesson
-
Access to an OpenStack cloud (we will use Jetstream2)
-
Terraform installed on your workstation or local machine
Outcomes
By the end of this tutorial, you will
have launched a lightweight Kubernetes (K3s) cluster
know how to modify the size of cluster to scale up and down with more or less resources
started and stopped a JupyterHub using a public Docker image
Updating Terraform Configurations¶
We will re-use our configurations from the Terraform basics lesson
We will update and append the following files:
variables.tf
- we are going to be adding new variables to include specific features related to our K3s and JupyterHub
instances.tf
- we are going to be launching multiple VM flavors to support our cluster. We want the server VM to be large enough to manage all of the JupyterHub worker nodes.
security.tf
- we need to specify all of the new security and networking settings for K3s and JupyterHub
We will create new configuration files for:
k3s.tf
- we will keep our Kubernetes (Rancher) configuration files here
docker.tf
- we will specify the JupyterHub Docker image here
jupyterhub.tf
- we will configure our JupyterHub here
instances.tf
¶
Our new cluster is going to be variably sized, meaning we can re-size or re-scale the number of VMs running in our cluster to account for demand by our users.
k3s.tf
¶
docker.tf
¶
We are going to be using the featured Datascience Latest image from the Project Jupyter team