- Refer or select one of the examples
- Customize the module by referring to their
variables.tf
- Access the master instance with GoSSM or via AWS console, or by Port Tunneling
:6443
- It is also recommended to use a backend to persist state information. Read here
To run this module, simply
- Select the VPC that you wish to deploy k3s in
- Carve out a subnet of the VPC to deploy this in. Ensure the cidr range is unused by other subnets
- Use
cloudposse/dynamic-subnets
to create new additional subnets. This is a cleaner approach
Refer example.
Refer example.
- Install gossm
- Enter shell with
gossm start
- Optionally for convenience, run
source /usr/bin/aliases
, refer here - Check that kubernetes is running with
kubectl get all --all-namespaces
- Install SSM plugin on your local machine
- Copy the content of
/etc/rancher/k3s/k3s.yaml
to your local path, eg:
gossm cmd -e "cat /etc/rancher/k3s/k3s.yaml"
# after seeing a list of instances,
# hit "space" to select master instance, before hitting "enter"
- Find the instance ID with
gossm start
, look for /i-*/ - Start a tunnel with:
aws ssm start-session \
--target MY_EC2_INSTANCE_ID \
--document-name AWS-StartPortForwardingSession \
--parameters '{"portNumber":["6443"], "localPortNumber":["6443"]}'
- Activate the kubeconfig with
export KUBECONFIG="$(pwd)/k3s.yaml"
- Access the cluster, eg:
kubectl get all -A