Author: https://github.com/itwars
Build a Kubernetes cluster using Ansible with k3s. The goal is easily install a Kubernetes cluster on machines running:
- Debian
- Ubuntu
on processor architecture:
- x64
- arm64
- armhf
Deployment environment must have Ansible 2.4.0+ Master and nodes must have passwordless SSH access
Second, edit inventory/k3s-cluster/hosts.ini to match the system information gathered above. For example:
[all:vars]
ansible_connection=ssh
ansible_user=root
ansible_ssh_private_key_file=~/.ssh/id_rsa
[cloud]
k3s-master ansible_host=135.181.192.36
[edge]
k3s-worker-0 ansible_host=95.217.214.198
[k3s]
k3s-master ansible_host=135.181.192.36
k3s-worker-0 ansible_host=95.217.214.198Edit the ansible_user in inventory/k3s-cluster/group_vars/all.yml and set it to your gcp name.
Open port TCP:6443 in the gcp firewall rules.
Start provisioning of the cluster using the following command:
sudo ansible-playbook site.yml -i inventory/k3s-cluster/hosts.ini --key-file ~/.ssh/google_compute_engineTo get access to your Kubernetes cluster just
scp debian@master_ip:~/.kube/config ~/.kube/configUnable to connect to the server error, use commands with this flag (not secure but works for testing): https://stackoverflow.com/questions/46360361/invalid-x509-certificate-for-kubernetes-master
kubectl --insecure-skip-tls-verify