diff --git a/IM/connectors/Kubernetes.py b/IM/connectors/Kubernetes.py index 4fae9a23..b7d3ed08 100644 --- a/IM/connectors/Kubernetes.py +++ b/IM/connectors/Kubernetes.py @@ -450,7 +450,8 @@ def _generate_pod_data(self, namespace, name, outports, system, volumes, configm containers[0]['volumeMounts'] = containers[0].get('volumeMounts', []) for (cm_name, cm_mount_path) in configmaps: containers[0]['volumeMounts'].append( - {'name': cm_name, 'mountPath': cm_mount_path, 'readOnly': True}) + {'name': cm_name, 'mountPath': cm_mount_path, "readOnly": True, + 'subPath': os.path.basename(cm_mount_path)}) pod_data['spec'] = {'containers': containers, 'restartPolicy': 'OnFailure'} @@ -462,11 +463,11 @@ def _generate_pod_data(self, namespace, name, outports, system, volumes, configm {'name': v_name, 'persistentVolumeClaim': {'claimName': v_name}}) if configmaps: + pod_data['spec']['volumes'] = pod_data['spec'].get('volumes', []) for (cm_name, _) in configmaps: pod_data['spec']['volumes'].append( {'name': cm_name, - 'configMap': {'name': cm_name, - 'items': [{'key': os.path.basename(cm_mount_path), 'path': cm_mount_path}]}}) + 'configMap': {'name': cm_name}}) return pod_data diff --git a/test/unit/connectors/Kubernetes.py b/test/unit/connectors/Kubernetes.py index 3b06c41f..b1aade94 100755 --- a/test/unit/connectors/Kubernetes.py +++ b/test/unit/connectors/Kubernetes.py @@ -219,14 +219,14 @@ def test_20_launch(self, save_data, requests): }, "env": [{"name": "var", "value": "some_val"}], "volumeMounts": [{"name": "test-1", "mountPath": "/mnt"}, - {'mountPath': '/etc/config', 'name': 'test-cm-2', 'readOnly': True}], + {'mountPath': '/etc/config', 'name': 'test-cm-2', + 'readOnly': True, 'subPath': 'config'}], } ], "restartPolicy": "OnFailure", "volumes": [ {"name": "test-1", "persistentVolumeClaim": {"claimName": "test-1"}}, - {"name": "test-cm-2", "configMap": {"name": "test-cm-2", - "items": [{"key": "config", "path": "/etc/config"}]}}, + {"name": "test-cm-2", "configMap": {"name": "test-cm-2"}}, ], }, }