Skip to content

Commit

Permalink
add calicoctl installation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tcharl committed Sep 21, 2024
1 parent 4f34f41 commit 2359366
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 7 deletions.
7 changes: 4 additions & 3 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ kube_cidr: "192.167.0.0/16" # Calico default: no garantee that it will work if m
standalone_role: Yes
secure_logs: Yes
reset_kube: False
k8s_version: 1.29
kubernetes_package_version: "{{ k8s_version }}.2-150500.1.1"
calico_cni_version: v3.27.0 # wait https://github.com/projectcalico/calico/issues/8541 to be solved
k8s_version: "1.31"
kubernetes_package_version: "{{ k8s_version }}.1-150500.1.1"
calico_cni_version: "v3.28.2" # wait https://github.com/projectcalico/calico/issues/8541 to be solved
calico_arch: "amd64"
12 changes: 11 additions & 1 deletion tasks/delete-configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
ansible.builtin.package:
name:
- kubeadm
- containerd.io
- kubectl
- kubelet
- kubernetes-cni
Expand Down Expand Up @@ -77,19 +78,21 @@
become: Yes
loop:
- /etc/cni
- /etc/containerd
- /etc/kubernetes
- /etc/sysconfig/kubelet
- /etc/systemd/system/multi-user.target.wants/kubelet.service
- /root/.kube
- /usr/lib/etcd
- /usr/lib/kubelet
- /opt/containerd
- /usr/lib/systemd/system/kubelet.service
- /usr/lib/systemd/system/kubelet.service.d
- /var/lib/etcd
- /var/lib/cni
- /var/lib/containerd
- /var/lib/kubelet
failed_when: false
notify: ansible-orchestration | refresh containerd

- name: Delete-configuration | Just force systemd to reread configs (2.4 and above)
ansible.builtin.systemd:
Expand All @@ -102,6 +105,13 @@
state: restarted
become: yes

- name: Delete-configuration | reinstall containerd
ansible.builtin.include_role:
name: geerlingguy.containerd
vars:
ansible_become: true
# notify: ansible-orchestration | refresh containerd

- name: Delete-configuration | start containerd service
ansible.builtin.service:
name: "{{ item }}"
Expand Down
22 changes: 21 additions & 1 deletion tasks/destroy-kubelet-volumes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,24 @@
loop_control:
loop_var: mounted_volume
when: kube_volume.files | length > 0 and kube_volume.files.path | length > 0
become: Yes
become: Yes

- name: Destroy-kubelet-volumes | get volume name
ansible.builtin.find:
paths: "{{ pod_files }}/volumes/kubernetes.io~projecte"
file_type: directory
follow: yes
recurse: false
register: kube_volume_projected
become: Yes

- name: Destroy-kubelet-volumes | unmount
ansible.posix.mount:
path: "{{ mounted_volume | map(attribute='path') }}"
state: absent
loop: "{{ kube_volume_projected.files | default([]) | list }}"
loop_control:
loop_var: mounted_volume
when: kube_volume_projected.files | length > 0 and kube_volume_projected.files.path | length > 0
become: Yes

11 changes: 9 additions & 2 deletions tasks/kube-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@
apiServer:
certSANs: "{{ kube_alt_names | default(['api.kubernetes.' + company_domain]) + [kube_master_ip.msg | ansible.utils.ipaddr] }}"
extraArgs:
authorization-mode: Node,RBAC
timeoutForControlPlane: 4m0s
- name: authorization-mode
value: Node,RBAC
controlPlaneEndpoint: "{{ kube_master_ip.msg | ansible.utils.ipaddr }}:6443"
# scheduler:
# extraArgs:
Expand All @@ -111,3 +111,10 @@
when: kube_masters_group in group_names
delay: 15
become: yes

- name: Kube-install | download calicoctl
ansible.builtin.get_url:
url: "https://github.com/projectcalico/calico/releases/download/{{calico_cni_version}}/calicoctl-linux-{{ calico_arch }}"
dest: "/usr/local/bin/kubectl-calico"
mode: u=rwx,g=r,o=r
become: yes

0 comments on commit 2359366

Please sign in to comment.