yooo can you help me figure out how to use the k8...
# 🤖|ask-kapa
f
yooo @microscopic-river-74022 can you help me figure out how to use the k8s provider's deploy action (edge/0.14) to change the namespace a kustomize overlay is pushed to
m
Please stand by @future-businessperson-39015 as I search the knowledge base. I normally take about 15 seconds or so. :wave:
---------------------- Absolutely! To change the namespace a Kustomize overlay is deployed to using Garden's Kubernetes provider (edge/0.14), you should: 1. Set the namespace in your provider config In your
Project
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:
Copy code
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:
Copy code
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:
Copy code
yaml
   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: ----------------------
message has been deleted