Skip to main content

Secret Env

You can create Secret to pass then as environement variable for your Cargoes.

tip

You can create secrets directly from a deployment Statefile!
But we recommend you to use Secret kind of Statefile and manage them separatly.

There is an Statefile example on how to do it:

ApiVersion: v0.18

Namespace: global

# See all options:
# https://docs.next-hat.com/references/nanocl/objects/secret
Secrets:
- Name: env.my-secret
Kind: nanocl.io/env
Data:
- MY_ENV=MY_VALUE
- MY_ENV1=MY_VALUE1

# See all options:
# https://docs.next-hat.com/references/nanocl/objects/cargo
Cargoes:
- Name: my-cargo
Containers:
- Name: web
# Container-scoped secrets are injected only into this container.
Secrets:
- env.my-secret
Image: ghcr.io/next-hat/nanocl-get-started:latest

# See all options:
# https://docs.next-hat.com/references/nanocl/objects/resource
Resources:
- Name: deploy-example.com
Kind: ncproxy.io/rule/v0.15
Data:
Rules:
- Domain: deploy-example.com
Network: Public
Locations:
- Path: /
Target:
Key: global.my-cargo.c
Port: 9000

For more information about secrets refer to our secret reference