Skip to content

Commit

Permalink
Improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Feb 23, 2024
1 parent d0000f8 commit 75b388e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions IM/connectors/Kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,24 +441,22 @@ def _generate_pod_data(self, namespace, name, outports, system, volumes, configm

if volumes:
containers[0]['volumeMounts'] = []
pod_data['spec']['volumes'] = []

for (v_name, _, v_mount_path) in volumes:
containers[0]['volumeMounts'].append(
{'name': v_name, 'mountPath': v_mount_path})

pod_data['spec']['volumes'] = []
for (v_name, _, _) in volumes:
pod_data['spec']['volumes'].append(
{'name': v_name, 'persistentVolumeClaim': {'claimName': v_name}})

if configmaps:
containers[0]['volumeMounts'] = containers[0].get('volumeMounts', [])
pod_data['spec']['volumes'] = pod_data['spec'].get('volumes', [])

for (cm_name, cm_mount_path) in configmaps:
containers[0]['volumeMounts'].append(
{'name': cm_name, 'mountPath': cm_mount_path, "readOnly": True,
'subPath': os.path.basename(cm_mount_path)})

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}})
Expand Down

0 comments on commit 75b388e

Please sign in to comment.