This is example code for how I deploy a cross cloud Kubernetes cluster to my home openstack, ramnode openstack, and digital ocean.
- DIGITALOCEAN_ACCESS_TOKEN - api token to interact with Digital Ocean. Used by
terraform-code/digitalocean.tf
- RAMNODE_USERNAME - ramnode openstack username. Used by
terraform-code/ramnode.tf
- RAMNODE_PASSWORD - ramnode openstack password. Used by
terraform-code/ramnode.tf
- HOME_USERNAME - home openstack username. Used by
terraform-code/home.tf
- HOME_PASSWORD - home openstack password. Used by
terraform-code/home.tf
- ZEROTIER_NETWORK - zerotier network id. Used by
terraform-code/user-data.sh
- CLOUDFLARE_API - cloudflare api token. Used by
ansible/roles/kubernetes/templates/cloudflare-updater.yaml
to be passed to the cloudflare updater pod. - LONGHORN_USERNAME - any username you want to use for basic auth http for longhorn. Used by
ansible/roles/longhorn/templates/longhorn-ingress.yaml
. Basic auth created bybin/longhorn-basic-auth.sh
- LONGHORN_PASSWORD - any password you want to use for basic auth http for longhorn. Used by
ansible/roles/longhorn/templates/longhorn-ingress.yaml
. Basic auth created bybin/longhorn-basic-auth.sh
Then run source test.env
- My personal domain (codywimer.com) is hard coded throughout this project. If replicating, you'll have to change this.
- My home openstack cloud and ramnodes openstack envs are hard coded in
terraform-code/home.tf
andterraform-code/ramnode.tf
make deploy
This will take your ENV's, pass them to terraform and ansible (see bin/deploy.sh
) and do the following:
- Install terraform in this repo
- Run terraform to deploy cloud resources. Instances will be pre-configured via
terraform-code/user-data.sh
and use a Debian 10 cloud image. - Terraform will ouput an ansible inventory to
hosts.cfg
- Ansible will be run to deploy Kubernetes via RKE. It will create the
rke
directory where you will findrke/kube_config_rke-k8s.yaml
to runkubectl
commands after Kubernetes is deployed.
- The
rke
directory contains your kube config file as stated above, a state file rke uses when configuring,rke/rke-k8s.yaml
which is the rke cluster config,rke/auth
which is the Kubernetes secret for http basic auth for Longhorn, therke/configs
directory which has default resources deployed into Kubernetes, and therke/lonhorn
directory which has the Longhorn configs. - The Terraform state file is located at
terraform-code/terraform.tfstate
make destroy