microscopic-river-74022
04/18/2024, 10:21 PMmicroscopic-river-74022
04/18/2024, 10:22 PMpatchResources
field in your Garden configuration. This allows you to overwrite any field in your manifests without modifying the underlying manifest.
Here's an example of how you can do this:
yaml
kind: Build
type: container
name: api
---
kind: Deploy
type: kubernetes
name: api
dependencies: [build.api]
spec:
files: [my-manifests.yml]
patchResources:
- name: api # <--- The name of the resource to patch, should match the name in the K8s manifest
kind: Deployment # <--- The kind of the resource to patch
patch:
spec:
template:
spec:
containers:
- name: api # <--- Should match the container name from the K8s manifest
image: ${actions.build.api.outputs.deployment-image-id} # <--- The output from the Build action above
In this example, the patchResources
field is used to overwrite the image
field in the corresponding manifest with the output from the Build action. This ensures that the correct version of the image is deployed.
You can find more information about this approach in the Garden documentation ().
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------microscopic-river-74022
04/18/2024, 10:26 PMbright-policeman-43626
04/18/2024, 10:26 PMapiVersion: batch/v1
kind: CronJob
metadata:
name: ci-cleanup-job
namespace: ci-cleaner
spec:
schedule: "* * * * *" # This schedule is just an example; adjust according to your needs
jobTemplate:
spec:
template:
spec:
serviceAccountName: ci-cleaner-sa
containers:
- name: ci-cleaner-job
image: gcr.io/ci-ns-cleaner:master
command:
- /bin/bash
- -c
restartPolicy: OnFailure
Specifically under containers.ci-cleaner-job.imagemicroscopic-river-74022
04/18/2024, 10:26 PMimage
field in your Kubernetes manifest using Garden template strings. Here's how you can do it:
yaml
apiVersion: batch/v1
kind: CronJob
metadata:
name: ci-cleanup-job
namespace: ci-cleaner
spec:
schedule: "* * * * *" # This schedule is just an example; adjust according to your needs
jobTemplate:
spec:
template:
spec:
serviceAccountName: ci-cleaner-sa
containers:
- name: ci-cleaner-job
image: ${actions.build.api.outputs.deployment-image-id} # <--- Garden will resolve this to the correct image before applying the manifest
command:
- /bin/bash
- -c
restartPolicy: OnFailure
In this example, ${actions.build.api.outputs.deployment-image-id}
is a Garden template string that will be resolved to the correct image before applying the manifest. You would replace api
with the name of your build action.
You can find more information about this approach in the Garden documentation ().
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------bright-policeman-43626
04/18/2024, 10:27 PMmicroscopic-river-74022
04/18/2024, 10:27 PMmicroscopic-river-74022
04/18/2024, 10:28 PMmodules
field in your Garden configuration. Here's an example:
yaml
kind: Module
type: container
name: ci-cleaner-job
dockerfile: Dockerfile
---
kind: Module
type: kubernetes
name: ci-cleanup-job
include: [ci-cleanup-job.yaml]
services:
- name: ci-cleanup-job
dependencies: [ci-cleaner-job]
manifests:
- apiVersion: batch/v1
kind: CronJob
metadata:
name: ci-cleanup-job
namespace: ci-cleaner
spec:
schedule: "* * * * *"
jobTemplate:
spec:
template:
spec:
serviceAccountName: ci-cleaner-sa
containers:
- name: ci-cleaner-job
image: ${modules.ci-cleaner-job.outputs.deployment-image-id}
command:
- /bin/bash
- -c
restartPolicy: OnFailure
In this example, ${modules.ci-cleaner-job.outputs.deployment-image-id}
is a Garden template string that will be resolved to the correct image before applying the manifest.
Please note that you might need to adjust the dockerfile
and include
paths according to your project structure.
For more information on how to use modules in Garden Acorn, you can refer to the Garden 0.12 documentation ().
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------