Creating a Cluster via the AWS CLI
In this guide we will create an HA Kubernetes cluster with 3 control plane nodes across 3 availability zones. You should have an existing AWS account and have the AWS CLI installed and configured. If you need more information on AWS specifics, please see the official AWS documentation. To install the dependencies for this tutorial you can use homebrew on macOS or Linux:terraform
or opentofu
please see the example in the contrib repository.
Note: this guide is not a production set up and steps were tested inbash
andzsh
shells.
Create AWS Resources
We will be creating a control plane with 3 Ec2 instances spread across 3 availability zones. It is recommended to not use the default VPC so we will create a new one for this tutorial. Change to your desired region and CIDR block and create a VPC:Make sure your subnet does not overlap with10.244.0.0/16
or10.96.0.0/12
the default pod and services subnets in Kubernetes.
Create the Subnets
Create 3 smaller CIDRs to use for each subnet in different availability zones. Make sure to adjust these CIDRs if you changed the default value from the last command.
Note: If you’re using zsh you need to run setopt KSH_ARRAYS
to have arrays referenced properly.
Official AMI Images
Official AMI image ID can be found in thecloud-images.json
file attached to the Talos release.
If using the official AMIs, you can skip to Creating the Security group
Create your own AMIs
The use of the official Talos AMIs are recommended, but if you wish to build your own AMIs, follow the procedure below.
Create the S3 Bucket
Create the vmimport
Role
In order to create an AMI, ensure that the vmimport
role exists as described in the official AWS documentation.
Note that the role should be associated with the S3 bucket we created above.
Create the Image Snapshot
First, download the AWS image from Image Factory: Copy the RAW disk to S3 and import it as a snapshot:SnapshotTaskDetail.Status
indicates completed
, we can register the image.
Register the Image
Create a Security Group
Note: This is only required for the control plane nodes. For a production environment you would want separate private subnets for worker nodes.
Create a Load Balancer
The load balancer is used for a stable Kubernetes API endpoint.Create the Machine Configuration Files
We will create a machine config patch to use the AWS time servers. You can create additional patches to customize the configuration as needed.Note that the generated configs are too long for AWS userdata field if the--with-examples
and--with-docs
flags are not passed.
Create the EC2 Instances
Note: There is a known issue that prevents Talos from running on T2 instance types. Please use T3 if you need burstable instance types.
Create the Control Plane Nodes
Create the Worker Nodes
For the worker nodes we will create a new launch template with theworker.yaml
machine configuration and create an autoscaling group.
Configure the Load Balancer
Now, using the load balancer target group’s ARN, and the PrivateIpAddress from the controlplane instances that you created :Export the talosconfig
file
Export the talosconfig
file so commands sent to Talos will be authenticated.
Bootstrap etcd
endpoints
(the control plane node to which talosctl
commands are sent) and nodes
(the nodes that the command operates on):
etcd
:
Retrieve the kubeconfig
When the cluster is healthy you can retrieve the admin kubeconfig
by running:
kubectl
commands.