Used it for my home thingie, some quality improvements.

Need to document the changes on the README.md.
This commit is contained in:
savagebidoof
2023-08-01 20:00:14 +02:00
parent 7358da26d8
commit 6902681907
8 changed files with 77 additions and 28 deletions

View File

@ -10,8 +10,8 @@
vars:
# Testing purposes
ansible_user: "kuser" # Testing purposes
ansible_password: "kuser1234" # Testing purposes
ansible_user: "kluser" # Testing purposes
ansible_password: "kluser_1234" # Testing purposes
ansible_become_password: "{{ ansible_password }}" # Testing purposes
# Actual vars
@ -20,7 +20,7 @@
# Cluster shit
kubeadm_join_path: "./Exported/kubeadm-join.command"
_kubeadm_join_command: "" #placeholder
_kubeadm_join_command: "" # Placeholder
tasks:
# - check vars
@ -36,6 +36,7 @@
- name: init cluster
import_tasks: tasks_master.yaml
when: is_master
become: true
# else: join
- name: join cluster
@ -45,3 +46,4 @@
# Do other stuff
- name: post setup
import_tasks: tasks_end.yaml
become: true

View File

@ -3,8 +3,8 @@
name: "{{ delete_user_name }}"
remove: true
state: absent
when: not is_master
become: true
when: delete_user_name != ""
#reboot
- name: reboot

View File

@ -1,7 +1,6 @@
## Init
- name: Init cluster
ansible.builtin.command: "kubeadm init"
become: true
## Export kubeconfig file
@ -11,31 +10,29 @@
src: /etc/kubernetes/admin.conf
dest: ./Exported/kubeconfig.conf
flat: true
become: true
## Taints
### Schedule pods on master
- name: Remove Taint (allows deployment in control plane node)
ansible.builtin.shell: "kubectl taint nodes --all node-role.kubernetes.io/control-plane-"
ansible.builtin.shell: "kubectl taint nodes --kubeconfig /etc/kubernetes/admin.conf --all node-role.kubernetes.io/control-plane-"
## CNI
### Calico
- name: Calico
ansible.builtin.command: "kubectl create --kubeconfig /etc/kubernetes/admin.conf -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.1/manifests/calico.yaml"
become: true
## Extras
### MetalLB
- name: MetalLB
ansible.builtin.command: "kubectl create --kubeconfig /etc/kubernetes/admin.conf -f https://raw.githubusercontent.com/metallb/metallb/v0.13.10/config/manifests/metallb-native.yaml"
become: true
## Export join command
- name: Generate join token
shell: kubeadm token create --print-join-command
shell: kubeadm token create --kubeconfig /etc/kubernetes/admin.conf --print-join-command
register: kubeadm_join_cmd
- set_fact:
@ -49,3 +46,4 @@
content: |
{{ kubeadm_join_command }}
delegate_to: localhost
become: false

View File

@ -1,7 +1,7 @@
- name: Populate {{ _kubeadm_join_command }}
ansible.builtin.set_fact: _kubeadm_join_command="{{ lookup('file', kubeadm_join_path ) }}"
- debug: var=kubeadm_join_command
- debug: var=_kubeadm_join_command
- name: Join kubeadm
ansible.builtin.command: "{{ _kubeadm_join_command }}"