Skip to content

Commit

Permalink
Add image pull secrets to k8s container context (#8221)
Browse files Browse the repository at this point in the history
  • Loading branch information
gibsondan authored and johannkm committed Jun 9, 2022
1 parent ed1b9b0 commit 455fb97
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ DAGSTER_K8S_PIPELINE_RUN_ENV_CONFIGMAP: "{{ template "dagster.fullname" . }}-pip
{{- with index . 1 }}
k8s:
image_pull_policy: {{ .image.pullPolicy }}
{{- if $.Values.imagePullSecrets }}
image_pull_secrets: {{- $.Values.imagePullSecrets | toYaml | nindent 6 }}
{{- end }}
env_config_maps:
- {{ include "dagster.fullname" $ }}-{{ .name }}-user-env
{{- range $envConfigMap := .envConfigMaps }}
Expand Down
27 changes: 26 additions & 1 deletion helm/dagster/schema/schema_tests/test_user_deployments.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,10 +818,18 @@ def test_user_deployment_resources(template: HelmTemplate, include_config_in_lau
_assert_no_container_context(user_deployments[0])


def test_subchart_image_pull_secrets(subchart_template: HelmTemplate):
@pytest.mark.parametrize("include_config_in_launched_runs", [False, True])
def test_subchart_image_pull_secrets(
subchart_template: HelmTemplate, include_config_in_launched_runs: bool
):
image_pull_secrets = [{"name": "super-duper-secret"}]
deployment_values = DagsterUserDeploymentsHelmValues.construct(
imagePullSecrets=image_pull_secrets,
deployments=[
create_simple_user_deployment(
"foo", include_config_in_launched_runs=include_config_in_launched_runs
)
],
)

deployment_templates = subchart_template.render(deployment_values)
Expand All @@ -833,6 +841,23 @@ def test_subchart_image_pull_secrets(subchart_template: HelmTemplate):

assert pod_spec.image_pull_secrets[0].name == image_pull_secrets[0]["name"]

if include_config_in_launched_runs:
container_context = deployment_template.spec.template.spec.containers[0].env[2]
assert container_context.name == "DAGSTER_CLI_API_GRPC_CONTAINER_CONTEXT"
assert json.loads(container_context.value) == {
"k8s": {
"env_config_maps": [
"release-name-dagster-user-deployments-foo-user-env",
],
"image_pull_policy": "Always",
"image_pull_secrets": image_pull_secrets,
"namespace": "default",
"service_account_name": "release-name-dagster-user-deployments-user-deployments",
}
}
else:
_assert_no_container_context(deployment_template)


def test_subchart_postgres_password_global_override(subchart_template: HelmTemplate):
deployment_values = DagsterUserDeploymentsHelmValues.construct(
Expand Down

0 comments on commit 455fb97

Please sign in to comment.