Commit 85b01829 authored by Vincent RABAH's avatar Vincent RABAH Committed by Hussein Galal
Browse files

Ansible provisionning (#217)

Ansible provisionning contrib
parents
Loading
Loading
Loading
Loading

README.md

0 → 100644
+43 −0
Original line number Diff line number Diff line
# Build a Kubernetes cluster using k3s via Ansible.

## K3s Ansible Playbook

Build a Kubernetes cluster using Ansible with k3s. The goal is easily install a Kubernetes cluster on machines running:

- [X] Debian 
- [ ] Ubuntu 
- [ ] CentOS 

on processor architecture:

- [X] x64
- [X] arm64
- [X] armhf

## System requirements:

Deployment environment must have Ansible 2.4.0+
Master and nodes must have passwordless SSH access

## Usage

Add the system information gathered above into a file called hosts.ini. For example:

```
[master]
192.16.35.12

[node]
192.16.35.[10:11]

[kube-cluster:children]
master
node
```

Start provisioning of the cluster using the following command:

```
ansible-playbook site.yaml
```

ansible.cfg

0 → 100644
+11 −0
Original line number Diff line number Diff line
[defaults]
roles_path = ./roles
inventory  = ./hosts.ini

remote_tmp = $HOME/.ansible/tmp
local_tmp  = $HOME/.ansible/tmp
pipelining = True
become = True
host_key_checking = False
deprecation_warnings = False
callback_whitelist = profile_tasks

group_vars/all.yml

0 → 100644
+4 −0
Original line number Diff line number Diff line
k3s_version: v0.3.0
ansible_user: debian
systemd_dir: /etc/systemd/system
master_ip: "{{ hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0]) }}"

hosts.ini

0 → 100644
+12 −0
Original line number Diff line number Diff line
[master]
192.168.1.26

[node]
192.168.1.34
192.168.1.39
192.168.1.16
192.168.1.32

[k3s-cluster:children]
master
node
+36 −0
Original line number Diff line number Diff line
---

- name: Delete k3s if already present
  file:
    path: /usr/local/bin/k3s
    state: absent

- name: Download k3s binary x64
  get_url:                                                           
      url: https://github.com/rancher/k3s/releases/download/{{ k3s_version }}/k3s
      dest: /usr/local/bin/k3s
      owner: root
      group: root
      mode: 755
#  when: ( ansible_facts.userspace_architecture == "x86_64" )
  when: ( ansible_facts.architecture == "x86_64" )

- name: Download k3s binary arm64
  get_url:                                                           
      url: https://github.com/rancher/k3s/releases/download/{{ k3s_version }}/k3s-arm64
      dest: /usr/local/bin/k3s
      owner: root
      group: root
      mode: 755
  when: ( ansible_facts.architecture is search "arm" and 
          ansible_facts.userspace_bits == "64" )

- name: Download k3s binary armhf
  get_url:                                                           
      url: https://github.com/rancher/k3s/releases/download/{{ k3s_version }}/k3s-armhf
      dest: /usr/local/bin/k3s
      owner: root
      group: root
      mode: 755
  when: ( ansible_facts.architecture is search "arm" and 
          ansible_facts.userspace_bits == "32" )