Compare commits
No commits in common. "739da8ac9063158ab629d5dbbdbfb2e7c28dace4" and "8c4615b2c748fc4cd8f5b529adb90824edcfb7b8" have entirely different histories.
739da8ac90
...
8c4615b2c7
11 changed files with 33 additions and 60 deletions
|
@ -1,3 +1 @@
|
||||||
# Ansible
|
# Ansible
|
||||||
|
|
||||||
Here you'll find Ansible playbooks and roles for the JILITS infrastructure 😎
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
# 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.
|
|
34
playbooks/kubernetes/Vagrantfile
vendored
34
playbooks/kubernetes/Vagrantfile
vendored
|
@ -1,6 +1,6 @@
|
||||||
IMAGE_NAME = "bento/ubuntu-22.04"
|
IMAGE_NAME = "bento/ubuntu-22.04"
|
||||||
CONTROL_PLANES = 1
|
CONTROLPLANE_IP = "192.168.56.11"
|
||||||
NODES = 0
|
NODES = 1
|
||||||
|
|
||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
config.ssh.insert_key = false
|
config.ssh.insert_key = false
|
||||||
|
@ -10,19 +10,17 @@ Vagrant.configure("2") do |config|
|
||||||
v.cpus = 2
|
v.cpus = 2
|
||||||
end
|
end
|
||||||
|
|
||||||
(1..CONTROL_PLANES).each do |i|
|
config.vm.define "controlplane" do |master|
|
||||||
config.vm.define "control-plane-#{i}" do |control_plane|
|
master.vm.box = IMAGE_NAME
|
||||||
control_plane.vm.box = IMAGE_NAME
|
master.vm.network "private_network", ip: CONTROLPLANE_IP
|
||||||
control_plane.vm.network "private_network", ip: "192.168.56.#{10 + i}"
|
master.vm.hostname = "controlplane"
|
||||||
control_plane.vm.hostname = "control-plane-#{i}"
|
master.vm.provision "ansible" do |ansible|
|
||||||
control_plane.vm.provision "ansible" do |ansible|
|
ansible.playbook = "playbook.yaml"
|
||||||
ansible.playbook = "playbook.yaml"
|
ansible.extra_vars = {
|
||||||
ansible.extra_vars = {
|
cluster_name: "gerar",
|
||||||
cluster_name: "gerar",
|
node_ip: CONTROLPLANE_IP,
|
||||||
node_ip: "192.168.56.#{10 + i}",
|
is_controlplane: true,
|
||||||
is_control_plane: true,
|
}
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,12 +30,12 @@ Vagrant.configure("2") do |config|
|
||||||
node.vm.network "private_network", ip: "192.168.56.#{20 + i}"
|
node.vm.network "private_network", ip: "192.168.56.#{20 + i}"
|
||||||
node.vm.hostname = "node-#{i}"
|
node.vm.hostname = "node-#{i}"
|
||||||
node.vm.provision "ansible" do |ansible|
|
node.vm.provision "ansible" do |ansible|
|
||||||
ansible.playbook = "playbook.yaml"
|
ansible.playbook = "playbook.yaml"
|
||||||
ansible.extra_vars = {
|
ansible.extra_vars = {
|
||||||
cluster_name: "gerar",
|
cluster_name: "gerar",
|
||||||
node_ip: "192.168.56.#{20 + i}",
|
node_ip: "192.168.56.#{20 + i}",
|
||||||
is_control_plane: false,
|
controlplane_ip: CONTROLPLANE_IP,
|
||||||
control_plane_endpoint: "192.168.56.11",
|
is_controlplane: false,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
3
playbooks/kubernetes/group_vars/all.yml
Normal file
3
playbooks/kubernetes/group_vars/all.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
pod_network_cidr: "10.254.0.0/16"
|
||||||
|
service_cidr: "10.255.0.0/16"
|
||||||
|
kubeadmin_config: /etc/kubernetes/admin.conf
|
|
@ -1,26 +1,2 @@
|
||||||
all:
|
gerar:
|
||||||
children:
|
hosts: []
|
||||||
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
|
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
- include_role:
|
- include_role:
|
||||||
name: kubernetes/any
|
name: kubernetes/any
|
||||||
- include_role:
|
- include_role:
|
||||||
name: kubernetes/control_plane
|
name: kubernetes/controlplane
|
||||||
when: is_control_plane
|
when: is_controlplane
|
||||||
- include_role:
|
- include_role:
|
||||||
name: kubernetes/node
|
name: kubernetes/node
|
||||||
when: not is_control_plane
|
when: not is_controlplane
|
||||||
|
|
||||||
# - hosts: control_plane
|
# - hosts: controlplane
|
||||||
# gather_facts: yes
|
# gather_facts: yes
|
||||||
# become: yes
|
# become: yes
|
||||||
# tasks:
|
# tasks:
|
||||||
|
|
|
@ -84,7 +84,8 @@
|
||||||
- name: Setup CRI-O
|
- name: Setup CRI-O
|
||||||
become: true
|
become: true
|
||||||
vars:
|
vars:
|
||||||
os: xUbuntu_{{ ansible_distribution_version}}
|
os: xUbuntu_22.04 # fetch this from os-release
|
||||||
|
version: 1.24
|
||||||
key_dir: /usr/share/keyrings
|
key_dir: /usr/share/keyrings
|
||||||
keys:
|
keys:
|
||||||
{
|
{
|
||||||
|
@ -95,13 +96,13 @@
|
||||||
},
|
},
|
||||||
"libcontainers-crio":
|
"libcontainers-crio":
|
||||||
{
|
{
|
||||||
"url": "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ k8s_version }}/{{ os }}/Release.key",
|
"url": "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ version }}/{{ os }}/Release.key",
|
||||||
"name": "libcontainers-crio-archive-keyring",
|
"name": "libcontainers-crio-archive-keyring",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
repos:
|
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-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:/{{ k8s_version }}/{{ os }}/ /
|
- deb [signed-by={{ key_dir }}/libcontainers-crio-archive-keyring.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ version }}/{{ os }}/ /
|
||||||
block:
|
block:
|
||||||
- name: Download signing keys
|
- name: Download signing keys
|
||||||
with_dict: "{{ keys }}"
|
with_dict: "{{ keys }}"
|
||||||
|
|
|
@ -7,15 +7,15 @@
|
||||||
path: /etc/hosts
|
path: /etc/hosts
|
||||||
state: present
|
state: present
|
||||||
regexp: '^\d+\.\d+\.\d+\.\d+\ .*-cluster-endpoint$'
|
regexp: '^\d+\.\d+\.\d+\.\d+\ .*-cluster-endpoint$'
|
||||||
line: "{{ control_plane_endpoint }} {{ cluster_name }}-cluster-endpoint"
|
line: "{{ controlplane_ip }} {{ cluster_name }}-cluster-endpoint"
|
||||||
|
|
||||||
- name: Obtain join command from control_plane
|
- name: Obtain join command from controlplane
|
||||||
ansible.builtin.command: "kubeadm token create --print-join-command"
|
ansible.builtin.command: "kubeadm token create --print-join-command"
|
||||||
when: inventory_hostname != "control_plane"
|
when: inventory_hostname != "controlplane"
|
||||||
register: join_cmd
|
register: join_cmd
|
||||||
delegate_to: "{{ item }}"
|
delegate_to: "{{ item }}"
|
||||||
delegate_facts: true
|
delegate_facts: true
|
||||||
with_items: ["control_plane"]
|
with_items: ["controlplane"]
|
||||||
|
|
||||||
- name: Execute join command
|
- name: Execute join command
|
||||||
become: true
|
become: true
|
||||||
|
|
Loading…
Reference in a new issue