Compare commits

..

5 commits

Author SHA1 Message Date
739da8ac90 Enrich inventory 2023-01-10 21:58:06 +01:00
98de636298 Parametarize K8s and Ubuntu version 2023-01-10 21:46:19 +01:00
c3405a7063 Add metal hosts 2023-01-10 21:29:53 +01:00
7b058f6304 Add READMEs 2023-01-10 21:29:53 +01:00
23edc91bab Prepare for HA control plane 2023-01-10 21:29:48 +01:00
11 changed files with 60 additions and 33 deletions

View file

@ -1 +1,3 @@
# Ansible
Here you'll find Ansible playbooks and roles for the JILITS infrastructure 😎

View file

@ -0,0 +1,3 @@
# Kubernetes playbook
This is a work-in-progress and currently only works with Vagrant, as the setup is being tested there for the moment before moving onto the real hardware.

View file

@ -1,6 +1,6 @@
IMAGE_NAME = "bento/ubuntu-22.04"
CONTROLPLANE_IP = "192.168.56.11"
NODES = 1
CONTROL_PLANES = 1
NODES = 0
Vagrant.configure("2") do |config|
config.ssh.insert_key = false
@ -10,19 +10,21 @@ Vagrant.configure("2") do |config|
v.cpus = 2
end
config.vm.define "controlplane" do |master|
master.vm.box = IMAGE_NAME
master.vm.network "private_network", ip: CONTROLPLANE_IP
master.vm.hostname = "controlplane"
master.vm.provision "ansible" do |ansible|
(1..CONTROL_PLANES).each do |i|
config.vm.define "control-plane-#{i}" do |control_plane|
control_plane.vm.box = IMAGE_NAME
control_plane.vm.network "private_network", ip: "192.168.56.#{10 + i}"
control_plane.vm.hostname = "control-plane-#{i}"
control_plane.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yaml"
ansible.extra_vars = {
cluster_name: "gerar",
node_ip: CONTROLPLANE_IP,
is_controlplane: true,
node_ip: "192.168.56.#{10 + i}",
is_control_plane: true,
}
end
end
end
(1..NODES).each do |i|
config.vm.define "node-#{i}" do |node|
@ -34,8 +36,8 @@ Vagrant.configure("2") do |config|
ansible.extra_vars = {
cluster_name: "gerar",
node_ip: "192.168.56.#{20 + i}",
controlplane_ip: CONTROLPLANE_IP,
is_controlplane: false,
is_control_plane: false,
control_plane_endpoint: "192.168.56.11",
}
end
end

View file

@ -1,3 +0,0 @@
pod_network_cidr: "10.254.0.0/16"
service_cidr: "10.255.0.0/16"
kubeadmin_config: /etc/kubernetes/admin.conf

View file

@ -1,2 +1,26 @@
gerar:
hosts: []
all:
children:
gerar:
hosts:
matthew.gerar.jilits.se:
mark.gerar.jilits.se:
luke.gerar.jilits.se:
vars:
ansible_user: servant
cluster_name: "gerar"
k8s_version: 1.26
pod_network_cidr: "10.254.0.0/16"
service_cidr: "10.255.0.0/16"
control_planes:
hosts:
matthew.gerar.jilits.se:
vars:
is_control_plane: true
nodes:
hosts:
mark.gerar.jilits.se:
luke.gerar.jilits.se:
vars:
is_control_plane: false
vars:
kubeadmin_config: /etc/kubernetes/admin.conf

View file

@ -7,13 +7,13 @@
- include_role:
name: kubernetes/any
- include_role:
name: kubernetes/controlplane
when: is_controlplane
name: kubernetes/control_plane
when: is_control_plane
- include_role:
name: kubernetes/node
when: not is_controlplane
when: not is_control_plane
# - hosts: controlplane
# - hosts: control_plane
# gather_facts: yes
# become: yes
# tasks:

View file

@ -84,8 +84,7 @@
- name: Setup CRI-O
become: true
vars:
os: xUbuntu_22.04 # fetch this from os-release
version: 1.24
os: xUbuntu_{{ ansible_distribution_version}}
key_dir: /usr/share/keyrings
keys:
{
@ -96,13 +95,13 @@
},
"libcontainers-crio":
{
"url": "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ version }}/{{ os }}/Release.key",
"url": "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ k8s_version }}/{{ os }}/Release.key",
"name": "libcontainers-crio-archive-keyring",
},
}
repos:
- deb [signed-by={{ key_dir }}/libcontainers-archive-keyring.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/{{ os }}/ /
- deb [signed-by={{ key_dir }}/libcontainers-crio-archive-keyring.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ version }}/{{ os }}/ /
- deb [signed-by={{ key_dir }}/libcontainers-crio-archive-keyring.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ k8s_version }}/{{ os }}/ /
block:
- name: Download signing keys
with_dict: "{{ keys }}"

View file

@ -7,15 +7,15 @@
path: /etc/hosts
state: present
regexp: '^\d+\.\d+\.\d+\.\d+\ .*-cluster-endpoint$'
line: "{{ controlplane_ip }} {{ cluster_name }}-cluster-endpoint"
line: "{{ control_plane_endpoint }} {{ cluster_name }}-cluster-endpoint"
- name: Obtain join command from controlplane
- name: Obtain join command from control_plane
ansible.builtin.command: "kubeadm token create --print-join-command"
when: inventory_hostname != "controlplane"
when: inventory_hostname != "control_plane"
register: join_cmd
delegate_to: "{{ item }}"
delegate_facts: true
with_items: ["controlplane"]
with_items: ["control_plane"]
- name: Execute join command
become: true