Compare commits
3 commits
cfcd2ca654
...
5db5bbbb4d
Author | SHA1 | Date | |
---|---|---|---|
5db5bbbb4d | |||
ddc2730fc3 | |||
6c485e0a51 |
11 changed files with 58 additions and 21 deletions
22
playbooks/kubernetes/Vagrantfile
vendored
22
playbooks/kubernetes/Vagrantfile
vendored
|
@ -1,7 +1,21 @@
|
|||
IMAGE_NAME = "bento/ubuntu-22.04"
|
||||
|
||||
CONTROL_PLANES = 1
|
||||
NODES = 0
|
||||
|
||||
ansible_groups = {
|
||||
"control_planes" => [
|
||||
"control-plane-[1:#{CONTROL_PLANES}]"
|
||||
],
|
||||
"nodes" => [
|
||||
"node-[1:#{NODES}]"
|
||||
],
|
||||
"local_dev" => [
|
||||
"control-plane-[1:#{CONTROL_PLANES}]",
|
||||
"node-[1:#{NODES}]"
|
||||
],
|
||||
}
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.ssh.insert_key = false
|
||||
|
||||
|
@ -17,10 +31,9 @@ Vagrant.configure("2") do |config|
|
|||
control_plane.vm.hostname = "control-plane-#{i}"
|
||||
control_plane.vm.provision "ansible" do |ansible|
|
||||
ansible.playbook = "playbook.yaml"
|
||||
ansible.groups = ansible_groups
|
||||
ansible.extra_vars = {
|
||||
cluster_name: "gerar",
|
||||
node_ip: "192.168.56.#{10 + i}",
|
||||
is_control_plane: true,
|
||||
node_ip: "192.168.56.#{10 + i}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -33,10 +46,9 @@ Vagrant.configure("2") do |config|
|
|||
node.vm.hostname = "node-#{i}"
|
||||
node.vm.provision "ansible" do |ansible|
|
||||
ansible.playbook = "playbook.yaml"
|
||||
ansible.groups = ansible_groups
|
||||
ansible.extra_vars = {
|
||||
cluster_name: "gerar",
|
||||
node_ip: "192.168.56.#{20 + i}",
|
||||
is_control_plane: false,
|
||||
control_plane_endpoint: "192.168.56.11",
|
||||
}
|
||||
end
|
||||
|
|
1
playbooks/kubernetes/group_vars/all.yaml
Normal file
1
playbooks/kubernetes/group_vars/all.yaml
Normal file
|
@ -0,0 +1 @@
|
|||
kubeadmin_config: "/etc/kubernetes/admin.conf"
|
1
playbooks/kubernetes/group_vars/control_planes.yaml
Normal file
1
playbooks/kubernetes/group_vars/control_planes.yaml
Normal file
|
@ -0,0 +1 @@
|
|||
is_control_plane: true
|
5
playbooks/kubernetes/group_vars/gerar.yaml
Normal file
5
playbooks/kubernetes/group_vars/gerar.yaml
Normal file
|
@ -0,0 +1,5 @@
|
|||
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"
|
5
playbooks/kubernetes/group_vars/local_dev.yaml
Normal file
5
playbooks/kubernetes/group_vars/local_dev.yaml
Normal file
|
@ -0,0 +1,5 @@
|
|||
cluster_name: "local-dev"
|
||||
k8s_version: "1.26"
|
||||
pod_network_cidr: "10.254.0.0/16"
|
||||
service_cidr: "10.255.0.0/16"
|
||||
kubeadmin_config: "/etc/kubernetes/admin.conf"
|
1
playbooks/kubernetes/group_vars/nodes.yaml
Normal file
1
playbooks/kubernetes/group_vars/nodes.yaml
Normal file
|
@ -0,0 +1 @@
|
|||
is_control_plane: false
|
|
@ -5,19 +5,7 @@ all:
|
|||
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:
|
||||
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"
|
||||
vars:
|
||||
kubeadmin_config: /etc/kubernetes/admin.conf
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
- hosts: all
|
||||
gather_facts: yes
|
||||
roles:
|
||||
- include_role:
|
||||
name: install_system_tools
|
||||
- include_role:
|
||||
name: remove_swap
|
||||
- include_role:
|
||||
|
|
10
roles/install_system_tools/tasks/main.yml
Normal file
10
roles/install_system_tools/tasks/main.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
- name: Install system tools
|
||||
become: true
|
||||
vars:
|
||||
packages:
|
||||
- less
|
||||
ansible.builtin.apt:
|
||||
name: "{{ packages }}"
|
||||
state: present
|
||||
update_cache: yes
|
|
@ -9,8 +9,9 @@
|
|||
- curl
|
||||
ansible.builtin.apt:
|
||||
name: "{{ packages }}"
|
||||
state: present
|
||||
state: latest
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
|
||||
- name: Setup Kubernetes repository
|
||||
become: true
|
||||
|
@ -25,19 +26,29 @@
|
|||
repo: deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main
|
||||
state: present
|
||||
|
||||
- name: Update apt cache
|
||||
ansible.builtin.apt:
|
||||
update_cache: yes
|
||||
|
||||
- name: Get Kubernetes package version
|
||||
ansible.builtin.shell: "apt-cache show kubeadm | grep -F 'Version: {{ k8s_version }}.' | cut -d' ' -f2 | sort -n | tail -n 1"
|
||||
register: k8s_pkg_ver
|
||||
|
||||
- name: Setup Kubernetes packages
|
||||
become: true
|
||||
vars:
|
||||
packages:
|
||||
- kubelet
|
||||
- kubeadm
|
||||
- kubectl
|
||||
- kubelet={{ k8s_pkg_ver.stdout }}
|
||||
- kubeadm={{ k8s_pkg_ver.stdout }}
|
||||
- kubectl={{ k8s_pkg_ver.stdout }}
|
||||
block:
|
||||
- name: Install kubelet, kubeadm and kubectl
|
||||
ansible.builtin.apt:
|
||||
name: "{{ packages }}"
|
||||
state: present
|
||||
update_cache: yes
|
||||
allow_downgrade: no
|
||||
cache_valid_time: 3600
|
||||
|
||||
- name: Hold Kubernetes packages
|
||||
loop: "{{ packages }}"
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
name: "{{ packages }}"
|
||||
state: present
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
|
||||
- name: Install Kubernetes module dependencies
|
||||
ansible.builtin.pip:
|
||||
|
|
Loading…
Reference in a new issue