Hi, community, currently I want to setup the secre...
# ask-the-community
l
Hi, community, currently I want to setup the secret value in flyte cluster. I run
Copy code
flytectl demo start
and use
Copy code
kubectl edit secret flyte-sandbox-config-secret -n flyte
Copy code
apiVersion: v1
data:
  012-database-secrets.yaml: ZGF0YWJhc2U6CiAgcG9zdGdyZXM6CiAgICBwYXNzd29yZDogInBvc3RncmVzIgo=
  013-storage-secrets.yaml: c3RvcmFnZToKICBzdG93OgogICAgY29uZmlnOgogICAgICBhY2Nlc3Nfa2V5X2lkOiAibWluaW8iCiAgICAgIHNlY3JldF9rZXk6ICJtaW5pb3N0b3JhZ2UiCg==
  bearer_token: <BASE64_ENCODED_TWITTER_BEARER_TOKEN>
  consumer_key: <BASE64_ENCODED_TWITTER_CONSUMER_KEY>
  consumer_secret: <BASE64_ENCODED_TWITTER_CONSUMER_SECRET>
  access_token: <BASE64_ENCODED_TWITTER_ACCESS_TOKEN>
  access_token_secret: <BASE64_ENCODED_TWITTER_ACCESS_TOKEN_SECRET>
to add 5 secrets from
bearer_token
to
access_token_secret
However, when I tried to retrieve the secret, it fails. Here is the error message. Can anyone help me? I will update the docs for secret setting to help others!
Copy code
Traceback (most recent call last):

      File "/usr/local/lib/python3.9/site-packages/flytekit/exceptions/scopes.py", line 206, in user_entry_point
        return wrapped(*args, **kwargs)
      File "/root/test.py", line 5, in t1
        return flytekit.current_context().secrets.get("BEARER_TOKEN")
      File "/usr/local/lib/python3.9/site-packages/flytekit/core/context_manager.py", line 365, in get
        raise ValueError(

Message:

    Unable to find secret for key None in group BEARER_TOKEN in Env Var:_FSEC_BEARER_TOKEN and FilePath: /etc/secrets/bearer_token

User error.
j
I believe secrets need to be in the namespace for which the workflow runs (you created them
flyte
), but would need to be in
<flyte-project>-<flyte-domain>
h
@Justin Boutwell I might have a similar issue getting the right namespace for flyte sandbox, could you have a look? https://flyte-org.slack.com/archives/CP2HDHKE1/p1697832228374239?thread_ts=1697808380.553099&amp;cid=CP2HDHKE1
s
@L godlike, may I know why you're adding your secrets to flyte-sandbox-config-secret but not creating new secrets?
l
Can I ask the main difference? Currently, I am writing a task using Twitter's API, so I need to store my tokens into the secret. https://github.com/Future-Outlier/MLOpsTrendFlyteBot/blob/main/getWeeklyMLOpsTrend.py#L59-L64 However, I can't retrieve them by adding my secrets.
Thanks a lot!
s
In that case, you need to add your secrets to the namespace you want to execute your task/workflow in: https://docs.flyte.org/projects/cookbook/en/latest/auto_examples/productionizing/use_secrets.html#secrets.
Let me know if you're seeing any errors while following the steps in the docs.
l
No problem, I will try it, thanks a lot
it works, thanks a lot!