mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-03-23 03:45:03 -02:30
Enable containerd to deploy vanilla containerd package (#4951)
* Enable containerd to deploy vanilla containerd package Fixes kubeadm references to CRI socket for containerd Fixes download role cache feature to work with containerd Change-Id: I2ab8f0031107e2f0d1a85c39b4beb66f08509a01 * use containerd for flannel-addons job Change-Id: Ied375c7d65e64a625ffbd995ff16f2374067dee6 * add containerd vars Change-Id: Ib9a8a04e501c481a86235413cbec63f3672baf91 * fixup vars Change-Id: Ibea64e4b18405a578b52a13da100384582aa24c2 * more fixes * fix rh repo Change-Id: I00575a77cfb7b81d6095db5d918a52023c8f13ba * Adjust helm host install for containerd
This commit is contained in:
committed by
Kubernetes Prow Robot
parent
a038d62644
commit
29307740dd
106
roles/container-engine/containerd/tasks/containerd_repo.yml
Normal file
106
roles/container-engine/containerd/tasks/containerd_repo.yml
Normal file
@@ -0,0 +1,106 @@
|
||||
---
|
||||
- name: ensure containerd repository public key is installed
|
||||
action: "{{ containerd_repo_key_info.pkg_key }}"
|
||||
args:
|
||||
id: "{{ item }}"
|
||||
url: "{{ containerd_repo_key_info.url }}"
|
||||
state: present
|
||||
register: keyserver_task_result
|
||||
until: keyserver_task_result is succeeded
|
||||
retries: 4
|
||||
delay: "{{ retry_stagger | d(3) }}"
|
||||
with_items: "{{ containerd_repo_key_info.repo_keys }}"
|
||||
when:
|
||||
- ansible_os_family in ['Ubuntu', 'Debian']
|
||||
- not is_atomic
|
||||
|
||||
- name: ensure containerd repository is enabled
|
||||
action: "{{ containerd_repo_info.pkg_repo }}"
|
||||
args:
|
||||
repo: "{{ item }}"
|
||||
state: present
|
||||
with_items: "{{ containerd_repo_info.repos }}"
|
||||
when:
|
||||
- ansible_os_family in ['Ubuntu', 'Debian']
|
||||
- not is_atomic
|
||||
- containerd_repo_info.repos|length > 0
|
||||
|
||||
# This is required to ensure any apt upgrade will not break kubernetes
|
||||
- name: Set containerd pin priority to apt_preferences on Debian family
|
||||
template:
|
||||
src: "apt_preferences.d/debian_containerd.j2"
|
||||
dest: "/etc/apt/preferences.d/containerd"
|
||||
owner: "root"
|
||||
mode: 0644
|
||||
when:
|
||||
- ansible_os_family in ['Ubuntu', 'Debian']
|
||||
- not is_atomic
|
||||
|
||||
- name: ensure containerd repository public key is installed
|
||||
action: "{{ containerd_repo_key_info.pkg_key }}"
|
||||
args:
|
||||
id: "{{ item }}"
|
||||
url: "{{ containerd_repo_key_info.url }}"
|
||||
state: present
|
||||
register: keyserver_task_result
|
||||
until: keyserver_task_result is succeeded
|
||||
retries: 4
|
||||
delay: "{{ retry_stagger | d(3) }}"
|
||||
with_items: "{{ containerd_repo_key_info.repo_keys }}"
|
||||
when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS", "RedHat", "Suse", "ClearLinux"] or is_atomic)
|
||||
|
||||
- name: ensure containerd repository is enabled
|
||||
action: "{{ containerd_repo_info.pkg_repo }}"
|
||||
args:
|
||||
repo: "{{ item }}"
|
||||
state: present
|
||||
with_items: "{{ containerd_repo_info.repos }}"
|
||||
when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS", "RedHat", "Suse", "ClearLinux"] or is_atomic) and (containerd_repo_info.repos|length > 0)
|
||||
|
||||
- name: Configure containerd repository on Fedora
|
||||
template:
|
||||
src: "fedora_containerd.repo.j2"
|
||||
dest: "{{ yum_repo_dir }}/containerd.repo"
|
||||
when: ansible_distribution == "Fedora" and not is_atomic
|
||||
|
||||
- name: Configure containerd repository on RedHat/CentOS
|
||||
template:
|
||||
src: "rh_containerd.repo.j2"
|
||||
dest: "{{ yum_repo_dir }}/containerd.repo"
|
||||
when: ansible_distribution in ["CentOS","RedHat"] and not is_atomic
|
||||
|
||||
- name: check if container-selinux is available
|
||||
yum:
|
||||
list: "container-selinux"
|
||||
register: yum_result
|
||||
when: ansible_distribution in ["CentOS","RedHat"] and not is_atomic
|
||||
|
||||
- name: Configure extras repository on RedHat/CentOS if container-selinux is not available in current repos
|
||||
yum_repository:
|
||||
name: extras
|
||||
description: "CentOS-7 - Extras"
|
||||
state: present
|
||||
baseurl: "{{ extras_rh_repo_base_url }}"
|
||||
file: "extras"
|
||||
gpgcheck: yes
|
||||
gpgkey: "{{ extras_rh_repo_gpgkey }}"
|
||||
keepcache: "{{ containerd_rpm_keepcache | default('1') }}"
|
||||
proxy: " {{ http_proxy | default('_none_') }}"
|
||||
when:
|
||||
- ansible_distribution in ["CentOS","RedHat"] and not is_atomic
|
||||
- yum_result.results | length == 0
|
||||
|
||||
- name: Copy yum.conf for editing
|
||||
copy:
|
||||
src: "{{ yum_conf }}"
|
||||
dest: "{{ containerd_yum_conf }}"
|
||||
remote_src: yes
|
||||
when: ansible_distribution in ["CentOS","RedHat"] and not is_atomic
|
||||
|
||||
- name: Edit copy of yum.conf to set obsoletes=0
|
||||
lineinfile:
|
||||
path: "{{ containerd_yum_conf }}"
|
||||
state: present
|
||||
regexp: '^obsoletes='
|
||||
line: 'obsoletes=0'
|
||||
when: ansible_distribution in ["CentOS","RedHat"] and not is_atomic
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: crictl | Download crictl
|
||||
include_tasks: "roles/download/tasks/download_file.yml"
|
||||
include_tasks: "../../../download/tasks/download_file.yml"
|
||||
vars:
|
||||
download: "{{ download_defaults | combine(downloads.crictl) }}"
|
||||
|
||||
|
||||
@@ -5,27 +5,119 @@
|
||||
when:
|
||||
- not ansible_distribution in ["CentOS","RedHat", "Ubuntu", "Debian"]
|
||||
|
||||
- name: Install Docker
|
||||
include_role:
|
||||
name: container-engine/docker
|
||||
- name: gather os specific variables
|
||||
include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- files:
|
||||
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_version|lower|replace('/', '_') }}.yml"
|
||||
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }}-{{ host_architecture }}.yml"
|
||||
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }}.yml"
|
||||
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml"
|
||||
- "{{ ansible_distribution|lower }}-{{ host_architecture }}.yml"
|
||||
- "{{ ansible_distribution|lower }}.yml"
|
||||
- "{{ ansible_os_family|lower }}-{{ host_architecture }}.yml"
|
||||
- "{{ ansible_os_family|lower }}.yml"
|
||||
- defaults.yml
|
||||
paths:
|
||||
- ../vars
|
||||
skip: true
|
||||
tags:
|
||||
- facts
|
||||
|
||||
- name: Install config.toml
|
||||
- include_tasks: containerd_repo.yml
|
||||
|
||||
- name: ensure containerd config directory
|
||||
file:
|
||||
dest: "{{ containerd_cfg_dir }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: Copy containerd config file
|
||||
template:
|
||||
src: config.toml.j2
|
||||
dest: /etc/containerd/config.toml
|
||||
owner: bin
|
||||
dest: "{{ containerd_cfg_dir }}/config.toml"
|
||||
owner: "root"
|
||||
mode: 0644
|
||||
notify: restart containerd
|
||||
|
||||
- name: Stop and disabled Docker
|
||||
systemd:
|
||||
name: docker
|
||||
state: stopped
|
||||
enabled: no
|
||||
|
||||
- name: Restart containerd
|
||||
systemd:
|
||||
name: containerd
|
||||
state: restarted
|
||||
- name: ensure containerd repository public key is installed
|
||||
action: "{{ containerd_repo_key_info.pkg_key }}"
|
||||
args:
|
||||
id: "{{ item }}"
|
||||
url: "{{ containerd_repo_key_info.url }}"
|
||||
state: present
|
||||
register: keyserver_task_result
|
||||
until: keyserver_task_result is succeeded
|
||||
retries: 4
|
||||
delay: "{{ retry_stagger | d(3) }}"
|
||||
with_items: "{{ containerd_repo_key_info.repo_keys }}"
|
||||
when:
|
||||
- ansible_os_family in ['Ubuntu', 'Debian']
|
||||
- not is_atomic
|
||||
|
||||
- name: ensure containerd repository is enabled
|
||||
action: "{{ containerd_repo_info.pkg_repo }}"
|
||||
args:
|
||||
repo: "{{ item }}"
|
||||
state: present
|
||||
with_items: "{{ containerd_repo_info.repos }}"
|
||||
when:
|
||||
- ansible_os_family in ['Ubuntu', 'Debian']
|
||||
- not is_atomic
|
||||
- containerd_repo_info.repos|length > 0
|
||||
|
||||
# This is required to ensure any apt upgrade will not break kubernetes
|
||||
- name: Set containerd pin priority to apt_preferences on Debian family
|
||||
template:
|
||||
src: "apt_preferences.d/debian_containerd.j2"
|
||||
dest: "/etc/apt/preferences.d/containerd"
|
||||
owner: "root"
|
||||
mode: 0644
|
||||
when:
|
||||
- ansible_os_family in ['Ubuntu', 'Debian']
|
||||
- not is_atomic
|
||||
|
||||
- name: ensure containerd packages are installed
|
||||
action: "{{ containerd_package_info.pkg_mgr }}"
|
||||
args:
|
||||
pkg: "{{ item.name }}"
|
||||
force: "{{ item.force | default(omit) }}"
|
||||
conf_file: "{{ item.yum_conf | default(omit) }}"
|
||||
state: present
|
||||
update_cache: "{{ omit if ansible_distribution == 'Fedora' else True }}"
|
||||
register: containerd_task_result
|
||||
until: containerd_task_result is succeeded
|
||||
retries: 4
|
||||
delay: "{{ retry_stagger | d(3) }}"
|
||||
with_items: "{{ containerd_package_info.pkgs }}"
|
||||
notify: restart containerd
|
||||
when:
|
||||
- not is_atomic
|
||||
- containerd_package_info.pkgs|length > 0
|
||||
ignore_errors: true
|
||||
|
||||
- name: Check if runc is installed
|
||||
stat:
|
||||
path: /usr/sbin/runc
|
||||
register: runc_stat
|
||||
|
||||
- name: Install runc package if necessary
|
||||
action: "{{ containerd_package_info.pkg_mgr }}"
|
||||
args:
|
||||
pkg: runc
|
||||
state: present
|
||||
update_cache: "{{ omit if ansible_distribution == 'Fedora' else True }}"
|
||||
register: runc_task_result
|
||||
until: runc_task_result is succeeded
|
||||
retries: 4
|
||||
delay: "{{ retry_stagger | d(3) }}"
|
||||
notify: restart containerd
|
||||
when:
|
||||
- not is_atomic
|
||||
- not runc_stat.stat.exists
|
||||
|
||||
- name: Install crictl config
|
||||
template:
|
||||
@@ -35,16 +127,6 @@
|
||||
mode: 0644
|
||||
|
||||
- name: Install crictl completion
|
||||
shell: /usr/local/bin/crictl completion >/etc/bash_completion.d/crictl
|
||||
shell: "{{ bin_dir }}/crictl completion >/etc/bash_completion.d/crictl"
|
||||
ignore_errors: True
|
||||
when: ansible_distribution in ["CentOS","RedHat", "Ubuntu", "Debian"]
|
||||
|
||||
- name: Enable containerd
|
||||
systemd:
|
||||
name: containerd.service
|
||||
state: started
|
||||
enabled: yes
|
||||
daemon-reload: yes
|
||||
|
||||
- name: flush handlers so we can wait for containerd to come up
|
||||
meta: flush_handlers
|
||||
|
||||
Reference in New Issue
Block a user