diff --git a/inventory/sample/group_vars/k8s-cluster/k8s-cluster.yml b/inventory/sample/group_vars/k8s-cluster/k8s-cluster.yml index 7df70a753ad5ad8f7b812909ff47a53da53bebfb..7a49bee1953bd0d72c8f3698075260390f18a606 100644 --- a/inventory/sample/group_vars/k8s-cluster/k8s-cluster.yml +++ b/inventory/sample/group_vars/k8s-cluster/k8s-cluster.yml @@ -191,6 +191,9 @@ podsecuritypolicy_enabled: false # Acceptable options are 'pods', 'system-reserved', 'kube-reserved' and ''. Default is "". # kubelet_enforce_node_allocatable: pods +# An alternative flexvolume plugin directory +# kubelet_flexvolumes_plugins_dir: /usr/libexec/kubernetes/kubelet-plugins/volume/exec + ## Supplementary addresses that can be added in kubernetes ssl keys. ## That can be useful for example to setup a keepalived virtual IP # supplementary_addresses_in_ssl_keys: [10.0.0.1, 10.0.0.2, 10.0.0.3] diff --git a/roles/kubernetes/node/defaults/main.yml b/roles/kubernetes/node/defaults/main.yml index 64502af654f0fabee33dcfb0636a2b63e739b849..3b549da86ffcb0edef7463805bc7b844de66465b 100644 --- a/roles/kubernetes/node/defaults/main.yml +++ b/roles/kubernetes/node/defaults/main.yml @@ -50,8 +50,6 @@ loadbalancer_apiserver_cpu_requests: 25m # - extensions/v1beta1/daemonsets=true # - extensions/v1beta1/deployments=true -kubelet_flexvolumes_plugins_dir: /usr/libexec/kubernetes/kubelet-plugins/volume/exec - # A port range to reserve for services with NodePort visibility. # Inclusive at both ends of the range. kube_apiserver_node_port_range: "30000-32767" diff --git a/roles/kubernetes/node/templates/kubelet.service.j2 b/roles/kubernetes/node/templates/kubelet.service.j2 index 4b4dce7c7379b4f646139007bda9e7f7f981aa81..71c97e0d0eee198fe98f8540fc29453648bcd776 100644 --- a/roles/kubernetes/node/templates/kubelet.service.j2 +++ b/roles/kubernetes/node/templates/kubelet.service.j2 @@ -7,7 +7,6 @@ Wants=docker.socket [Service] User=root EnvironmentFile=-{{ kube_config_dir }}/kubelet.env -ExecStartPre=-/bin/mkdir -p {{ kubelet_flexvolumes_plugins_dir }} ExecStart={{ bin_dir }}/kubelet \ $KUBE_LOGTOSTDERR \ $KUBE_LOG_LEVEL \ diff --git a/roles/kubernetes/preinstall/defaults/main.yml b/roles/kubernetes/preinstall/defaults/main.yml index 926de4e3e39b74d6b3e334fe8de60e0aa92009c6..1ffcfb346520a0ff2870bdbd760104977e17c155 100644 --- a/roles/kubernetes/preinstall/defaults/main.yml +++ b/roles/kubernetes/preinstall/defaults/main.yml @@ -25,6 +25,7 @@ kube_cert_group: kube-cert kube_config_dir: /etc/kubernetes kube_cert_dir: "{{ kube_config_dir }}/ssl" kube_cert_compat_dir: /etc/kubernetes/pki +kubelet_flexvolumes_plugins_dir: /usr/libexec/kubernetes/kubelet-plugins/volume/exec # Container Linux by CoreOS cloud init config file to define /etc/resolv.conf content # for hostnet pods and infra needs diff --git a/roles/kubernetes/preinstall/tasks/0040-set_facts.yml b/roles/kubernetes/preinstall/tasks/0040-set_facts.yml index 939da53a499e153d8d5d97fb8613bc487a09b704..4a6318cc9a05cb69f5d6870994beb4c612eab304 100644 --- a/roles/kubernetes/preinstall/tasks/0040-set_facts.yml +++ b/roles/kubernetes/preinstall/tasks/0040-set_facts.yml @@ -178,3 +178,13 @@ etcd_deployment_type: host when: - etcd_kubeadm_enabled + +- name: check /usr readonly + stat: + path: "/usr" + register: usr + +- name: set alternate flexvolume path + set_fact: + kubelet_flexvolumes_plugins_dir: /var/lib/kubelet/volumeplugins + when: not usr.stat.writeable diff --git a/roles/kubernetes/preinstall/tasks/0050-create_directories.yml b/roles/kubernetes/preinstall/tasks/0050-create_directories.yml index 4ba782bdc865311ef4b7bf039baefddb48fb030c..07dccd475d5246f7666457cd896d2096357baa75 100644 --- a/roles/kubernetes/preinstall/tasks/0050-create_directories.yml +++ b/roles/kubernetes/preinstall/tasks/0050-create_directories.yml @@ -22,6 +22,7 @@ - "{{ kube_cert_dir }}" - "{{ kube_manifest_dir }}" - "{{ kube_script_dir }}" + - "{{ kubelet_flexvolumes_plugins_dir }}" - name: Check if kubernetes kubeadm compat cert dir exists stat: