RKE is a useful tool that help with configuring K8s clusters. In this use case we will deploy a highly available K8s cluster using RKE. We will also use Terraform in order to deploy the required compute resources into AWS.
- Docker
- RKE
- kubectl
- Helm
-
Install Terraform: How to install Terraform
-
Edit the Terraform provider information in order to deploy to AWS. You can use access keys, or you could configure the AWS CLI. Another option is to use an IAM role.
-
Run the following to initiate the terraform deployment
terraform init
terraform apply
-
SSH into the master node using its public IP
-
Edit the
rancher-cluster.yml
and update the IP addresses of the nodes. Also, update the path to your SSH private key (How to create SSH key pairs) for authentication between the nodes.
nodes:
- address: <Node01 IP Address>
user: ubuntu
role: [controlplane,etcd,worker]
ssh_key_path: /path/to/privatekey.pem
- address: <Node02 IP Address>
user: ubuntu
role: [controlplane,etcd,worker]
ssh_key_path: /path/to/privatekey.pemm
- address: <Node03 IP Address>
user: ubuntu
role: [controlplane,etcd,worker]
ssh_key_path: /path/to/privatekey.pem
addon_job_timeout: 120
- Run the up command to initiate the creation of the cluster
rke up config rancher-cluster.yml
You will then see the following output. This output indecates that the setup has started and that the tunnels to the hosts have been created. Using the SSH key pair fro the previous step.
After a few moments you will get a success output:
- Create a symbolic link and export path to the kubeconfig
mkdir -p /home/ubuntu/.kube
ln -s /home/ubuntu/kube_config_rancher-cluster.yml /home/ubuntu/.kube/config
export KUBECONFIG=/home/ubuntu/kube_config_rancher-cluster.yml
- Check that the cluster is running properly
kubectl get nodes
This should give you the running nodes in the cluster