diff options
author | Christian Pointner <equinox@spreadspace.org> | 2019-10-10 23:36:51 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2019-10-10 23:37:00 +0200 |
commit | 6d65dac3d747cd126eaa71463237f290b12360f3 (patch) | |
tree | bbd37676079469e443e05774bca0118aaa4657b6 /roles/kubernetes | |
parent | added zfs support for docker (diff) |
added role for containerd and improve kubernetes/base
Diffstat (limited to 'roles/kubernetes')
-rw-r--r-- | roles/kubernetes/base/tasks/lvm.yml | 18 | ||||
-rw-r--r-- | roles/kubernetes/base/tasks/main.yml | 45 | ||||
-rw-r--r-- | roles/kubernetes/base/tasks/zfs.yml | 15 |
3 files changed, 58 insertions, 20 deletions
diff --git a/roles/kubernetes/base/tasks/lvm.yml b/roles/kubernetes/base/tasks/lvm.yml new file mode 100644 index 00000000..3ef36e89 --- /dev/null +++ b/roles/kubernetes/base/tasks/lvm.yml @@ -0,0 +1,18 @@ +--- +- name: create logical volume + lvol: + vg: "{{ kubelet_lvm.vg }}" + lv: "{{ kubelet_lvm.lv }}" + size: "{{ kubelet_lvm.size }}" + +- name: create filesystem + filesystem: + fstype: "{{ kubelet_lvm.fs }}" + dev: "/dev/mapper/{{ kubelet_lvm.vg | replace('-', '--') }}-{{ kubelet_lvm.lv | replace('-', '--') }}" + +- name: mount filesytem + mount: + src: "/dev/mapper/{{ kubelet_lvm.vg | replace('-', '--') }}-{{ kubelet_lvm.lv | replace('-', '--') }}" + path: /var/lib/kubelet + fstype: "{{ kubelet_lvm.fs }}" + state: mounted diff --git a/roles/kubernetes/base/tasks/main.yml b/roles/kubernetes/base/tasks/main.yml index 0b0be821..375bb63e 100644 --- a/roles/kubernetes/base/tasks/main.yml +++ b/roles/kubernetes/base/tasks/main.yml @@ -1,25 +1,11 @@ --- - name: prepare /var/lib/kubelet as LVM when: kubelet_lvm is defined - block: + import_tasks: lvm.yml - - name: create logical volume - lvol: - vg: "{{ kubelet_lvm.vg }}" - lv: "{{ kubelet_lvm.lv }}" - size: "{{ kubelet_lvm.size }}" - - - name: create filesystem - filesystem: - fstype: "{{ kubelet_lvm.fs }}" - dev: "/dev/mapper/{{ kubelet_lvm.vg | replace('-', '--') }}-{{ kubelet_lvm.lv | replace('-', '--') }}" - - - name: mount filesytem - mount: - src: "/dev/mapper/{{ kubelet_lvm.vg | replace('-', '--') }}-{{ kubelet_lvm.lv | replace('-', '--') }}" - path: /var/lib/kubelet - fstype: "{{ kubelet_lvm.fs }}" - state: mounted +- name: prepare /var/lib/kubelet as ZFS dataset + when: kubelet_zfs is defined + import_tasks: zfs.yml - name: install apt https transport apt: @@ -35,17 +21,19 @@ - name: add repository entry copy: content: | - deb http://apt.kubernetes.io/ kubernetes-xenial main + deb https://apt.kubernetes.io/ kubernetes-xenial main dest: /etc/apt/sources.list.d/kubernetes.list notify: update apt cache - name: update apt cache meta: flush_handlers -- name: install kubelet +- name: install kubelet and utils apt: name: - "kubelet{% if kubernetes.pkg_version is defined %}={{ kubernetes.pkg_version }}{% endif %}" + - cri-tools + - bridge-utils state: present - name: disable automatic upgrades for kubelet @@ -56,6 +44,23 @@ name: "{{ item }}" selection: hold +- name: configure crictl to use containerd + when: kubernetes_container_runtime == 'containerd' + loop: + - zsh + - bash + blockinfile: + path: "/root/.{{ item }}rc" + create: yes + marker: "### {mark} ANSIBLE MANAGED BLOCK for crictl ###" + content: | + alias crictl="crictl --runtime-endpoint unix:///run/containerd/containerd.sock" + {% if item == 'zsh' %} + ## TODO: see https://github.com/kubernetes-sigs/cri-tools/issues/435 + autoload -U +X bashcompinit && bashcompinit + {% endif %} + source <(crictl completion) + - name: add dummy group with gid 998 group: name: app diff --git a/roles/kubernetes/base/tasks/zfs.yml b/roles/kubernetes/base/tasks/zfs.yml new file mode 100644 index 00000000..4311dd3f --- /dev/null +++ b/roles/kubernetes/base/tasks/zfs.yml @@ -0,0 +1,15 @@ +--- +- name: create zfs dataset + zfs: + name: "{{ kubelet_zfs.pool }}/{{ kubelet_zfs.name }}" + state: present + extra_zfs_properties: + quota: "{{ kubelet_zfs.size }}" + +- name: bind mount filesytem + mount: + src: "{{ zfs_zpools[kubelet_zfs.pool].mountpoint }}/{{ kubelet_zfs.name }}" + path: /var/lib/kubelet + fstype: none + opts: bind,x-systemd.automount,nofail + state: mounted |