cold-train-21872
10/20/2023, 1:26 PM.env
file, a separate config.py
that loads the credentials, and I import that config module into a file. However when running remotely that config module is not found. What is the preferred way to load this?thankful-minister-83577
thankful-minister-83577
cold-train-21872
10/20/2023, 1:43 PMkubectl create secret -n <project>-<domain> --from-env-file=.env
cold-train-21872
10/20/2023, 1:43 PMthankful-minister-83577
thankful-minister-83577
cold-train-21872
10/20/2023, 1:50 PMcold-train-21872
10/20/2023, 8:03 PMkubectl get namespace
Not sure which namespace is the correct one for flyte sandbox, I tried to create the secrets in all of them and ran
secret = Secret(
group="user-info",
key="user_secret",
mount_requirement=Secret.MountType.ENV_VAR,
)
SECRET_GROUP = "user-info"
SECRET_NAME = "user_secret"
@task(secret_requests=[Secret(group=SECRET_GROUP, key=SECRET_NAME)])
def secret_task() -> str:
context = current_context()
secret_val = context.secrets.get(SECRET_GROUP, SECRET_NAME)
print(secret_val)
return secret_val
but got the error when I run `pyflyte run`:
Failed with Unknown Exception <class 'ValueError'> Reason: Error encountered while executing 'secret_task':
Unable to find secret for key user_secret in group user-info in Env Var:_FSEC_USER-INFO_GH_PAT and FilePath: /etc/secrets/user-info/user_secret
Error encountered while executing 'secret_task':
Unable to find secret for key user_secret in group user-info in Env Var:_FSEC_USER-INFO_GH_PAT and FilePath: /etc/secrets/user-info/user_secret
whereby the user_secret
is the key I defined in my .env
file e.g. user_secret=<my-secret-key>
@thankful-minister-83577thankful-minister-83577
thankful-minister-83577
cold-train-21872
10/21/2023, 2:21 AM❯ kubectl get secret
NAME TYPE DATA AGE
user-info Opaque 3 5h55m
@thankful-minister-83577 so this only worked when I created it in the default
namespacethankful-minister-83577
cold-train-21872
10/21/2023, 2:23 AMthankful-minister-83577
thankful-minister-83577
cold-train-21872
10/21/2023, 2:25 AM❯ kubectl get namespace
NAME STATUS AGE
default Active 29d
kube-system Active 29d
kube-public Active 29d
kube-node-lease Active 29d
flyte Active 29d
flytesnacks-development Active 29d
flytesnacks-staging Active 29d
flytesnacks-production Active 29d
So I have created the secret in all of the namespaces - and I still get the errorthankful-minister-83577
thankful-minister-83577
cold-train-21872
10/21/2023, 2:26 AMthankful-minister-83577
-
and _
thankful-minister-83577
thankful-minister-83577
thankful-minister-83577
cold-train-21872
10/21/2023, 2:28 AMkubectl delete secret user-info
in other namespaces beside default
is there a way to delete those?thankful-minister-83577
thankful-minister-83577
thankful-minister-83577
thankful-minister-83577
cold-train-21872
10/21/2023, 2:34 AMError encountered while executing 'secret_task':
Unable to find secret for key usersecret in group userinfo in Env Var:_FSEC_USERINFO_USERSECRET and FilePath: /etc/secrets/userinfo/usersecret
cold-train-21872
10/21/2023, 2:35 AMthankful-minister-83577
thankful-minister-83577
cold-train-21872
10/21/2023, 2:38 AM❯ kubectl get secret
NAME TYPE DATA AGE
userinfo Opaque 1 5m28s
thankful-minister-83577
k get userinfo -o yaml
cold-train-21872
10/21/2023, 2:39 AM❯ kubectl get userinfo -o yaml
error: the server doesn't have a resource type "userinfo"
thankful-minister-83577
thankful-minister-83577
thankful-minister-83577
thankful-minister-83577
cold-train-21872
10/21/2023, 2:43 AMthankful-minister-83577
thankful-minister-83577
alias k="kubectl"
alias kf="kubectl -n flyte"
alias ksd='k -n flytesnacks-development'
alias kga="kubectl get --all-namespaces"
cold-train-21872
10/21/2023, 2:50 AMflyte-sandbox-postgresql-0 1/1 Running 1 (2d9h ago) 11d
flyte-sandbox-proxy-d95874857-4lzjw 1/1 Running 1 (2d9h ago) 11d
flyte-sandbox-buildkit-7d7d55dbb-4fdlm 1/1 Running 1 (2d9h ago) 11d
flyte-sandbox-minio-645c8ddf7c-h84qp 1/1 Running 10 (2d9h ago) 29d
flyte-sandbox-docker-registry-759844bc88-ctmng 1/1 Running 0 11d
flyte-sandbox-7d699df5fc-8qx5r 1/1 Running 1 (2d9h ago) 11d
flyte-sandbox-kubernetes-dashboard-6757db879c-zv7b6 1/1 Running 20 (36h ago) 11d
cold-train-21872
10/21/2023, 2:50 AMthankful-minister-83577
flyte-sandbox-7d699df5fc-8qx5r
thankful-minister-83577
thankful-minister-83577
cold-train-21872
10/21/2023, 2:53 AMthankful-minister-83577
thankful-minister-83577
thankful-minister-83577
thankful-minister-83577
thankful-minister-83577
cold-train-21872
10/21/2023, 3:03 AM@task
def secret_task():
sc = SecretsManager()
print(sc.get(SECRET_GROUP, SECRET_NAME))
also gave the same errorthankful-minister-83577
thankful-minister-83577
cold-train-21872
10/21/2023, 3:10 AMthankful-minister-83577
average-finland-92144
10/30/2023, 3:15 PMpyflyte run --remote ...
) and the env vars described here are not set.
Maybe the docs need better guidance on what to configure depending on remote/local execution so secrets discovery works.thankful-minister-83577