Secrets
Opta provides built-in secret management for your applications. Any secrets like database passwords, api keys, should not be written in the code (including opta.yaml) because if the code is leaked accidentally, your infrastructure is exposed to hackers.
Opta enables you to store these in an encrypted fashion inside the kubernetes
cluster. To use the secrets functionality use the opta secret command.
For this example, we can reuse the service defined in the Getting Started guide.
# hello.yaml
name: hello
environments:
- name: staging
path: "opta.yaml"
modules:
- type: k8s-service
name: hello
port:
http: 80
image: ghcr.io/run-x/hello-opta/hello-opta:main
healthcheck_path: "/"
public_uri: "/hello"
-
Create or update a secret with the
secret updatecommandopta secret update -c hello.yaml MY_SECRET_1 "value_1"SuccessNote: Opta will restart the service for the secrets to be updated in real time, if that’s not desirable use the
--no-restartflag. -
Or if you want to create multiple secrets, use the
secret bulk-updatecommand# example of .env file containing secrets cat secrets.env MY_SECRET_2=value_2 MY_SECRET_3=value_3opta secret bulk-update -c hello.yaml secrets.envSuccessNote: Opta will restart the service for the secrets to be updated in real time, if that’s not desirable use the
--no-restartflag. -
List all secrets with the
secret listcommandopta secret list -c hello.yamlMY_SECRET_1=value_1 MY_SECRET_2=value_2 MY_SECRET_3=value_3 -
View a secret value with the
secret viewcommandopta secret view -c hello.yaml MY_SECRET_1value_1 -
View a secret value at runtime
# shell into a service and view the environment variables # the application can use these opta shell -c hello.yaml env | grep MY_SECRET_ MY_SECRET_1=value_1 MY_SECRET_2=value_2 MY_SECRET_3=value_3
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.