https://flyte.org logo
#flytekit
Title
# flytekit
f

Fredrick

09/27/2022, 7:16 PM
Hi, is there a way to inject k8s secret in
ContainerTask
as env vars ? https://docs.flyte.org/projects/cookbook/en/latest/auto/core/containerization/raw_container.html
y

Yee

09/27/2022, 7:53 PM
is the
mount_requirement
option not working?
Copy code
@task(
    secret_requests=[
        Secret(
            group=SECRET_GROUP,
            key=SECRET_NAME,
            mount_requirement=Secret.MountType.ENV_VAR,
        )
    ]
)
def secret_file_task() -> Tuple[str, str]:
    # SM here is a handle to the secrets manager
    sm = flytekit.current_context().secrets
    f = sm.get_secrets_file(SECRET_GROUP, SECRET_NAME)
    secret_val = sm.get(SECRET_GROUP, SECRET_NAME)
    # returning the filename and the secret_val
    return f, secret_val
oh are secret requests even exposed?
oh it is not… you’ll have to do it manually i think
but kwargs are passed up to the base task, so you’ll need to create secret objects manually and pass them in like so: https://github.com/flyteorg/flytekit/blob/41f775061135eab5632be5adefb426c2da94b612/flytekit/core/python_auto_container.py#L77
f

Fredrick

09/27/2022, 8:38 PM
thanks for the pointer. let me try creating them manually and passing them via
security_ctx
25 Views