simplified the variables and removed redundant information

This commit is contained in:
2025-06-30 00:05:33 +02:00
parent d5032d4bb4
commit ab0dd018be
13 changed files with 428 additions and 110 deletions

View File

@ -1,14 +0,0 @@
- name: Install Kubernetes CNI
hosts: k8s_control_plane
become: true
tasks:
- name: Download Calico manifest
get_url:
url: https://raw.githubusercontent.com/projectcalico/calico/v3.27.3/manifests/calico.yaml
dest: /tmp/calico.yaml
mode: '0644'
- name: Apply Calico CNI plugin
shell: kubectl apply -f /tmp/calico.yaml
environment:
KUBECONFIG: /etc/kubernetes/admin.conf

View File

@ -1,10 +0,0 @@
[k8s_control_plane]
k8s-control-plane
[k8s_nodes]
k8s-worker1
k8s-worker2
[all:vars]
ansible_user=kevin
ansible_ssh_private_key_file=~/.ssh/id_rsa

View File

@ -1,43 +0,0 @@
- name: Initialize Kubernetes Control Plane
hosts: k8s_control_plane
become: true
vars:
## This is the default networkd of Calico
pod_network_cidr: "192.168.0.0/16"
apiserver_advertise_address: "10.50.3.21"
cri_socket: "unix:///run/containerd/containerd.sock"
kubeconfig_src: "/etc/kubernetes/admin.conf"
kubeconfig_dest: "/home/{{ ansible_user }}/.kube/config"
## Crea la directory .kube nella home dell'utente
tasks:
- name: Ensure .kube directory exists
file:
path: "/home/{{ ansible_user }}/.kube"
state: directory
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: '0755'
## Crea il cluster con i parametri indicati sopra
- name: Run kubeadm init
command: >
kubeadm init
--pod-network-cidr={{ pod_network_cidr }}
--apiserver-advertise-address={{ apiserver_advertise_address }}
--cri-socket {{ cri_socket }}
args:
creates: /etc/kubernetes/pki/ca.crt
## Copia la configurazione del cluster così da poter eseguire comandi kubectl dall'utente
- name: Copy admin.conf to user's kube config
copy:
src: "{{ kubeconfig_src }}"
dest: "{{ kubeconfig_dest }}"
remote_src: true
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: '0644'

View File

@ -98,12 +98,6 @@
- name: Hold Kubernetes packages
ansible.builtin.shell: apt-mark hold kubelet kubeadm kubectl
- name: Enable and start containerd
systemd:
name: containerd
enabled: true
state: started
## Abilita il servizio di kubelet
- name: Enable and start kubelet

View File

@ -49,4 +49,4 @@
state: stopped
masked: true
daemon_reload: yes
ignore_errors: true # in case it's not installed
ignore_errors: true

View File

@ -1,5 +1,3 @@
# master-k8s.yaml
- import_playbook: k8s-install-deps.yaml
- import_playbook: k8s-init.yaml
- import_playbook: install_cni.yaml
- import_playbook: longhorn-reqs.yaml
- import_playbook: longhorn-deps.yaml