containerd + docker recovered

This commit is contained in:
Bartal Læarsson
2025-02-28 14:11:17 +00:00
parent 834fdd53b0
commit 96fc2d0d3e
3 changed files with 80 additions and 18 deletions
-11
View File
@@ -26,14 +26,3 @@ kubernetes_packages:
- kubelet - kubelet
- kubeadm - kubeadm
- kubectl - kubectl
# Containerd configuration
containerd_version: "2.0.0"
containerd_arch: "amd64"
containerd_checksum: "sha256:6f8da716941f7e89315cefaa6e5a8f1ff10b323ff46611313c455df7ab1ebee1"
containerd_work_dir: "/tmp/containerd-install"
containerd_install_root: "/usr/local"
containerd_config_root: "/etc/containerd"
containerd_systemd_root: "/etc/systemd/system"
containerd_binary_path: "{{ containerd_install_root }}/bin"
containerd_group: "containerd"
+4 -4
View File
@@ -6,15 +6,15 @@ all:
control_plane: control_plane:
hosts: hosts:
controlplane: controlplane:
ansible_host: 10.203.146.25 ansible_host: 10.203.146.36
workers: workers:
hosts: hosts:
node01: node01:
ansible_host: 10.203.146.23 ansible_host: 10.203.146.66
node02: node02:
ansible_host: 10.203.146.117 ansible_host: 10.203.146.212
node03: node03:
ansible_host: 10.203.146.104 ansible_host: 10.203.146.223
vars: vars:
ansible_user: ubuntu ansible_user: ubuntu
ansible_become: yes ansible_become: yes
+76 -3
View File
@@ -13,9 +13,82 @@
- gnupg - gnupg
state: present state: present
# Install containerd directly from GitHub release # Add Docker GPG key
- name: Install containerd directly from release - name: Add Docker GPG key
include_tasks: install-containerd.yml apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker repository
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
state: present
filename: docker
- name: Install containerd from Docker repository
apt:
name: containerd.io
state: present
update_cache: yes
- name: Create containerd directory
file:
path: /etc/containerd
state: directory
mode: '0755'
- name: Check if containerd config command works
command: which containerd
register: containerd_check
changed_when: false
failed_when: false
- name: Generate default containerd config (if containerd exists)
command: containerd config default
register: containerd_config
changed_when: false
when: containerd_check.rc == 0
- name: Create a basic containerd config (if command failed)
copy:
content: |
version = 2
[plugins]
[plugins."io.containerd.grpc.v1.cri"]
[plugins."io.containerd.grpc.v1.cri".containerd]
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes]
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
runtime_type = "io.containerd.runc.v2"
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true
dest: /etc/containerd/config.toml
owner: root
group: root
mode: '0644'
when: containerd_check.rc != 0
- name: Write containerd config from generated output
copy:
content: "{{ containerd_config.stdout }}"
dest: /etc/containerd/config.toml
owner: root
group: root
mode: '0644'
when: containerd_check.rc == 0 and containerd_config.stdout is defined and containerd_config.stdout != ""
- name: Enable SystemdCgroup in containerd config
replace:
path: /etc/containerd/config.toml
regexp: 'SystemdCgroup = false'
replace: 'SystemdCgroup = true'
when: containerd_check.rc == 0
- name: Restart containerd
systemd:
name: containerd
state: restarted
enabled: yes
# Continue with Kubernetes repository setup and installation # Continue with Kubernetes repository setup and installation
- name: Get latest Kubernetes version - name: Get latest Kubernetes version