future-businessperson-39015
06/12/2025, 6:10 PMmicroscopic-river-74022
06/12/2025, 6:10 PMmicroscopic-river-74022
06/12/2025, 6:11 PMProject
config, under the providers
section, set the namespace
field to a dynamic value using Garden's templating. Typically, you use ${environment.namespace}
so that the namespace is determined by the current environment. For example:
yaml
providers:
- name: kubernetes
namespace: ${environment.namespace}
# other provider config...
This ensures that the Kubernetes resources (including those managed by Kustomize) are deployed to the namespace defined for the current environment. You can template this namespace per environment (e.g., per developer, per PR, per CI run) as shown in the guides [Edge-release > Guides > Environments and Namespaces]().
2. Configure your environments to set the namespace
In your environments
section, set defaultNamespace
for each environment. For example:
yaml
environments:
- name: dev
defaultNamespace: my-project-${local.username}
- name: ci
defaultNamespace: my-project-ci-${local.env.BUILD_NUMBER}
${environment.namespace}
will resolve to these values in the provider config above.
3. Kustomize overlay path
In your deploy action, specify the Kustomize overlay directory with spec.kustomize.path
if needed. This does not affect the namespace, but lets you pick the right overlay:microscopic-river-74022
06/12/2025, 6:11 PMyaml
kind: Deploy
name: my-service
type: kubernetes
spec:
kustomize:
path: overlays/${environment.name}
[Reference: spec.kustomize.path]()
Summary:
Garden injects the namespace into your manifests at deploy time, so you don't need to hardcode the namespace in your Kustomize overlays. Just use the templated namespace in your provider config, and Garden will handle deploying to the correct namespace for each environment.
For a full example and more details, see the [opinionated guide on using namespaces]() and the [Kustomize example]().
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------microscopic-river-74022
06/12/2025, 6:11 PM