hey I'm using garden 0.12 and I want to deploy a ...
# 🤖|ask-kapa
b
hey @microscopic-river-74022 I'm using garden 0.12 and I want to deploy a couple of kubernetes manifests using the power or garden, how would I go about that?
m
Please stand by @bright-policeman-43626 as I search the knowledge base. I normally take about 20 seconds or so. :wave:
---------------------- Sure, I can guide you through the process of deploying Kubernetes manifests using Garden. However, please note that as of Garden version
0.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:
Copy code
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.
4. **Set the deployment target so Garden can stream logs and sync code changes**: You can set the default target in your
garden.yml
file like so:
Copy code
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:
Copy code
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: ----------------------
b
@microscopic-river-74022 seems like that is for 0.13 since 0.12 doesn't have actions?
m
Let me check the knowledge base for you. One moment! :books:
---------------------- I apologize for the confusion. You're correct, the concept of actions was introduced in Garden Bonsai (0.13) and does not exist in Garden 0.12. In Garden 0.12, you would use modules to define your services. Here's how you can deploy Kubernetes manifests using Garden 0.12: 1. **Define a Kubernetes module**: In your
garden.yml
file, you would define a Kubernetes module that points to your Kubernetes manifest files. Here's an example:
Copy code
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:
Copy code
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:
Copy code
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.
For more information on using modules in Garden 0.12, you can refer to the Garden 0.12 documentation (). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------