This collection deploys, maintains and manages K8S clusters.
- The cluster host(s) must have a compatible CRI installed (Containerd, Podman, etc.)
- The collection
jpclipffel.container
can be used to install and setup a CRI
- The collection
Create an inventory which include the host(s) to use as K8S cluster node(s):
all:
children:
# For MicroK8s cluster:
microk8s:
vars:
# Optional: MicroK8s configuration variables
# jpclipffel_k8s_microk8s_*: ...
hosts:
microk8s-01.tld:
microk8s-02.tld:
# ...
# For vanilla (kubeadm) cluster:
k8s:
vars:
# Optional: K8S cluster configuration variables
# jpclipffel_k8s_k8x_*: ...
children:
k8s_masters:
vars:
jpclipffel_k8s_k8x_node_type: master
hosts:
master-01.tld:
master-02.tld:
# ...
k8s_workers:
vars:
jpclipffel_k8s_k8x_node_type: worker
hosts:
worker-01.tld:
worker-02.tld:
# ...
Clusters setup is done using the following roles and collections:
Resource | Variables name format | Documentation / link |
---|---|---|
microk8s cluster |
jpclipffel_k8s_microk8s_* |
Link |
vanilla cluster |
jpclipffel_k8s_k8x_* |
Link |
Create an Ansible playbook:
# For MicroK8s cluster:
- hosts: microk8s
vars:
jpclipffel_container_containerd_configonly: true
jpclipffel_container_containerd_root_path: "/var/snap/microk8s/current/args"
jpclipffel_container_containerd_config_path: "{{ jpclipffel_container_containerd_root_path }}/containerd-template.toml"
roles:
- jpclipffel.k8s.microk8s # Setup the single-node cluster
- jpclipffel.container.containerd # Setup MicroK8s CRI (Containerd)
# For vanilla (kubeadm) cluster:
- hosts: k8s
roles:
- jpclipffel.container.containerd # Setup the Containerd CRI
- jpclipffel.k8s.k8x # Setup the K8S cluster
Ensure the required collections are installed:
$> ansible-galaxy collection install jpclipffel.k8s
$> ansible-galaxy collection install jpclipffel.container
Run the playbook with the appropriate tag(s) (see next section for available tags):
ansible-playbook -i <your-inventory> <your-playbook.yml> --tags 'tag,tag,...'
- Deploys and maintains a MicroK8s node
- See the role documentation
- Deploys and maintains a vanilla K8S cluster
- See the role documentation