Skip to content

Commit 51a8d3f

Browse files
authored
fix: kubernetes imagePullSecrets support for argo workflows (#2494)
Argo workflows does not support applying imagePullSecrets on a per-template basis, only on a workflow template level. Changing the implementation to leverage podSpecPatch in order to apply the imagePullSecrets on a per task basis JobSets were not tested but should be unaffected due to them utilizing `create` within the spec and simply dumping native k8s job specs closes #2477
1 parent f33c948 commit 51a8d3f

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

metaflow/plugins/argo/argo_workflows.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,8 +2125,17 @@ def _container_templates(self):
21252125
.node_selectors(resources.get("node_selector"))
21262126
# Set tolerations
21272127
.tolerations(resources.get("tolerations"))
2128-
# Set image pull secrets
2129-
.image_pull_secrets(resources.get("image_pull_secrets"))
2128+
# Set image pull secrets if present. We need to use pod_spec_patch due to Argo not supporting this on a template level.
2129+
.pod_spec_patch(
2130+
{
2131+
"imagePullSecrets": [
2132+
{"name": secret}
2133+
for secret in resources["image_pull_secrets"]
2134+
]
2135+
}
2136+
if resources["image_pull_secrets"]
2137+
else None
2138+
)
21302139
# Set container
21312140
.container(
21322141
# TODO: Unify the logic with kubernetes.py
@@ -3825,6 +3834,14 @@ def pvc_volumes(self, pvcs=None):
38253834
)
38263835
return self
38273836

3837+
def pod_spec_patch(self, pod_spec_patch=None):
3838+
if pod_spec_patch is None:
3839+
return self
3840+
3841+
self.payload["podSpecPatch"] = json.dumps(pod_spec_patch)
3842+
3843+
return self
3844+
38283845
def node_selectors(self, node_selectors):
38293846
if "nodeSelector" not in self.payload:
38303847
self.payload["nodeSelector"] = {}
@@ -3836,10 +3853,6 @@ def tolerations(self, tolerations):
38363853
self.payload["tolerations"] = tolerations
38373854
return self
38383855

3839-
def image_pull_secrets(self, image_pull_secrets):
3840-
self.payload["image_pull_secrets"] = image_pull_secrets
3841-
return self
3842-
38433856
def to_json(self):
38443857
return self.payload
38453858

0 commit comments

Comments
 (0)