- Using runtime attributes
@timoni(runtime:string:SECRET-NAME). - Using 1Password secret references resolved by the
opCLI. - Using SOPS encrypted YAML or JSON files.
Runtime Secrets
To showcase how secrets injections works, we’ll assume we are deploying an application that connects to an S3-compatible API and needs two secrets:ACCESS_KEY and SECRET_KEY.
Injecting secrets from CI secret store
When using a CI runner to deploy apps with Timoni, we can pass secrets from the runner’s secret store to Timoni’s Bundle. Example of a Bundle that contains runtime attributes:Injecting secrets from Kubernetes
The same secrets from the above example, can be injected from a Kubernetes Secret, assuming we’re using some external-secret controller that syncs secrets from a Vault in etcd. Example of a Timoni Bundle Runtime that fetches the secrets from the cluster:Secrets interpolation
When the secrets stored in external system do not map to a value key in the Bundle, we can use CUE’s string interpolation to compose the desired value. Assuming an application config expects a Redis URL, but the secret store containsREDIS_HOST and REDIS_PASS.
_secrets, where we set the
runtime secrets mappings. Then in the instance values, we use string interpolation
to set the redisURL containing the secrets.
Using the build command, we can see the URL value set in the podinfo container args:
1Password secrets
When using 1Password, theop run command resolves secret references to env vars and passes them
to Timoni as a subprocess, where they are read with --runtime-from-env.
Injecting secrets with op CLI
Using the bundle from the CI example, create an env filesecrets.env that maps the runtime attribute names
to 1Password secret references:
op run:
op CLI authenticates with the 1Password desktop app on workstations,
or with a service account in CI when the OP_SERVICE_ACCOUNT_TOKEN env var is set.
To inspect the generated manifests, run timoni bundle build with op run.
The secret values are masked in the output as <concealed by 1Password>:
SOPS secrets
When using SOPS, we can decrypt the secrets and inject those values to env vars, then use--runtime-from-env.
Another option is to extract the secret values of a Timoni Bundle to a YAML or JSON file,
that we encrypt/decrypt with SOPS.
Injecting secrets from SOPS
Main bundle filebundle.main.cue:
bundle.secret.yaml:
bundle.secret.yaml file is kept encrypted with SOPS,
at apply-time we can run the SOPS decryption,
and pass the plain YAML to Timoni’s apply command like so: