remove unused files and code
This commit is contained in:
@@ -76,12 +76,6 @@
|
||||
register: node_ready
|
||||
changed_when: false
|
||||
|
||||
# - name: Remove taint from control plane node
|
||||
# shell: kubectl --kubeconfig=/etc/kubernetes/admin.conf taint nodes --all node-role.kubernetes.io/control-plane-
|
||||
# register: taint_result
|
||||
# changed_when: "'untainted' in taint_result.stdout"
|
||||
# failed_when: false # This might fail if the taint doesn't exist, which is fine
|
||||
|
||||
- name: Remove load balancer label from all nodes
|
||||
shell: kubectl --kubeconfig=/etc/kubernetes/admin.conf label nodes --all node.kubernetes.io/exclude-from-external-load-balancers-
|
||||
register: label_result
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
---
|
||||
# ansible/tasks/kubernetes/debug-containerd.yml
|
||||
|
||||
- name: Get containerd status
|
||||
command: systemctl status containerd
|
||||
register: containerd_status
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
|
||||
- name: Display containerd status
|
||||
debug:
|
||||
var: containerd_status.stdout_lines
|
||||
|
||||
- name: Get containerd configuration
|
||||
command: cat /etc/containerd/config.toml
|
||||
register: containerd_config
|
||||
changed_when: false
|
||||
|
||||
- name: Display containerd configuration
|
||||
debug:
|
||||
var: containerd_config.stdout_lines
|
||||
|
||||
- name: Fix containerd configuration directly
|
||||
block:
|
||||
- name: Create a minimal containerd configuration
|
||||
copy:
|
||||
content: |
|
||||
version = 2
|
||||
|
||||
[plugins]
|
||||
[plugins."io.containerd.grpc.v1.cri"]
|
||||
sandbox_image = "registry.k8s.io/pause:3.10"
|
||||
[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'
|
||||
register: new_config
|
||||
|
||||
- name: Restart containerd
|
||||
systemd:
|
||||
name: containerd
|
||||
state: restarted
|
||||
when: new_config.changed
|
||||
|
||||
- name: Pull the pause image manually
|
||||
command: crictl pull registry.k8s.io/pause:3.10
|
||||
register: pull_result
|
||||
changed_when: pull_result.rc == 0
|
||||
failed_when: false
|
||||
|
||||
- name: Display pull result
|
||||
debug:
|
||||
var: pull_result.stdout_lines
|
||||
|
||||
- name: Verify sandbox image
|
||||
command: crictl images
|
||||
register: images
|
||||
changed_when: false
|
||||
|
||||
- name: Display available images
|
||||
debug:
|
||||
var: images.stdout_lines
|
||||
|
||||
- name: Reset kubeadm if needed
|
||||
command: kubeadm reset -f
|
||||
register: reset_result
|
||||
changed_when: reset_result.rc == 0
|
||||
failed_when: false
|
||||
|
||||
- name: Display reset result
|
||||
debug:
|
||||
var: reset_result.stdout_lines
|
||||
|
||||
- name: Clean up Kubernetes directories
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- /etc/kubernetes
|
||||
- /var/lib/kubelet
|
||||
- /var/lib/etcd
|
||||
changed_when: false
|
||||
@@ -1,169 +0,0 @@
|
||||
---
|
||||
# ansible/tasks/kubernetes/install-containerd.yml
|
||||
- name: Ensure runc is installed (Debian/Ubuntu)
|
||||
apt:
|
||||
name: runc
|
||||
state: present
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Create work directory for containerd installation
|
||||
file:
|
||||
path: "{{ containerd_work_dir }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Download containerd tarball
|
||||
get_url:
|
||||
url: "https://github.com/containerd/containerd/releases/download/v{{ containerd_version }}/containerd-{{ containerd_version }}-linux-{{ containerd_arch }}.tar.gz"
|
||||
dest: "{{ containerd_work_dir }}/containerd.tar.gz"
|
||||
checksum: "{{ containerd_checksum }}"
|
||||
mode: '0644'
|
||||
|
||||
- name: Extract containerd binaries to install directory
|
||||
unarchive:
|
||||
src: "{{ containerd_work_dir }}/containerd.tar.gz"
|
||||
dest: "{{ containerd_install_root }}"
|
||||
remote_src: yes
|
||||
|
||||
- name: Create containerd config directory
|
||||
file:
|
||||
path: "{{ containerd_config_root }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Detect if containerd is already installed
|
||||
stat:
|
||||
path: "{{ containerd_binary_path }}/containerd"
|
||||
register: containerd_binary
|
||||
|
||||
- name: Generate default containerd configuration
|
||||
command: "{{ containerd_binary_path }}/containerd config default"
|
||||
register: default_config
|
||||
changed_when: false
|
||||
when: containerd_binary.stat.exists
|
||||
|
||||
- name: Ensure containerd group exists
|
||||
group:
|
||||
name: "{{ containerd_group }}"
|
||||
system: yes
|
||||
state: present
|
||||
|
||||
- name: Get containerd group GID
|
||||
shell: "getent group {{ containerd_group }} | cut -d: -f3"
|
||||
register: containerd_gid_cmd
|
||||
changed_when: false
|
||||
|
||||
- name: Write containerd configuration file
|
||||
copy:
|
||||
content: "{{ default_config.stdout }}"
|
||||
dest: "{{ containerd_config_root }}/config.toml"
|
||||
mode: '0644'
|
||||
when: containerd_binary.stat.exists and default_config.stdout is defined
|
||||
register: config_written
|
||||
|
||||
- name: Update containerd config for SystemdCgroup
|
||||
replace:
|
||||
path: "{{ containerd_config_root }}/config.toml"
|
||||
regexp: 'SystemdCgroup = false'
|
||||
replace: 'SystemdCgroup = true'
|
||||
when: config_written.changed or containerd_binary.stat.exists
|
||||
notify: Restart containerd
|
||||
|
||||
- name: Update containerd config for Kubernetes sandbox image
|
||||
lineinfile:
|
||||
path: "{{ containerd_config_root }}/config.toml"
|
||||
regexp: '(\s*)sandbox_image\s*=\s*".*"'
|
||||
line: '\1sandbox_image = "registry.k8s.io/pause:3.10"'
|
||||
backrefs: yes
|
||||
when: config_written.changed or containerd_binary.stat.exists
|
||||
notify: Restart containerd
|
||||
|
||||
- name: Ensure containerd config has sandbox_image set
|
||||
lineinfile:
|
||||
path: "{{ containerd_config_root }}/config.toml"
|
||||
insertafter: '^\[plugins\."io\.containerd\.grpc\.v1\.cri"\]'
|
||||
line: ' sandbox_image = "registry.k8s.io/pause:3.10"'
|
||||
state: present
|
||||
when: containerd_binary.stat.exists
|
||||
notify: Restart containerd
|
||||
|
||||
- name: Make sure CRI plugin is not disabled
|
||||
replace:
|
||||
path: "{{ containerd_config_root }}/config.toml"
|
||||
regexp: 'disabled_plugins\s*=\s*\[\s*"cri"\s*\]'
|
||||
replace: 'disabled_plugins = []'
|
||||
when: containerd_binary.stat.exists
|
||||
notify: Restart containerd
|
||||
|
||||
- name: Update containerd config for GRPC socket group (gid)
|
||||
replace:
|
||||
path: "{{ containerd_config_root }}/config.toml"
|
||||
regexp: '^(\s*gid\s*=\s*)0'
|
||||
replace: '\g<1>{{ containerd_gid_cmd.stdout }}'
|
||||
when: config_written.changed or containerd_binary.stat.exists
|
||||
notify: Restart containerd
|
||||
|
||||
- name: Create containerd systemd service file
|
||||
copy:
|
||||
dest: "{{ containerd_systemd_root }}/containerd.service"
|
||||
mode: '0644'
|
||||
content: |
|
||||
[Unit]
|
||||
Description=containerd container runtime
|
||||
Documentation=https://containerd.io
|
||||
After=network.target network-online.target
|
||||
|
||||
[Service]
|
||||
ExecStart={{ containerd_binary_path }}/containerd --config {{ containerd_config_root }}/config.toml
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
Delegate=yes
|
||||
KillMode=process
|
||||
OOMScoreAdjust=-999
|
||||
LimitNOFILE=1048576
|
||||
LimitNPROC=infinity
|
||||
LimitCORE=infinity
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
notify: Restart containerd
|
||||
|
||||
- name: Add current user to containerd group
|
||||
user:
|
||||
name: "{{ ansible_user }}"
|
||||
groups: "{{ containerd_group }}"
|
||||
append: yes
|
||||
|
||||
- name: Reload systemd daemon
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
|
||||
- name: Enable and start containerd service
|
||||
systemd:
|
||||
name: containerd
|
||||
enabled: yes
|
||||
state: started
|
||||
|
||||
- name: Restart containerd immediately if needed
|
||||
systemd:
|
||||
name: containerd
|
||||
state: restarted
|
||||
when: containerd_binary.stat.exists
|
||||
|
||||
- name: Configure crictl to use containerd
|
||||
copy:
|
||||
dest: /etc/crictl.yaml
|
||||
content: |
|
||||
runtime-endpoint: unix:///run/containerd/containerd.sock
|
||||
image-endpoint: unix:///run/containerd/containerd.sock
|
||||
timeout: 10
|
||||
debug: false
|
||||
mode: '0644'
|
||||
|
||||
- name: Set permissions for containerd socket
|
||||
file:
|
||||
path: /run/containerd/containerd.sock
|
||||
owner: root
|
||||
group: "{{ containerd_group }}"
|
||||
mode: '0660'
|
||||
when: ansible_system_vendor != 'Microsoft Corporation' # Avoid issues on WSL2
|
||||
Reference in New Issue
Block a user