All Projects → movd → k0s-ansible

movd / k0s-ansible

Licence: Apache-2.0 license
Create a Kubernetes Cluster using Ansible and the vanilla upstream Kubernetes distro k0s.

Programming Languages

python
139335 projects - #7 most used programming language
Jinja
831 projects
shell
77523 projects

Projects that are alternatives of or similar to k0s-ansible

Kube Aws
[EOL] A command-line tool to declaratively manage Kubernetes clusters on AWS
Stars: ✭ 1,146 (+1946.43%)
Mutual labels:  kubernetes-cluster, high-availability
k8s-lemp
LEMP stack in a Kubernetes cluster
Stars: ✭ 74 (+32.14%)
Mutual labels:  kubernetes-cluster, high-availability
Kubernetes Ansible
🎄ansible多网卡机器上一键部署高可用Kubernetes(systemd)
Stars: ✭ 402 (+617.86%)
Mutual labels:  kubernetes-cluster, high-availability
Kubespray
Deploy a Production Ready Kubernetes Cluster
Stars: ✭ 11,588 (+20592.86%)
Mutual labels:  kubernetes-cluster, high-availability
ansible-role-etcd
Ansible role for installing etcd cluster
Stars: ✭ 38 (-32.14%)
Mutual labels:  playbook, high-availability
Awx Ha Instancegroup
Build AWX clustering on Docker Standalone Installation
Stars: ✭ 106 (+89.29%)
Mutual labels:  playbook, high-availability
multi-master-kubernetes
Multi-master Kubernetes cluster on Exoscale
Stars: ✭ 65 (+16.07%)
Mutual labels:  playbook, kubernetes-cluster
Ansible Role K3s
Ansible role for installing k3s as either a standalone server or HA cluster.
Stars: ✭ 132 (+135.71%)
Mutual labels:  playbook, kubernetes-cluster
Graylog Ansible Role
Ansible role which installs and configures Graylog
Stars: ✭ 173 (+208.93%)
Mutual labels:  playbook
Ansible Playbook Grapher
A command line tool to create a graph representing your Ansible playbook tasks and roles
Stars: ✭ 234 (+317.86%)
Mutual labels:  playbook
Redfish Ansible Module
Ansible modules for Out-Of-Band Controllers using Redfish APIs
Stars: ✭ 139 (+148.21%)
Mutual labels:  playbook
Ansible Collection Hardening
This Ansible collection provides battle tested hardening for Linux, SSH, nginx, MySQL
Stars: ✭ 2,543 (+4441.07%)
Mutual labels:  playbook
azure-k3s-cluster
An Azure template to deploy a lightweight Kubernetes cluster using k3s.io
Stars: ✭ 46 (-17.86%)
Mutual labels:  kubernetes-cluster
Terrible
An Ansible playbook that apply the principle of the Infrastructure as Code on a QEMU/KVM environment.
Stars: ✭ 161 (+187.5%)
Mutual labels:  playbook
guides
Dealerdirect guides for getting things done, be a programming role-model, coding in style and being the better colleague.
Stars: ✭ 21 (-62.5%)
Mutual labels:  playbook
Rollback
Ansible role to rollback scripting applications like PHP, Python, Ruby, etc. in a capistrano style
Stars: ✭ 230 (+310.71%)
Mutual labels:  playbook
Ansible Playbook Bundle
THIS REPO IS MIGRATING: https://github.com/automationbroker/apb
Stars: ✭ 136 (+142.86%)
Mutual labels:  playbook
kubernetes-starterkit
A launchpad for developers to learn Kubernetes from scratch and deployment of microservices on a kubernetes cluster.
Stars: ✭ 39 (-30.36%)
Mutual labels:  kubernetes-cluster
jenkins kube brains
Example scripts to run Kubernetes on your private VMs. This is to support of Loren and my KubeCon 2018 talk "Migrating Jenkins to Kubernetes broke our brains." https://sched.co/GrSh
Stars: ✭ 34 (-39.29%)
Mutual labels:  kubernetes-cluster
Nci Ansible Ui
Simple web interface for running Ansible playbooks
Stars: ✭ 217 (+287.5%)
Mutual labels:  playbook

Supported k0s version Ansible Lint status GitHub commits since latest release (by date)

k0s Ansible Playbook

Create a Kubernetes Cluster using Ansible and vanilla upstream Kubernetes distro k0s

This playbook is largely based on the extensive and outstanding work of the contributors of k3s-ansible and, of course, kubespray.

Included Playbooks

site.yml:

$ ansible-playbook site.yml -i inventory/multipass/inventory.yml

Your inventory must include at least one initial_controller and one worker node. To get a highly available control plane more controller nodes can be added. The first initial controller creates tokens that get written to the nodes when the playbook is executed.

reset.yml:

$ ansible-playbook reset.yml -i inventory/multipass/inventory.yml

Deletes k0s all its files, directories and services from all hosts.

Step by step guide

You can find a user guide on how to use this playbook in the k0s documentation.

Example with multipass

For the quick creation of virtual machines, I have added a script that provisions a bunch of nodes via multipass and another small Python script that generates an Ansible inventory from the created instances.

Steps:

Create 5 instances with multipass and import your ssh public key with cloud-init (create_instances.sh):

$ ./tools/multipass_create_instances.sh
Create cloud-init to import ssh key...
[1/5] Creating instance k0s-1 with multipass...
Launched: k0s-1
...
Name                    State             IPv4             Image
k0s-1                   Running           192.168.64.32    Ubuntu 20.04 LTS
k0s-2                   Running           192.168.64.33    Ubuntu 20.04 LTS
k0s-3                   Running           192.168.64.56    Ubuntu 20.04 LTS
k0s-4                   Running           192.168.64.57    Ubuntu 20.04 LTS
k0s-5                   Running           192.168.64.58    Ubuntu 20.04 LTS

Generate your Ansible inventory:

$ cp -rfp inventory/sample inventory/multipass
$ ./tools/multipass_generate_inventory.py
Designate first instance as control plane
Created Ansible Inventory at: /Users/dev/k0s-ansible/tools/inventory.yml
$ cp tools/inventory.yml inventory/multipass/inventory.yml

Test the ssh connection to all instances in your inventory.yml:

$ ansible -i inventory/multipass/inventory.yml -m ping all
k0s-4 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "ping": "pong"
}
k0s-1 | SUCCESS => {
...

Create your cluster:

$ ansible-playbook site.yml -i inventory/multipass/inventory.yml
...
TASK [k0s/initial_controller : print kubeconfig command] *******************************************************
Friday 22 January 2021  15:32:44 +0100 (0:00:00.247)       0:04:25.177 ********
ok: [k0s-1] => {
    "msg": "To use Cluster: export KUBECONFIG=/Users/dev/k0s-ansible/inventory/multipass/artifacts/k0s-kubeconfig.yml"
}
...
PLAY RECAP *****************************************************************************************************
...
Friday 22 January 2021  15:32:58 +0100 (0:00:00.575)       0:04:39.234 ********
===============================================================================
download : Download k0s binary k0s-v0.10.0-beta1-amd64 ------------------------------------------------ 225.86s
prereq : Install apt packages -------------------------------------------------------------------------- 17.30s
k0s/initial_controller : Wait for k8s apiserver -------------------------------------------------------- 15.34s
k0s/controller : Wait for k8s apiserver ----------------------------------------------------------------- 3.36s
Gathering Facts ----------------------------------------------------------------------------------------- 1.35s
prereq : Create k0s Directories ------------------------------------------------------------------------- 0.86s
Gathering Facts ----------------------------------------------------------------------------------------- 0.84s
k0s/worker : Create k0s worker service with install command --------------------------------------------- 0.80s
Gathering Facts ----------------------------------------------------------------------------------------- 0.79s
k0s/initial_controller : Create k0s initial controller service with install command ------------------------- 0.76s
k0s/initial_controller : Enable and check k0s service --------------------------------------------------- 0.74s
k0s/controller : Create k0s controller service with install command ----------------------------------------- 0.72s
prereq : Write the k0s config file ---------------------------------------------------------------------- 0.69s
Gathering Facts ----------------------------------------------------------------------------------------- 0.68s
Gathering Facts ----------------------------------------------------------------------------------------- 0.65s
k0s/worker : Enable and check k0s service --------------------------------------------------------------- 0.58s
k0s/controller : Enable and check k0s service ----------------------------------------------------------- 0.53s
k0s/worker : Write the k0s token file on worker --------------------------------------------------------- 0.48s
k0s/controller : Write the k0s token file on controller ------------------------------------------------- 0.44s
k0s/initial_controller : Set controller IP in kubeconfig ------------------------------------------------ 0.32s

Connect to your new Kubernetes cluster. The config is ready to use in the inventory/artifacts directory:

$ export KUBECONFIG=/Users/dev/k0s-ansible/inventory/multipass/artifacts/k0s-kubeconfig.yml
$ kubectl get nodes -o wide
NAME    STATUS   ROLES    AGE   VERSION        INTERNAL-IP     EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION     CONTAINER-RUNTIME
k0s-4   Ready    <none>   17m   v1.20.2-k0s1   192.168.64.57   <none>        Ubuntu 20.04.1 LTS   5.4.0-62-generic   containerd://1.4.3
k0s-5   Ready    <none>   17m   v1.20.2-k0s1   192.168.64.58   <none>        Ubuntu 20.04.1 LTS   5.4.0-62-generic   containerd://1.4.3
$ kubectl run hello-k0s --image=quay.io/prometheus/busybox --rm -it --restart=Never --command -- sh -c "echo hello k0s"
hello k0s
pod "hello-k0s" deleted

Want to throw away your cluster and start all over?

$ multipass delete $(multipass list --format csv | grep 'k0s' | cut -d',' -f1)
$ multipass purge

Example with virt-lightning

Virt-lightning (aliased as vl) is tool for fast deploy of virtual machines using Libvirt as backend. Script provided to deploy number of VM and generate Ansible inventory. If some machines are running, they are not changed at the script run. 5 VMs are created by default, pass number as argument if needed.

$ tools/vl_create_instances_inventory.py

This command will create VMs and generate inventory file in tools directory.

How to cleanup the cluster

If you have only k0s VMs, just cleanup everything:

$ vl down

Test with Vagrant

It's assumed that vagrant is installed, if not, download and install it from their website

After that consult the readme

How to Contribute

I welcome issues to and pull requests against this repository!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].