summaryrefslogtreecommitdiff
path: root/roles/kubernetes/base/tasks/cri_docker.yml
blob: 626395b738474384c8d0faf3fa6c8cdbe53bf35b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
- name: make sure the kubernetes_cri_socket variable is configured correctly
  assert:
    msg: "The variable kubernetes_cri_socket is not configured correctly. You might need to move your host to the group kubernetes-cluster or standalone-kubelet!"
    that:
    - kubernetes_cri_socket == "unix:///var/run/cri-dockerd.sock"

- name: create systemd snippet directory
  file:
    path: /etc/systemd/system/kubelet.service.d/
    state: directory

- name: install systemd snippet to make sure kubelet starts after cri-dockerd
  copy:
    content: |
      [Unit]
      After=cri-docker.service
    dest: /etc/systemd/system/kubelet.service.d/after-docker.conf

- name: disable bridge and iptables in docker daemon config and switch to systemd cgroup driver
  set_fact:
    docker_daemon_config_override:
      exec-opts:
      - "native.cgroupdriver=systemd"
      bridge: "none"
      iptables: false
      log-driver: "json-file"
      log-opts:
        max-size: "20M"
        max-file: "3"

- name: override mandatory settings in docker_daemon_config
  set_fact:
    docker_daemon_config: "{{ docker_daemon_config | default({}) | combine(docker_daemon_config_override, recursive=True, list_merge='append') }}"

- name: install docker
  include_role:
    name: docker/engine

- name: install cri-dockerd
  apt:
    name: cri-dockerd
    state: present

- name: install systemd units for cri-docker
  loop:
  - socket
  - service
  template:
    src: "cri-docker.{{ item }}.j2"
    dest: "/etc/systemd/system/cri-docker.{{ item }}"

- name: make sure cri-docker is started and enabled
  loop:
  - socket
  - service
  systemd:
    daemon_reload: yes
    name: "cri-docker.{{ item }}"
    enabled: yes
    state: started