Hi :wave: is it possible to use secrets in Ray tas...
# flyte-v1-support
s
Hi šŸ‘‹ is it possible to use secrets in Ray tasks? I tried this but I’m not seeing the secret propagated.
Copy code
@task(
    container_image=<ray_image>,
    requests=Resources(mem="2Gi", cpu="1"),
    task_config=RayJobConfig(
        worker_node_config=[WorkerNodeConfig(group_name="ray-group", replicas=1)],
    )
    secret_requests=[
        Secret(
            group="super-secrets",
            key="foo",
            mount_requirement=Secret.MountType.ENV_VAR,
        )
    ],
)
def test_get_secret():
    # Would expect to see _FSEC_SUPER-SECRETS_FOO here, but does not exist.
    print(os.environ)
Also tried adding
runtime_env
to the
RayJobConfig
but that ends up being empty because I assume the secret is populated at runtime, not at registration time:
Copy code
runtime_env={
    "env_vars": {
        "FOO": os.environ.get("_FSEC_SUPER-SECRETS_FOO", "")
    }
},
e
You can follow this docs to use secret: https://www.union.ai/docs/v1/flyte/deployment/flyte-configuration/secrets/#creating-secrets-with-a-secrets-manager Need to create secret with secret manager first
s
Thanks @echoing-account-76888. The Secret exists in Kubernetes already. If I run the task as a regular Flyte Python task (non-Ray) I can see it.
šŸ‘€ 1
e
Oh so it's only not working on ray's plugin? Let me try it out when I got time with your example to see what's the issue
s
Yeah exactly, if you just remove the
task_config=RayJobConfig(…)
from the
@task
decorator it works fine. Appreciate it!
As a workaround I have added a rolebinding for the serviceaccount in our Flyte namespace to access the specific Kubernetes secret that we need, and fetch it via k8s Python SDK directly, but would be nice if they were simply available via
secret_requests
(or if someone can confirm this is simply not possible today šŸ™‚)
f
It might be the ray operator
s
So should just work then @freezing-airport-6809?
e
@shy-evening-51366 Could you send your
PodSpec
for us? The env var should be in the pod spec environment section