Bootstrap kubernetes cluster worker and master ok
This commit is contained in:
25
host_vars/ubuntu-worker.yml
Normal file
25
host_vars/ubuntu-worker.yml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
kubernetes_version: 1.28
|
||||||
|
kubernetes_role: node
|
||||||
|
|
||||||
|
kubernetes_alias_bashrc:
|
||||||
|
- path: "/root/.bashrc"
|
||||||
|
regexp: "^source /usr/share/bash-completion/bash_completion"
|
||||||
|
state: present
|
||||||
|
line: "source /usr/share/bash-completion/bash_completion"
|
||||||
|
- path: "/root/.bashrc"
|
||||||
|
regexp: "^source /etc/bash_completion"
|
||||||
|
state: present
|
||||||
|
line: "source /etc/bash_completion"
|
||||||
|
- path: "/root/.bashrc"
|
||||||
|
regexp: "^source <(kubectl completion bash)"
|
||||||
|
state: present
|
||||||
|
line: "source <(kubectl completion bash)"
|
||||||
|
- path: "/root/.bashrc"
|
||||||
|
regexp: "^alias k=kubectl"
|
||||||
|
state: present
|
||||||
|
line: "alias k=kubectl"
|
||||||
|
- path: "/root/.bashrc"
|
||||||
|
regexp: "^complete -F __start_kubectl k"
|
||||||
|
state: present
|
||||||
|
line: "complete -F __start_kubectl k"
|
||||||
@@ -57,6 +57,9 @@ kubernetes_git_repo: perso-infra
|
|||||||
|
|
||||||
kubernetes_git_url: github.com
|
kubernetes_git_url: github.com
|
||||||
|
|
||||||
|
|
||||||
|
kubernetes_allow_pods_on_control_plane: false
|
||||||
|
|
||||||
kubernetes_alias_bashrc:
|
kubernetes_alias_bashrc:
|
||||||
- path: "/root/.bashrc"
|
- path: "/root/.bashrc"
|
||||||
regexp: "^source /usr/share/bash-completion/bash_completion"
|
regexp: "^source /usr/share/bash-completion/bash_completion"
|
||||||
|
|||||||
19
hosts
19
hosts
@@ -1,10 +1,10 @@
|
|||||||
[perso]
|
; [perso]
|
||||||
ovh_fr ansible_host=37.187.127.90 ansible_user=stephane
|
; ovh_fr ansible_host=37.187.127.90 ansible_user=stephane
|
||||||
scaleway_fr ansible_host=163.172.84.28 ansible_user=stephane
|
; scaleway_fr ansible_host=163.172.84.28 ansible_user=stephane
|
||||||
|
|
||||||
# TO KNOW WHOIS CHISEL SERVER
|
; # TO KNOW WHOIS CHISEL SERVER
|
||||||
[server]
|
; [server]
|
||||||
scaleway_fr ansible_host=163.172.84.28 ansible_user=stephane
|
; scaleway_fr ansible_host=163.172.84.28 ansible_user=stephane
|
||||||
|
|
||||||
; [ovh]
|
; [ovh]
|
||||||
; ovh_fr ansible_host=37.187.127.90 ansible_user=stephane
|
; ovh_fr ansible_host=37.187.127.90 ansible_user=stephane
|
||||||
@@ -14,3 +14,10 @@ scaleway_fr ansible_host=163.172.84.28 ansible_user=stephane
|
|||||||
|
|
||||||
[local]
|
[local]
|
||||||
vagrant ansible_host=192.168.33.10 ansible_user=vagrant ansible_password=vagrant
|
vagrant ansible_host=192.168.33.10 ansible_user=vagrant ansible_password=vagrant
|
||||||
|
ubuntu-worker ansible_host=192.168.33.11 ansible_user=vagrant ansible_password=vagrant
|
||||||
|
|
||||||
|
[workers]
|
||||||
|
ubuntu-worker ansible_host=192.168.33.11 ansible_user=vagrant ansible_password=vagrant
|
||||||
|
|
||||||
|
|
||||||
|
#kubectl label node ubuntu-worker node-role.kubernetes.io/worker ubuntu-worker
|
||||||
28
kube.yml
28
kube.yml
@@ -7,6 +7,8 @@
|
|||||||
# # @author Stéphane Gratias (2023).
|
# # @author Stéphane Gratias (2023).
|
||||||
# #
|
# #
|
||||||
|
|
||||||
|
# Use hostname node and control_plane to join the kubernetes cluster
|
||||||
|
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
|
|
||||||
- name: >-
|
- name: >-
|
||||||
@@ -25,8 +27,16 @@
|
|||||||
- overlay
|
- overlay
|
||||||
- br_netfilter
|
- br_netfilter
|
||||||
tags:
|
tags:
|
||||||
- always
|
- kubernetes
|
||||||
|
|
||||||
|
- name: Set ipv4 forwarding on kubernetes node only
|
||||||
|
ansible.posix.sysctl:
|
||||||
|
name: net.ipv4.ip_forward
|
||||||
|
value: '1'
|
||||||
|
sysctl_set: true
|
||||||
|
when: kubernetes_role == 'node'
|
||||||
|
tags:
|
||||||
|
- kubernetes
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- { role: geerlingguy.containerd, tags: [kubernetes, containerd] }
|
- { role: geerlingguy.containerd, tags: [kubernetes, containerd] }
|
||||||
@@ -34,6 +44,17 @@
|
|||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
|
# labeled worker
|
||||||
|
- name: Labeled workers from master
|
||||||
|
command: "kubectl label node {{ item }} node-role.kubernetes.io/worker={{ item }}"
|
||||||
|
loop: "{{ groups['workers'] }}"
|
||||||
|
when:
|
||||||
|
- kubernetes_role == 'control_plane'
|
||||||
|
- groups['workers'] is defined
|
||||||
|
tags:
|
||||||
|
- kubernetes
|
||||||
|
- alias
|
||||||
|
|
||||||
- name: Add kubectl alias and completion
|
- name: Add kubectl alias and completion
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ item.path }}"
|
path: "{{ item.path }}"
|
||||||
@@ -56,9 +77,10 @@
|
|||||||
- "{{ kubernetes_tree_base_dir | last }}"
|
- "{{ kubernetes_tree_base_dir | last }}"
|
||||||
- "{{ kubernetes_tree_base_dir | last }}/{{ kubernetes_service }}"
|
- "{{ kubernetes_tree_base_dir | last }}/{{ kubernetes_service }}"
|
||||||
tags:
|
tags:
|
||||||
- kubernetes
|
|
||||||
- git
|
- git
|
||||||
|
|
||||||
|
#kubectl label node <node name> node-role.kubernetes.io/<role name>=<key
|
||||||
|
|
||||||
# - name: Allow pods on control plane (if configured).
|
# - name: Allow pods on control plane (if configured).
|
||||||
# command: "kubectl taint nodes --all node-role.kubernetes.io/control-plane-"
|
# command: "kubectl taint nodes --all node-role.kubernetes.io/control-plane-"
|
||||||
# when:
|
# when:
|
||||||
@@ -85,7 +107,7 @@
|
|||||||
tags:
|
tags:
|
||||||
- test
|
- test
|
||||||
|
|
||||||
- name: Apply metrics-server manifest to the cluster.
|
- name: Apply argocd manifest to the cluster.
|
||||||
kubernetes.core.k8s:
|
kubernetes.core.k8s:
|
||||||
state: present
|
state: present
|
||||||
namespace: argocd
|
namespace: argocd
|
||||||
|
|||||||
Reference in New Issue
Block a user