Secrets such as provider keys and environment variables can be set when defining compute. These are set at launch time and accessible during the scope of your program.
Builds an instance of Secret. At most one of provider, path, or env_vars can be provided, to maintain
one source of truth. For a provider, the values are inferred from the default path or environment variables for that
provider. To load a secret by name, provide its name and namespace.
namespace (str, optional) – Namespace to load the secret from, if we create a secret from name. Default: “default”.
name (str, optional) – Name to assign the resource. If none is provided, resource name defaults to the provider name.
provider (str, optional) – Provider corresponding to the secret (e.g. “aws”, “gcp”). To see all supported provider
types, run kt.Secret.builtin_providers(as_str=True).
path (str, optional) – Path where the secret values are held.
env_vars (Dict, optional) – Dictionary mapping secret keys to the corresponding environment variable key.
override (Bool, optional) – If True, override the secret’s values in Kubernetes if a secret with the same name already exists.
The resulting secret object.
Examples:
import kubetorch as kt local_secret = kt.secret(name="in_memory_secret", values={"secret_key": "secret_val"}) aws_secret = kt.secret(provider="aws") gcp_secret = kt.secret(name="my-gcp-secret", path="~/.gcp/credentials") lambda_secret = kt.secret(name= "my-lambda-secret", env_vars={"api_key": "LAMBDA_API_KEY"})
- __init__(name: str | None = None, provider: str | None = None, values: Dict | None = None, path: str | None = None, env_vars: Dict | None = None, override: bool = False, **kwargs)
Secret class. Built-in provider classes contain default path and/or environment variable mappings, based on it’s expected usage.
Note
Currently supported built-in providers: anthropic, aws, azure, gcp, github, huggingface, lambda, langchain, openai, pinecone, ssh, wandb.
- Parameters:
name (str, optional) – Name to assign the Kubetorch secret.
provider (str, optional) – Provider corresponding to the secret (e.g. “aws”, “gcp”).
values (Dict, optional) – Dictionary mapping secret keys to the corresponding secret values.
path (str, optional) – Path where the secret values are held.
env_vars (Dict, optional) – Dictionary mapping secret keys to the corresponding environment variable key.
override (bool, optional) – If True, override the secret’s values in Kubernetes if a secret with the same name already exists.
Name of the secret.
Should we override secret’s values in Kubernetes if a secret with the same name already exists
Secret values.
Return list of all Kubetorch providers (as class objects) supported out of the box.
as_str (bool, optional) – Whether to return the providers as a string or as a class.
(Default: False)
Return kubetorch provider secret object
provider (str) – Provider’s name
name (str, Optional) – Secret name
path (str, optional) – Path where the secret values are held.
override (Bool, optional) – If True, override the secret’s values in Kubernetes if a secret with the same name already exists.
Return kubetorch provider secret object
path (str) – Local path to the secret values file
name (str, Optional) – Secret name
override (Bool, optional) – If True, override the secret’s values in Kubernetes if a secret with the same name already exists.
Return kubetorch provider secret object
env_vars (dict) – Dictionary mapping secret keys to the corresponding
key. (environment variable) –
name (str, Optional) – Secret name
override (Bool, optional) – If True, override the secret’s values in Kubernetes if a secret with the same name already exists.