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 2bcfa48 commit d0000f8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions IM/connectors/Kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,18 @@ def _generate_pod_data(self, namespace, name, outports, system, volumes, configm
if system.getValue("docker.privileged") == 'yes':
containers[0]['securityContext'] = {'privileged': True}

pod_data['spec'] = {'restartPolicy': 'OnFailure'}

if volumes:
containers[0]['volumeMounts'] = []
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', [])
Expand All @@ -450,21 +457,14 @@ def _generate_pod_data(self, namespace, name, outports, system, volumes, configm
{'name': cm_name, 'mountPath': cm_mount_path, "readOnly": True,
'subPath': os.path.basename(cm_mount_path)})

pod_data['spec'] = {'containers': containers, 'restartPolicy': 'OnFailure'}

if volumes:
pod_data['spec']['volumes'] = []
for (v_name, _, _) in volumes:
pod_data['spec']['volumes'].append(
{'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}})

pod_data['spec']['containers'] = containers

return pod_data

@staticmethod
Expand Down

0 comments on commit d0000f8

Please sign in to comment.