Browse Source

Merge pull request #9028 from openshift-cherrypick-robot/cherry-pick-8964-to-master

[master] Fix flex volume location in openshift installs
Scott Dodson 6 years ago
parent
commit
b857beb96e

+ 2 - 0
roles/lib_utils/action_plugins/master_check_paths_in_config.py

@@ -32,6 +32,8 @@ ALLOWED_DIRS = (
     '/etc/origin/master/',
     '/var/lib/origin',
     '/etc/origin/cloudprovider',
+    '/etc/origin/kubelet-plugins',
+    '/usr/libexec/kubernetes/kubelet-plugins',
 )
 
 ALLOWED_DIRS_STRING = ', '.join(ALLOWED_DIRS)

+ 6 - 0
roles/openshift_control_plane/files/controller.yaml

@@ -33,6 +33,9 @@ spec:
        name: master-cloud-provider
      - mountPath: /etc/containers/registries.d/
        name: signature-import
+     - mountPath: /usr/libexec/kubernetes/kubelet-plugins
+       name: kubelet-plugins
+       mountPropagation: "HostToContainer"
     livenessProbe:
       httpGet:
         scheme: HTTPS
@@ -50,3 +53,6 @@ spec:
   - hostPath:
       path: /etc/containers/registries.d
     name: signature-import
+  - name: kubelet-plugins
+    hostPath:
+      path: /usr/libexec/kubernetes/kubelet-plugins

+ 14 - 0
roles/openshift_control_plane/tasks/main.yml

@@ -45,6 +45,20 @@
     path: "/etc/origin/master"
     state: directory
 
+- name: Create flexvolume directory when on atomic hosts
+  file:
+    state: directory
+    path: "{{ openshift_flexvolume_container_directory_default }}/volume/exec"
+    mode: '0750'
+  when: openshift_is_atomic | bool
+
+- name: Flex volume directory on non-atomic host
+  file:
+    state: directory
+    path: "/usr/libexec/kubernetes/kubelet-plugins/volume/exec/"
+    mode: '0750'
+  when: not openshift_is_atomic | bool
+
 - name: Create the policy file if it does not already exist
   command: >
     {{ openshift_client_binary }} adm create-bootstrap-policy-file

+ 10 - 0
roles/openshift_control_plane/tasks/static.yml

@@ -45,6 +45,16 @@
     - key: spec.containers[0].readinessProbe.httpGet.port
       value: "{{ openshift_master_api_port }}"
 
+- name: Update controller-manager static pod on atomic host
+  yedit:
+    src: "{{ mktemp.stdout }}/controller.yaml"
+    edits:
+    - key: spec.volumes[3].hostPath.path
+      value: "{{ openshift_flexvolume_container_directory_default }}"
+    - key: spec.containers[0].volumeMounts[3].mountPath
+      value: "{{ openshift_flexvolume_container_directory_default }}"
+  when: openshift_is_atomic | bool
+
 - name: ensure pod location exists
   file:
     path: "{{ openshift_control_plane_static_pod_location }}"

+ 4 - 0
roles/openshift_control_plane/templates/master.yaml.v1.j2

@@ -83,6 +83,10 @@ kubernetesMasterConfig:
     - VolumeScheduling=true
 {% endif %}
   controllerArguments: {{ openshift.master.controller_args | default(None) | lib_utils_to_padded_yaml( level=2 ) }}
+{% if openshift_is_atomic | bool %}
+    flex-volume-plugin-dir:
+    - "{{ openshift_flexvolume_container_directory_default }}/volume/exec"
+{% endif %}
 {% if openshift_master_use_persistentlocalvolumes | bool %}
     feature-gates:
     - PersistentLocalVolumes=true

+ 1 - 0
roles/openshift_facts/defaults/main.yml

@@ -142,3 +142,4 @@ openshift_node_groups:
       - 'node-role.kubernetes.io/infra=true,node-role.kubernetes.io/master=true,node-role.kubernetes.io/compute=true'
     edits: []
 openshift_master_manage_htpasswd: True
+openshift_flexvolume_container_directory_default: "/etc/origin/kubelet-plugins"

+ 7 - 0
roles/openshift_node/tasks/config.yml

@@ -47,6 +47,13 @@
     state: directory
     mode: 0755
 
+- name: Create flexvolume directory when running on atomic
+  file:
+    state: directory
+    path: "{{ openshift_flexvolume_container_directory_default }}/volume/exec"
+    mode: '0750'
+  when: openshift_is_atomic | bool
+
 - name: include aws provider credentials
   import_tasks: aws.yml
   when: not (openshift_node_use_instance_profiles | default(False))

+ 4 - 0
roles/openshift_node/templates/node.yaml.v1.j2

@@ -12,6 +12,10 @@ imageConfig:
   latest: {{ openshift_node_image_config_latest }}
 kind: NodeConfig
 kubeletArguments: {{  l2_openshift_node_kubelet_args  | default(None) | lib_utils_to_padded_yaml(level=1) }}
+{% if openshift_is_atomic | bool %}
+  volume-plugin-dir:
+  - "{{ openshift_flexvolume_container_directory_default }}/volume/exec"
+{% endif %}
 {% if openshift_use_crio | bool %}
   container-runtime:
   - remote

+ 4 - 0
roles/openshift_node_group/templates/node-config.yaml.j2

@@ -20,6 +20,10 @@ imageConfig:
   latest: false
 iptablesSyncPeriod: "{{ openshift_node_iptables_sync_period }}"
 kubeletArguments:
+{% if openshift_is_atomic | bool %}
+  volume-plugin-dir:
+  - "{{ openshift_flexvolume_container_directory_default }}/volume/exec"
+{% endif %}
 {% if openshift_use_crio | bool %}
   container-runtime:
   - remote