To reduce development cost, every weekday night we destroy the kubernetes cluster and provision it again the next morning.
The following instructions are divided into:
You should have installed the following tools
Before either destroying or provisioning a kubernetes cluster, take these setup steps.
-
Change to the relevant environment directory (e.g.
infrastructure/environments/non-prod
) -
Source the environment variables
set -a && source .env && set +a
-
Initialize terraform (ensure providers/modules are installed and backend is initialized)
terraform init
First, follow the setup steps above.
Destroying the cluster is now just one step:
terraform destroy --target=module.cluster
This should give a nice message saying well done on a good destruction job: Destruction complete.
First, follow the setup steps above.
-
Provision cluster.
terraform apply --target=module.cluster
-
Update your
~/.kube/config
with credentials for the new cluster, by running this script.../../scripts/create-kubernetes-config.sh
-
Install Istio, Sealed Secrets and ArgoCD (https://github.com/MHRA/deployments)
The cluster is now ready.
We are storing the configuration (manifests) for all the services in the cluster in the deployments repo (https://github.com/MHRA/deployments) so that they are provisioned using GitOps by ArgoCD.