In a Deploy action, if I use a kustomize file for ...
# 🤖|ask-kapa
f
@microscopic-river-74022 In a Deploy action, if I use a kustomize file for my spec, will garden interpolate garden variables in the kustomization?
m
Please stand by @fresh-yak-35965 as I search the knowledge base. I normally take about 20 seconds or so. :wave:
---------------------- No, Garden does not support templating in Kustomize files. If you want to use Garden variables in your deployment, you should use the
patchResources
field in your
garden.yml
file. This field is designed for cases like this and can serve the same role as Kustomize. Here is an example of how you can use the
patchResources
field:
Copy code
yaml
kind: Deploy
type: kubernetes
name: admin-api
variables:
  ADMIN_IMAGE: ${actions.build.admin-api.outputs.deployment-image-name}:${actions.build.admin-api.version}
dependencies:
  - build.admin-api
spec:
  kustomize:
    path: ./kubernetes/overlays/${environment.name}
  patchResources:
    - name: admin-api
      kind: Deployment
      patch:
        spec:
          template:
            spec:
              containers:
                - name: api-container
                  image: ${var.ADMIN_IMAGE}
              initContainers:
                - name: init-api
                  image: ${var.ADMIN_IMAGE}
In this example, the
ADMIN_IMAGE
variable is defined using the output of a build action, and then used in the
patchResources
field to patch the image of the
api-container
and
init-api
containers in the
admin-api
Deployment. For more information, you can refer to the Garden documentation on the
patchResources
field
(). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
message has been deleted