This commit is contained in:
tomas.limpinho
2025-10-12 11:55:56 +01:00
parent c05033cdc8
commit 1d6d1bea7a
7 changed files with 114 additions and 0 deletions

View File

@ -0,0 +1,12 @@
- name: Update apt cache
apt:
update_cache: yes
- name: Install basic packages
apt:
name:
- curl
- vim
- net-tools
- gnupg
state: present

View File

@ -0,0 +1,21 @@
- name: Initialize Kubernetes master
command: kubeadm init --pod-network-cidr=192.168.1.3/16
args:
creates: /etc/kubernetes/admin.conf
- name: Set up kubeconfig for user
copy:
src: /etc/kubernetes/admin.conf
dest: /home/ubuntu/.kube/config
remote_src: yes
owner: ubuntu
group: ubuntu
mode: 0644
- name: Install Calico CNI
become: yes
become_user: ubuntu
shell: |
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
environment:
KUBECONFIG: /home/ubuntu/.kube/config

View File

@ -0,0 +1,3 @@
- name: Join Kubernetes cluster
shell: "{{ hostvars['master1']['kubeadm_join_command'] }}"
when: hostvars['master1']['kubeadm_join_command'] is defined

View File

@ -0,0 +1,31 @@
- name: Install containerd
apt:
name: containerd
state: present
- name: Add Kubernetes APT key
apt_key:
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
state: present
- name: Add Kubernetes repo
apt_repository:
repo: deb http://apt.kubernetes.io/ kubernetes-xenial main
state: present
- name: Install Kubernetes components
apt:
name:
- kubelet
- kubeadm
- kubectl
state: present
update_cache: yes
- name: Hold Kubernetes packages
apt:
name:
- kubelet
- kubeadm
- kubectl
state: hold