Mount local volume provisioner dirs for containerized kubelet (#2648)

This commit is contained in:
Matthew Mosesohn 2018-04-12 22:55:13 +03:00 committed by GitHub
parent 1967963702
commit f73717ea35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 0 deletions

View file

@ -29,6 +29,10 @@
{% if '/var/lib/kubelet' not in kubelet_flexvolumes_plugins_dir %} {% if '/var/lib/kubelet' not in kubelet_flexvolumes_plugins_dir %}
-v {{ kubelet_flexvolumes_plugins_dir }}:{{ kubelet_flexvolumes_plugins_dir }}:rw \ -v {{ kubelet_flexvolumes_plugins_dir }}:{{ kubelet_flexvolumes_plugins_dir }}:rw \
{% endif -%} {% endif -%}
{% if local_volume_provisioner_enabled -%}
-v {{ local_volume_provisioner_base_dir }}:{{ local_volume_provisioner_base_dir }}:rw \
-v {{ local_volume_provisioner_mount_dir }}:{{ local_volume_provisioner_mount_dir }}:rw \
{% endif %}
-v {{kube_config_dir}}:{{kube_config_dir}}:ro \ -v {{kube_config_dir}}:{{kube_config_dir}}:ro \
-v /etc/os-release:/etc/os-release:ro \ -v /etc/os-release:/etc/os-release:ro \
{{ hyperkube_image_repo }}:{{ hyperkube_image_tag}} \ {{ hyperkube_image_repo }}:{{ hyperkube_image_tag}} \

View file

@ -43,6 +43,14 @@ ExecStart=/usr/bin/rkt run \
{% if '/var/lib/kubelet' not in kubelet_flexvolumes_plugins_dir %} {% if '/var/lib/kubelet' not in kubelet_flexvolumes_plugins_dir %}
--volume flexvolumes,kind=host,source={{ kubelet_flexvolumes_plugins_dir }},readOnly=false \ --volume flexvolumes,kind=host,source={{ kubelet_flexvolumes_plugins_dir }},readOnly=false \
{% endif %} {% endif %}
{% if local_volume_provisioner_enabled %}
--volume local_volume_provisioner_base_dir,kind=host,source={{ local_volume_provisioner_base_dir }},readOnly=false \
{# Not pretty, but needed to avoid double mount #}
{% if local_volume_provisioner_base_dir not in local_volume_provisioner_mount_dir and local_volume_provisioner_mount_dir not in local_volume_provisioner_base_dir %}
--volume local_volume_provisioner_mount_dir,kind=host,source={{ local_volume_provisioner_mount_dir }},readOnly=false \
{% endif %}
{% endif %}
{% if kubelet_load_modules == true %} {% if kubelet_load_modules == true %}
--mount volume=modprobe,target=/usr/sbin/modprobe \ --mount volume=modprobe,target=/usr/sbin/modprobe \
--mount volume=lib-modules,target=/lib/modules \ --mount volume=lib-modules,target=/lib/modules \
@ -69,6 +77,14 @@ ExecStart=/usr/bin/rkt run \
{% if '/var/lib/kubelet' not in kubelet_flexvolumes_plugins_dir %} {% if '/var/lib/kubelet' not in kubelet_flexvolumes_plugins_dir %}
--mount volume=flexvolumes,target={{ kubelet_flexvolumes_plugins_dir }} \ --mount volume=flexvolumes,target={{ kubelet_flexvolumes_plugins_dir }} \
{% endif %} {% endif %}
{% if local_volume_provisioner_enabled %}
--mount local_volume_provisioner_base_dir,target={{ local_volume_provisioner_base_dir }} \
{# Not pretty, but needed to avoid double mount #}
{% if local_volume_provisioner_base_dir not in local_volume_provisioner_mount_dir and local_volume_provisioner_mount_dir not in local_volume_provisioner_base_dir %}
--volume local_volume_provisioner_mount_dir,target={{ local_volume_provisioner_mount_dir }} \
{% endif %}
{% endif %}
--stage1-from-dir=stage1-fly.aci \ --stage1-from-dir=stage1-fly.aci \
{% if kube_hyperkube_image_repo == "docker" %} {% if kube_hyperkube_image_repo == "docker" %}
--insecure-options=image \ --insecure-options=image \

View file

@ -96,6 +96,20 @@
- contiv - contiv
- bootstrap-os - bootstrap-os
- name: Create local volume provisioner directories
file:
path: "{{ item }}"
state: directory
owner: kube
with_items:
- "{{ local_volume_provisioner_base_dir }}"
- "{{ local_volume_provisioner_mount_dir }}"
when:
- inventory_hostname in groups['k8s-cluster']
- local_volume_provisioner_enabled
tags:
- persistent_volumes
- import_tasks: resolvconf.yml - import_tasks: resolvconf.yml
when: when:
- dns_mode != 'none' - dns_mode != 'none'