bright-policeman-43626
04/18/2024, 6:57 PMmicroscopic-river-74022
04/18/2024, 6:57 PMmicroscopic-river-74022
04/18/2024, 6:58 PM0.14
, modules are deprecated and it's recommended to use action-based configuration instead. You might want to consider upgrading to a newer version of Garden and following the 0.12 to Bonsai migration guide () for details.
If you still want to proceed with version 0.12
, here's how you can deploy Kubernetes manifests:
1. **Point Garden to your manifests**: When configuring a kubernetes
Deploy action, you point Garden to the manifest files via the spec.files
directive. You can also specify them inline in your Garden config via the spec.manifests
field but it's recommended to use the former approach since that allows you to re-use them with other tools. source ()
2. **Deploy a container image that's been built by Garden**: You can use Garden template strings in your Kubernetes manifests to set the image. Here's an example of how to do this:
yaml
# In the corresponding manifest file
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
labels:
app: api
spec:
replicas: 1
selector:
matchLabels:
app: api
template:
metadata:
labels:
app: api
spec:
containers:
- name: api
image: ${actions.build.api.outputs.deployment-image-id} # <--- Garden will resolve this to the correct image before applying the manifest
source ()
3. **Overwrite values in your manifests to suit your environment**: You can use template strings () to interpolate values into the manifests.microscopic-river-74022
04/18/2024, 6:58 PMgarden.yml
file like so:
yaml
defaultTarget: # <--- This tells Garden what "target" to use for logs, code syncing and more
kind: Deployment
name: api
source ()
5. **Configure code syncing for rapid development**: This is done by setting up dependencies in your garden.yml
file. For example, if you need to build the API and seed the DB before deploying it, you can set it up like so:
yaml
dependencies: [build.api, run.db-seed] # <--- We need to build the api and seed the DB before deploying it
source ()
Remember, the kubernetes
Deploy action type works very similarly to the helm
() Deploy action, and you'll find a lot common between the two guides.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------bright-policeman-43626
04/18/2024, 7:04 PMmicroscopic-river-74022
04/18/2024, 7:04 PMmicroscopic-river-74022
04/18/2024, 7:04 PMgarden.yml
file, you would define a Kubernetes module that points to your Kubernetes manifest files. Here's an example:
yaml
kind: Module
type: kubernetes
name: my-kubernetes-module
include:
- path/to/your/manifests/*.yaml
2. **Use Garden template strings**: If you want to deploy a container image that's been built by Garden, you can use Garden template strings in your Kubernetes manifests to set the image. Here's an example:
yaml
# In the corresponding manifest file
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
labels:
app: api
spec:
replicas: 1
selector:
matchLabels:
app: api
template:
metadata:
labels:
app: api
spec:
containers:
- name: api
image: ${{modules.my-docker-module.version}} # <--- Garden will resolve this to the correct image before applying the manifest
3. **Define services**: In the same garden.yml
file, you would define a service for each Kubernetes manifest you want to deploy. Here's an example:
yaml
services:
- name: my-service
dependencies: []
timeout: 60
Please note that the kubernetes
module type in Garden 0.12 is quite flexible and can be used to deploy any kind of Kubernetes resource. However, as mentioned earlier, modules are deprecated in Garden 0.14 and later, so you might want to consider upgrading to a newer version of Garden and using actions instead.