Skip to content

Instantly share code, notes, and snippets.

@lioneltchami
Created July 15, 2022 06:21
Show Gist options
  • Select an option

  • Save lioneltchami/2a3eb9310234dd781a81707e015a9d7a to your computer and use it in GitHub Desktop.

Select an option

Save lioneltchami/2a3eb9310234dd781a81707e015a9d7a to your computer and use it in GitHub Desktop.
- name: Remove current swaps from fstab
lineinfile:
dest: /etc/fstab
regexp: '^/[\S]+\s+none\s+swap '
state: absent
- name: Disable swap
command: swapoff -a
when: ansible_swaptotal_mb > 0
- name: Configure containerd.conf modules
template:
src: etc/modules-load.d/containerd.conf
dest: /etc/modules-load.d/containerd.conf
- name: Load containerd kernel modules
modprobe:
name: "{{ item.name }}"
state: present
loop: "{{ k8s_common_modprobe }}"
- name: Configure kubernetes-cri sys params
sysctl:
name: "{{ item.name }}"
value: "{{ item.value }}"
state: present
reload: yes
loop: "{{ k8s_common_sysctl }}"
# https://github.com/containerd/containerd/issues/4581
# File etc/containerd/config.toml needs to be deleted before kubeadm init
- name: Configure containerd.conf
template:
src: etc/containerd/config.toml
dest: /etc/containerd/config.toml
notify: restart containerd
- name: Configure node-ip {{ k8s_node_public_ip }} at kubelet
lineinfile:
path: '/etc/systemd/system/kubelet.service.d/10-kubeadm.conf'
line: 'Environment="KUBELET_EXTRA_ARGS=--node-ip={{ k8s_node_public_ip }}"'
regexp: 'KUBELET_EXTRA_ARGS='
insertafter: '\[Service\]'
state: present
notify: restart kubelet
- name: restart containerd
service:
name: containerd
state: restarted
daemon_reload: yes
- name: Delete configuration for containerd.conf (see https://github.com/containerd/containerd/issues/4581)
file:
state: absent
path: /etc/containerd/config.toml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment