kubernetes

Description

Specify one or more Kubernetes manifests to deploy.
You can either (or both) specify the manifests as part of the garden.yml configuration, or you can refer to one or more files with existing manifests.
Note that if you include the manifests in the garden.yml file, you can use template strings to interpolate values into the manifests.
If you need more advanced templating features you can use the helm module type.
Below is the full schema reference. For an introduction to configuring Garden modules, please look at our Configuration guide.
The first section contains the complete YAML schema, and the second section describes each schema key.
kubernetes modules also export values that are available in template strings. See the Outputs section below for details.

Complete YAML Schema

The values in the schema below are the default values.
1
# The schema version of this config (currently not used).
2
apiVersion: garden.io/v0
3
​
4
kind: Module
5
​
6
# The type of this module.
7
type:
8
​
9
# The name of this module.
10
name:
11
​
12
# Specify how to build the module. Note that plugins may define additional keys on this object.
13
build:
14
# A list of modules that must be built before this module is built.
15
dependencies:
16
- # Module name to build ahead of this module.
17
name:
18
​
19
# Specify one or more files or directories to copy from the built dependency to this module.
20
copy:
21
- # POSIX-style path or filename of the directory or file(s) to copy to the target.
22
source:
23
​
24
# POSIX-style path or filename to copy the directory or file(s), relative to the build directory.
25
# Defaults to to same as source path.
26
target: ''
27
​
28
# Maximum time in seconds to wait for build to finish.
29
timeout: 1200
30
​
31
# A description of the module.
32
description:
33
​
34
# Set this to `true` to disable the module. You can use this with conditional template strings to disable modules
35
# based on, for example, the current environment or other variables (e.g. `disabled: \${environment.name == "prod"}`).
36
# This can be handy when you only need certain modules for specific environments, e.g. only for development.
37
#
38
# Disabling a module means that any services, tasks and tests contained in it will not be deployed or run. It also
39
# means that the module is not built _unless_ it is declared as a build dependency by another enabled module (in which
40
# case building this module is necessary for the dependant to be built).
41
#
42
# If you disable the module, and its services, tasks or tests are referenced as _runtime_ dependencies, Garden will
43
# automatically ignore those dependency declarations. Note however that template strings referencing the module's
44
# service or task outputs (i.e. runtime outputs) will fail to resolve when the module is disabled, so you need to make
45
# sure to provide alternate values for those if you're using them, using conditional expressions.
46
disabled: false
47
​
48
# Specify a list of POSIX-style paths or globs that should be regarded as the source files for this module. Files that
49
# do *not* match these paths or globs are excluded when computing the version of the module, when responding to
50
# filesystem watch events, and when staging builds.
51
#
52
# Note that you can also _exclude_ files using the `exclude` field or by placing `.gardenignore` files in your source
53
# tree, which use the same format as `.gitignore` files. See the [Configuration Files
54
# guide](https://docs.garden.io/using-garden/configuration-overview#including-excluding-files-and-directories) for
55
# details.
56
#
57
# Also note that specifying an empty list here means _no sources_ should be included.
58
#
59
# If neither `include` nor `exclude` is set, Garden automatically sets `include` to equal the
60
# `files` directive so that only the Kubernetes manifests get included.
61
include:
62
​
63
# Specify a list of POSIX-style paths or glob patterns that should be excluded from the module. Files that match these
64
# paths or globs are excluded when computing the version of the module, when responding to filesystem watch events,
65
# and when staging builds.
66
#
67
# Note that you can also explicitly _include_ files using the `include` field. If you also specify the `include`
68
# field, the files/patterns specified here are filtered from the files matched by `include`. See the [Configuration
69
# Files guide](https://docs.garden.io/using-garden/configuration-overview#including-excluding-files-and-directories)
70
# for details.
71
#
72
# Unlike the `modules.exclude` field in the project config, the filters here have _no effect_ on which files and
73
# directories are watched for changes. Use the project `modules.exclude` field to affect those, if you have large
74
# directories that should not be watched for changes.
75
exclude:
76
​
77
# A remote repository URL. Currently only supports git servers. Must contain a hash suffix pointing to a specific
78
# branch or tag, with the format: <git remote url>#<branch|tag>
79
#
80
# Garden will import the repository source code into this module, but read the module's config from the local
81
# garden.yml file.
82
repositoryUrl:
83
​
84
# When false, disables pushing this module to remote registries.
85
allowPublish: true
86
​
87
# A list of files to write to the module directory when resolving this module. This is useful to automatically
88
# generate (and template) any supporting files needed for the module.
89
generateFiles:
90
- # POSIX-style filename to read the source file contents from, relative to the path of the module (or the
91
# ModuleTemplate configuration file if one is being applied).
92
# This file may contain template strings, much like any other field in the configuration.
93
sourcePath:
94
​
95
# POSIX-style filename to write the resolved file contents to, relative to the path of the module source directory
96
# (for remote modules this means the root of the module repository, otherwise the directory of the module
97
# configuration).
98
#
99
# Note that any existing file with the same name will be overwritten. If the path contains one or more
100
# directories, they will be automatically created if missing.
101
targetPath:
102
​
103
# By default, Garden will attempt to resolve any Garden template strings in source files. Set this to false to
104
# skip resolving template strings. Note that this does not apply when setting the `value` field, since that's
105
# resolved earlier when parsing the configuration.
106
resolveTemplates: true
107
​
108
# The desired file contents as a string.
109
value:
110
​
111
# A map of variables scoped to this particular module. These are resolved before any other parts of the module
112
# configuration and take precedence over project-scoped variables. They may reference project-scoped variables, and
113
# generally use any template strings normally allowed when resolving modules.
114
variables:
115
​
116
# Specify a path (relative to the module root) to a file containing variables, that we apply on top of the
117
# module-level `variables` field.
118
#
119
# The format of the files is determined by the configured file's extension:
120
#
121
# * `.env` - Standard "dotenv" format, as defined by [dotenv](https://github.com/motdotla/dotenv#rules).
122
# * `.yaml`/`.yml` - YAML. The file must consist of a YAML document, which must be a map (dictionary). Keys may
123
# contain any value type.
124
# * `.json` - JSON. Must contain a single JSON _object_ (not an array).
125
#
126
# _NOTE: The default varfile format will change to YAML in Garden v0.13, since YAML allows for definition of nested
127
# objects and arrays._
128
#
129
# To use different module-level varfiles in different environments, you can template in the environment name
130
# to the varfile name, e.g. `varfile: "my-module.\$\{environment.name\}.env` (this assumes that the corresponding
131
# varfiles exist).
132
varfile:
133
​
134
# The names of any services that this service depends on at runtime, and the names of any tasks that should be
135
# executed before this service is deployed.
136
dependencies: []
137
​
138
# Specifies which files or directories to sync to which paths inside the running containers of the service when it's
139
# in dev mode, and overrides for the container command and/or arguments.
140
#
141
# Note that `serviceResource` must also be specified to enable dev mode.
142
#
143
# Dev mode is enabled when running the `garden dev` command, and by setting the `--dev` flag on the `garden deploy`
144
# command.
145
#
146
# See the [Code Synchronization guide](https://docs.garden.io/guides/code-synchronization-dev-mode) for more
147
# information.
148
devMode:
149
# Override the default container arguments when in dev mode.
150
args:
151
​
152
# Override the default container command (i.e. entrypoint) when in dev mode.
153
command:
154
​
155
# Specify one or more source files or directories to automatically sync with the running container.
156
sync:
157
- # POSIX-style path of the directory to sync to the target, relative to the module's top-level directory. Must be
158
# a relative path. Defaults to the module's top-level directory if no value is provided.
159
source: .
160
​
161
# POSIX-style absolute path to sync the directory to inside the container. The root path (i.e. "/") is not
162
# allowed.
163
target:
164
​
165
# Specify a list of POSIX-style paths or glob patterns that should be excluded from the sync.
166
#
167
# `.git` directories and `.garden` directories are always ignored.
168
exclude:
169
​
170
# The sync mode to use for the given paths. See the [Dev Mode
171
# guide](https://docs.garden.io/guides/code-synchronization-dev-mode) for details.
172
mode: one-way-safe
173
​
174
# The default permission bits, specified as an octal, to set on files at the sync target. Defaults to 0600 (user
175
# read/write). See the [Mutagen docs](https://mutagen.io/documentation/synchronization/permissions#permissions)
176
# for more information.
177
defaultFileMode:
178
​
179
# The default permission bits, specified as an octal, to set on directories at the sync target. Defaults to 0700
180
# (user read/write). See the [Mutagen
181
# docs](https://mutagen.io/documentation/synchronization/permissions#permissions) for more information.
182
defaultDirectoryMode:
183
​
184
# Set the default owner of files and directories at the target. Specify either an integer ID or a string name.
185
# See the [Mutagen docs](https://mutagen.io/documentation/synchronization/permissions#owners-and-groups) for
186
# more information.
187
defaultOwner:
188
​
189
# Set the default group on files and directories at the target. Specify either an integer ID or a string name.
190
# See the [Mutagen docs](https://mutagen.io/documentation/synchronization/permissions#owners-and-groups) for
191
# more information.
192
defaultGroup:
193
​
194
# Optionally specify the name of a specific container to sync to. If not specified, the first container in the
195
# workload is used.
196
containerName:
197
​
198
# POSIX-style paths to YAML files to load manifests from. Each can contain multiple manifests, and can include any
199
# Garden template strings, which will be resolved before applying the manifests.
200
files: []
201
​
202
# List of Kubernetes resource manifests to deploy. Use this instead of the `files` field if you need to resolve
203
# template strings in any of the manifests.
204
manifests:
205
- # The API version of the resource.
206
apiVersion:
207
​
208
# The kind of the resource.
209
kind:
210
​
211
metadata:
212
# The name of the resource.
213
name:
214
​
215
# A valid Kubernetes namespace name. Must be a valid RFC1035/RFC1123 (DNS) label (may contain lowercase letters,
216
# numbers and dashes, must start with a letter, and cannot end with a dash) and must not be longer than 63 characters.
217
namespace:
218
​
219
# Manually specify port forwards that Garden should set up when deploying in dev or watch mode. If specified, these
220
# override the auto-detection of forwardable ports, so you'll need to specify the full list of port forwards to
221
# create.
222
portForwards:
223
- # An identifier to describe the port forward.
224
name:
225
​
226
# The full resource kind and name to forward to, e.g. Service/my-service or Deployment/my-deployment. Note that
227
# Garden will not validate this ahead of attempting to start the port forward, so you need to make sure this is
228
# correctly set. The types of resources supported will match that of the `kubectl port-forward` CLI command.
229
resource:
230
​
231
# The port number on the remote resource to forward to.
232
targetPort:
233
​
234
# The _preferred_ local port to forward from. If none is set, a random port is chosen. If the specified port is
235
# not available, a warning is shown and a random port chosen instead.
236
localPort:
237
​
238
# The Deployment, DaemonSet or StatefulSet or Pod that Garden should regard as the _Garden service_ in this module
239
# (not to be confused with Kubernetes Service resources).
240
#
241
# This can either reference a workload (i.e. a Deployment, DaemonSet or StatefulSet) via the `kind` and `name` fields,
242
# or a Pod via the `podSelector` field.
243
#
244
# Because a `kubernetes` module can contain any number of Kubernetes resources, this needs to be specified for certain
245
# Garden features and commands to work.
246
serviceResource:
247
# The type of Kubernetes resource to sync files to.
248
kind: Deployment
249
​
250
# The name of the resource to sync to. If the module contains a single resource of the specified Kind, this can be
251
# omitted.
252
name:
253
​
254
# The name of a container in the target. Specify this if the target contains more than one container and the main
255
# container is not the first container in the spec.
256
containerName:
257
​
258
# A map of string key/value labels to match on any Pods in the namespace. When specified, a random ready Pod with
259
# matching labels will be picked as a target, so make sure the labels will always match a specific Pod type.
260
podSelector:
261
​
262
# The Garden module that contains the sources for the container. This needs to be specified under `serviceResource`
263
# in order to enable hot-reloading and dev mode, but is not necessary for tasks and tests.
264
#
265
# Must be a `container` module, and for hot-reloading to work you must specify the `hotReload` field on the
266
# container module (not required for dev mode).
267
#
268
# _Note: If you specify a module here, you don't need to specify it additionally under `build.dependencies`._
269
containerModule:
270
​
271
# If specified, overrides the arguments for the main container when running in hot-reload mode.
272
hotReloadArgs:
273
​
274
tasks:
275
- # The name of the task.
276
name:
277
​
278
# A description of the task.
279
description:
280
​
281
# The names of any tasks that must be executed, and the names of any services that must be running, before this
282
# task is executed.
283
dependencies: []
284
​
285
# Set this to `true` to disable the task. You can use this with conditional template strings to enable/disable
286
# tasks based on, for example, the current environment or other variables (e.g. `enabled: \${environment.name !=
287
# "prod"}`). This can be handy when you only want certain tasks to run in specific environments, e.g. only for
288
# development.
289
#
290
# Disabling a task means that it will not be run, and will also be ignored if it is declared as a runtime
291
# dependency for another service, test or task.
292
#
293
# Note however that template strings referencing the task's outputs (i.e. runtime outputs) will fail to resolve
294
# when the task is disabled, so you need to make sure to provide alternate values for those if you're using them,
295
# using conditional expressions.
296
disabled: false
297
​
298
# Maximum duration (in seconds) of the task's execution.
299
timeout: null
300
​
301
# The Deployment, DaemonSet, StatefulSet or Pod that Garden should use to execute this task.
302
# If not specified, the `serviceResource` configured on the module will be used. If neither is specified,
303
# an error will be thrown.
304
#
305
# This can either reference a workload (i.e. a Deployment, DaemonSet or StatefulSet) via the `kind` and `name`
306
# fields, or a Pod via the `podSelector` field.
307
#
308
# The following pod spec fields from the service resource will be used (if present) when executing the task:
309
# * `affinity`
310
# * `automountServiceAccountToken`
311
# * `containers`
312
# * `dnsConfig`
313
# * `dnsPolicy`
314
# * `enableServiceLinks`
315
# * `hostAliases`
316
# * `hostIPC`
317
# * `hostNetwork`
318
# * `hostPID`
319
# * `hostname`
320
# * `imagePullSecrets`
321
# * `nodeName`
322
# * `nodeSelector`
323
# * `overhead`
324
# * `preemptionPolicy`
325
# * `priority`
326
# * `priorityClassName`
327
# * `runtimeClassName`
328
# * `schedulerName`
329
# * `securityContext`
330
# * `serviceAccount`
331
# * `serviceAccountName`
332
# * `shareProcessNamespace`
333
# * `subdomain`
334
# * `tolerations`
335
# * `topologySpreadConstraints`
336
# * `volumes`
337
resource:
338
# The type of Kubernetes resource to sync files to.
339
kind: Deployment
340
​
341
# The name of the resource to sync to. If the module contains a single resource of the specified Kind, this can
342
# be omitted.
343
name:
344
​
345
# The name of a container in the target. Specify this if the target contains more than one container and the
346
# main container is not the first container in the spec.
347
containerName:
348
​
349
# A map of string key/value labels to match on any Pods in the namespace. When specified, a random ready Pod
350
# with matching labels will be picked as a target, so make sure the labels will always match a specific Pod
351
# type.
352
podSelector:
353
​
354
# Set to false if you don't want the task's result to be cached. Use this if the task needs to be run any time
355
# your project (or one or more of the task's dependants) is deployed. Otherwise the task is only re-run when its
356
# version changes (i.e. the module or one of its dependencies is modified), or when you run `garden run task`.
357
cacheResult: true
358
​
359
# The command/entrypoint used to run the task inside the container.
360
command:
361
​
362
# The arguments to pass to the container used for execution.
363
args:
364
​
365
# Key/value map of environment variables. Keys must be valid POSIX environment variable names (must not start with
366
# `GARDEN`) and values must be primitives or references to secrets.
367
env: {}
368
​
369
# Specify artifacts to copy out of the container after the run. The artifacts are stored locally under
370
# the `.garden/artifacts` directory.
371
artifacts:
372
- # A POSIX-style path or glob to copy. Must be an absolute path. May contain wildcards.
373
source:
374
​
375
# A POSIX-style path to copy the artifacts to, relative to the project artifacts directory at
376
# `.garden/artifacts`.
377
target: .
378
​
379
tests:
380
- # The name of the test.
381
name:
382
​
383
# The names of any services that must be running, and the names of any tasks that must be executed, before the
384
# test is run.
385
dependencies: []
386
​
387
# Set this to `true` to disable the test. You can use this with conditional template strings to
388
# enable/disable tests based on, for example, the current environment or other variables (e.g.
389
# `enabled: \${environment.name != "prod"}`). This is handy when you only want certain tests to run in
390
# specific environments, e.g. only during CI.
391
disabled: false
392
​
393
# Maximum duration (in seconds) of the test run.
394
timeout: null
395
​
396
# The Deployment, DaemonSet or StatefulSet or Pod that Garden should use to execute this test suite.
397
# If not specified, the `serviceResource` configured on the module will be used. If neither is specified,
398
# an error will be thrown.
399
#
400
# This can either reference a workload (i.e. a Deployment, DaemonSet or StatefulSet) via the `kind` and `name`
401
# fields, or a Pod via the `podSelector` field.
402
#
403
# The following pod spec fields from the service resource will be used (if present) when executing the test suite:
404
# * `affinity`
405
# * `automountServiceAccountToken`
406
# * `containers`
407
# * `dnsConfig`
408
# * `dnsPolicy`
409
# * `enableServiceLinks`
410
# * `hostAliases`
411
# * `hostIPC`
412
# * `hostNetwork`
413
# * `hostPID`
414
# * `hostname`
415
# * `imagePullSecrets`
416
# * `nodeName`
417
# * `nodeSelector`
418
# * `overhead`
419
# * `preemptionPolicy`
420
# * `priority`
421
# * `priorityClassName`
422
# * `runtimeClassName`
423
# * `schedulerName`
424
# * `securityContext`
425
# * `serviceAccount`
426
# * `serviceAccountName`
427
# * `shareProcessNamespace`
428
# * `subdomain`
429
# * `tolerations`
430
# * `topologySpreadConstraints`
431
# * `volumes`
432
resource:
433
# The type of Kubernetes resource to sync files to.
434
kind: Deployment
435
​
436
# The name of the resource to sync to. If the module contains a single resource of the specified Kind, this can
437
# be omitted.
438
name:
439
​
440
# The name of a container in the target. Specify this if the target contains more than one container and the
441
# main container is not the first container in the spec.
442
containerName:
443
​
444
# A map of string key/value labels to match on any Pods in the namespace. When specified, a random ready Pod
445
# with matching labels will be picked as a target, so make sure the labels will always match a specific Pod
446
# type.
447
podSelector:
448
​
449
# The command/entrypoint used to run the test inside the container.
450
command:
451
​
452
# The arguments to pass to the container used for testing.
453
args:
454
​
455
# Key/value map of environment variables. Keys must be valid POSIX environment variable names (must not start with
456
# `GARDEN`) and values must be primitives or references to secrets.
457
env: {}
458
​
459
# Specify artifacts to copy out of the container after the run. The artifacts are stored locally under
460
# the `.garden/artifacts` directory.
461
artifacts:
462
- # A POSIX-style path or glob to copy. Must be an absolute path. May contain wildcards.
463
source:
464
​
465
# A POSIX-style path to copy the artifacts to, relative to the project artifacts directory at
466
# `.garden/artifacts`.
467
target: .
468
​
469
# The maximum duration (in seconds) to wait for resources to deploy and become healthy.
470
timeout: 300
Copied!

Configuration Keys

apiVersion

The schema version of this config (currently not used).
Type
Allowed Values
Default
Required
string
"garden.io/v0"
"garden.io/v0"
Yes

kind

Type
Allowed Values
Default
Required
string
"Module"
"Module"
Yes

type

The type of this module.
Type
Required
string
Yes
Example:
1
type: "container"
Copied!

name

The name of this module.
Type
Required
string
Yes
Example:
1
name: "my-sweet-module"
Copied!

build

Specify how to build the module. Note that plugins may define additional keys on this object.
Type
Default
Required
object
{"dependencies":[]}
No

build.dependencies[]

​build > dependencies
A list of modules that must be built before this module is built.
Type
Default
Required
array[object]
[]
No
Example:
1
build:
2
...
3
dependencies:
4
- name: some-other-module-name
Copied!

build.dependencies[].name

​build > dependencies > name
Module name to build ahead of this module.
Type
Required
string
Yes

build.dependencies[].copy[]

​build > dependencies > copy
Specify one or more files or directories to copy from the built dependency to this module.
Type
Default
Required
array[object]
[]
No

build.dependencies[].copy[].source

​build > dependencies > copy > source
POSIX-style path or filename of the directory or file(s) to copy to the target.
Type
Required
posixPath
Yes

build.dependencies[].copy[].target

​build > dependencies > copy > target
POSIX-style path or filename to copy the directory or file(s), relative to the build directory. Defaults to to same as source path.
Type
Default
Required
posixPath
""
No

build.timeout

​build > timeout
Maximum time in seconds to wait for build to finish.
Type
Default
Required
number
1200
No

description

A description of the module.
Type
Required
string
No

disabled

Set this to true to disable the module. You can use this with conditional template strings to disable modules based on, for example, the current environment or other variables (e.g. disabled: \${environment.name == "prod"}). This can be handy when you only need certain modules for specific environments, e.g. only for development.
Disabling a module means that any services, tasks and tests contained in it will not be deployed or run. It also means that the module is not built unless it is declared as a build dependency by another enabled module (in which case building this module is necessary for the dependant to be built).
If you disable the module, and its services, tasks or tests are referenced as runtime dependencies, Garden will automatically ignore those dependency declarations. Note however that template strings referencing the module's service or task outputs (i.e. runtime outputs) will fail to resolve when the module is disabled, so you need to make sure to provide alternate values for those if you're using them, using conditional expressions.
Type
Default
Required
boolean
false
No

include[]

Specify a list of POSIX-style paths or globs that should be regarded as the source files for this module. Files that do not match these paths or globs are excluded when computing the version of the module, when responding to filesystem watch events, and when staging builds.
Note that you can also exclude files using the exclude field or by placing .gardenignore files in your source tree, which use the same format as .gitignore files. See the Configuration Files guide for details.
Also note that specifying an empty list here means no sources should be included.
If neither include nor exclude is set, Garden automatically sets include to equal the files directive so that only the Kubernetes manifests get included.
Type
Required
array[posixPath]
No
Example:
1
include:
2
- Dockerfile
3
- my-app.js
Copied!

exclude[]

Specify a list of POSIX-style paths or glob patterns that should be excluded from the module. Files that match these paths or globs are excluded when computing the version of the module, when responding to filesystem watch events, and when staging builds.
Note that you can also explicitly include files using the include field. If you also specify the include field, the files/patterns specified here are filtered from the files matched by include. See the Configuration Files guide for details.
Unlike the modules.exclude field in the project config, the filters here have no effect on which files and directories are watched for changes. Use the project modules.exclude field to affect those, if you have large directories that should not be watched for changes.
Type
Required
array[posixPath]
No
Example:
1
exclude:
2
- tmp/**/*
3
- '*.log'
Copied!

repositoryUrl

A remote repository URL. Currently only supports git servers. Must contain a hash suffix pointing to a specific branch or tag, with the format: #<branch|tag>
Garden will import the repository source code into this module, but read the module's config from the local garden.yml file.
Type
Required
`gitUrl
string`
Example:
1
repositoryUrl: "git+https://github.com/org/repo.git#v2.0"
Copied!

allowPublish

When false, disables pushing this module to remote registries.
Type
Default
Required
boolean
true
No

generateFiles[]

A list of files to write to the module directory when resolving this module. This is useful to automatically generate (and template) any supporting files needed for the module.
Type
Default
Required
array[object]
[]
No

generateFiles[].sourcePath

​generateFiles > sourcePath
POSIX-style filename to read the source file contents from, relative to the path of the module (or the ModuleTemplate configuration file if one is being applied). This file may contain template strings, much like any other field in the configuration.
Type
Required
posixPath
No

generateFiles[].targetPath

​generateFiles > targetPath
POSIX-style filename to write the resolved file contents to, relative to the path of the module source directory (for remote modules this means the root of the module repository, otherwise the directory of the module configuration).
Note that any existing file with the same name will be overwritten. If the path contains one or more directories, they will be automatically created if missing.
Type
Required
posixPath
Yes

generateFiles[].resolveTemplates

​generateFiles > resolveTemplates
By default, Garden will attempt to resolve any Garden template strings in source files. Set this to false to skip resolving template strings. Note that this does not apply when setting the value field, since that's resolved earlier when parsing the configuration.
Type
Default
Required
boolean
true
No

generateFiles[].value

​generateFiles > value
The desired file contents as a string.
Type
Required
string
No

variables

A map of variables scoped to this particular module. These are resolved before any other parts of the module configuration and take precedence over project-scoped variables. They may reference project-scoped variables, and generally use any template strings normally allowed when resolving modules.
Type
Required
object
No

varfile

Specify a path (relative to the module root) to a file containing variables, that we apply on top of the module-level variables field.
The format of the files is determined by the configured file's extension:
  • .env - Standard "dotenv" format, as defined by dotenv.
  • .yaml/.yml - YAML. The file must consist of a YAML document, which must be a map (dictionary). Keys may contain any value type.
  • .json - JSON. Must contain a single JSON object (not an array).
NOTE: The default varfile format will change to YAML in Garden v0.13, since YAML allows for definition of nested objects and arrays.
To use different module-level varfiles in different environments, you can template in the environment name to the varfile name, e.g. varfile: "my-module.\$\{environment.name\}.env (this assumes that the corresponding varfiles exist).
Type
Required
posixPath
No
Example:
1
varfile: "my-module.env"
Copied!

dependencies[]

The names of any services that this service depends on at runtime, and the names of any tasks that should be executed before this service is deployed.
Type
Default
Required
array[string]
[]
No

devMode

Specifies which files or directories to sync to which paths inside the running containers of the service when it's in dev mode, and overrides for the container command and/or arguments.
Note that serviceResource must also be specified to enable dev mode.
Dev mode is enabled when running the garden dev command, and by setting the --dev flag on the garden deploy command.
See the Code Synchronization guide for more information.
Type
Required
object
No

devMode.args[]

​devMode > args
Override the default container arguments when in dev mode.
Type
Required
array[string]
No

devMode.command[]

​devMode > command
Override the default container command (i.e. entrypoint) when in dev mode.
Type
Required
array[string]
No

devMode.sync[]

​devMode > sync
Specify one or more source files or directories to automatically sync with the running container.
Type
Required
array[object]
No

devMode.sync[].source

​devMode > sync > source
POSIX-style path of the directory to sync to the target, relative to the module's top-level directory. Must be a relative path. Defaults to the module's top-level directory if no value is provided.
Type
Default
Required
posixPath
"."
No
Example:
1
devMode:
2
...
3
sync:
4
- source: "src"
Copied!

devMode.sync[].target

​devMode > sync > target
POSIX-style absolute path to sync the directory to inside the container. The root path (i.e. "/") is not allowed.
Type
Required
posixPath
Yes
Example:
1
devMode:
2
...
3
sync:
4
- target: "/app/src"
Copied!

devMode.sync[].exclude[]

​devMode > sync > exclude
Specify a list of POSIX-style paths or glob patterns that should be excluded from the sync.
.git directories and .garden directories are always ignored.
Type
Required
array[posixPath]
No
Example:
1
devMode:
2
...
3
sync:
4
- exclude:
5
- dist/**/*
6
- '*.log'
Copied!

devMode.sync[].mode

​devMode > sync > mode
The sync mode to use for the given paths. See the Dev Mode guide for details.
Type
Allowed Values
Default
Required
string
"one-way", "one-way-safe", "one-way-replica", "one-way-reverse", "one-way-replica-reverse", "two-way", "two-way-safe", "two-way-resolved"
"one-way-safe"
Yes

devMode.sync[].defaultFileMode

​devMode > sync > defaultFileMode
The default permission bits, specified as an octal, to set on files at the sync target. Defaults to 0600 (user read/write). See the Mutagen docs for more information.
Type
Required
number
No

devMode.sync[].defaultDirectoryMode

​devMode > sync > defaultDirectoryMode
The default permission bits, specified as an octal, to set on directories at the sync target. Defaults to 0700 (user read/write). See the Mutagen docs for more information.
Type
Required
number
No

devMode.sync[].defaultOwner

​devMode > sync > defaultOwner
Set the default owner of files and directories at the target. Specify either an integer ID or a string name. See the Mutagen docs for more information.
Type
Required
`number
string`

devMode.sync[].defaultGroup

​devMode > sync > defaultGroup
Set the default group on files and directories at the target. Specify either an integer ID or a string name. See the Mutagen docs for more information.
Type
Required
`number
string`

devMode.containerName

​devMode > containerName
Optionally specify the name of a specific container to sync to. If not specified, the first container in the workload is used.
Type
Required
string
No

files[]

POSIX-style paths to YAML files to load manifests from. Each can contain multiple manifests, and can include any Garden template strings, which will be resolved before applying the manifests.
Type
Default
Required
array[posixPath]
[]
No

manifests[]

List of Kubernetes resource manifests to deploy. Use this instead of the files field if you need to resolve template strings in any of the manifests.
Type
Default
Required
array[object]
[]
No

manifests[].apiVersion

​manifests > apiVersion
The API version of the resource.
Type
Required
string
Yes

manifests[].kind

​manifests > kind
The kind of the resource.
Type
Required
string
Yes

manifests[].metadata

​manifests > metadata
Type
Required
object
Yes

manifests[].metadata.name

​manifests > metadata > name
The name of the resource.
Type
Required
string
Yes

namespace

A valid Kubernetes namespace name. Must be a valid RFC1035/RFC1123 (DNS) label (may contain lowercase letters, numbers and dashes, must start with a letter, and cannot end with a dash) and must not be longer than 63 characters.
Type
Required
string
No

portForwards[]

Manually specify port forwards that Garden should set up when deploying in dev or watch mode. If specified, these override the auto-detection of forwardable ports, so you'll need to specify the full list of port forwards to create.
Type
Required
array[object]
No

portForwards[].name

​portForwards > name
An identifier to describe the port forward.
Type
Required
string
No

portForwards[].resource

​portForwards > resource
The full resource kind and name to forward to, e.g. Service/my-service or Deployment/my-deployment. Note that Garden will not validate this ahead of attempting to start the port forward, so you need to make sure this is correctly set. The types of resources supported will match that of the kubectl port-forward CLI command.
Type
Required
string
Yes

portForwards[].targetPort

​portForwards > targetPort
The port number on the remote resource to forward to.
Type
Required
number
Yes

portForwards[].localPort

​portForwards > localPort
The preferred local port to forward from. If none is set, a random port is chosen. If the specified port is not available, a warning is shown and a random port chosen instead.
Type
Required
number
No

serviceResource

The Deployment, DaemonSet or StatefulSet or Pod that Garden should regard as the Garden service in this module (not to be confused with Kubernetes Service resources).
This can either reference a workload (i.e. a Deployment, DaemonSet or StatefulSet) via the kind and name fields, or a Pod via the podSelector field.
Because a kubernetes module can contain any number of Kubernetes resources, this needs to be specified for certain Garden features and commands to work.
Type
Required
object
No

serviceResource.kind

​serviceResource > kind
The type of Kubernetes resource to sync files to.
Type
Allowed Values
Default
Required
string
"Deployment", "DaemonSet", "StatefulSet"
"Deployment"
Yes

serviceResource.name

​serviceResource > name
The name of the resource to sync to. If the module contains a single resource of the specified Kind, this can be omitted.
Type
Required
string
No

serviceResource.containerName

​serviceResource > containerName
The name of a container in the target. Specify this if the target contains more than one container and the main container is not the first container in the spec.
Type
Required
string
No

serviceResource.podSelector

​serviceResource > podSelector
A map of string key/value labels to match on any Pods in the namespace. When specified, a random ready Pod with matching labels will be picked as a target, so make sure the labels will always match a specific Pod type.
Type
Required
object
No

serviceResource.containerModule

​serviceResource > containerModule
The Garden module that contains the sources for the container. This needs to be specified under serviceResource in order to enable hot-reloading and dev mode, but is not necessary for tasks and tests.
Must be a container module, and for hot-reloading to work you must specify the hotReload field on the container module (not required for dev mode).
Note: If you specify a module here, you don't need to specify it additionally under build.dependencies.
Type
Required
string
No
Example:
1
serviceResource:
2
...
3
containerModule: "my-container-module"
Copied!

serviceResource.hotReloadArgs[]

​serviceResource > hotReloadArgs
If specified, overrides the arguments for the main container when running in hot-reload mode.
Type
Required
array[string]
No
Example:
1
serviceResource:
2
...
3
hotReloadArgs:
4
- nodemon
5
- my-server.js
Copied!

tasks[]

Type
Default
Required
array[object]
[]
No

tasks[].name

​tasks > name
The name of the task.
Type
Required
string
Yes

tasks[].description

​tasks > description
A description of the task.
Type
Required
string
No

tasks[].dependencies[]

​tasks > dependencies
The names of any tasks that must be executed, and the names of any services that must be running, before this task is executed.
Type
Default
Required
array[string]
[]
No

tasks[].disabled

​tasks > disabled
Set this to true to disable the task. You can use this with conditional template strings to enable/disable tasks based on, for example, the current environment or other variables (e.g. enabled: \${environment.name != "prod"}). This can be handy when you only want certain tasks to run in specific environments, e.g. only for development.
Disabling a task means that it will not be run, and will also be ignored if it is declared as a runtime dependency for another service, test or task.
Note however that template strings referencing the task's outputs (i.e. runtime outputs) will fail to resolve when the task is disabled, so you need to make sure to provide alternate values for those if you're using them, using conditional expressions.
Type
Default
Required
boolean
false
No

tasks[].timeout

​tasks > timeout
Maximum duration (in seconds) of the task's execution.
Type
Default
Required
number
null
No

tasks[].resource

​tasks > resource
The Deployment, DaemonSet, StatefulSet or Pod that Garden should use to execute this task. If not specified, the serviceResource configured on the module will be used. If neither is specified, an error will be thrown.
This can either reference a workload (i.e. a Deployment, DaemonSet or StatefulSet) via the kind and name fields, or a Pod via the podSelector field.
The following pod spec fields from the service resource will be used (if present) when executing the task:
  • affinity
  • automountServiceAccountToken
  • containers
  • dnsConfig
  • dnsPolicy
  • enableServiceLinks
  • hostAliases
  • hostIPC
  • hostNetwork
  • hostPID
  • hostname
  • imagePullSecrets
  • nodeName
  • nodeSelector
  • overhead
  • preemptionPolicy
  • priority
  • priorityClassName
  • runtimeClassName
  • schedulerName
  • securityContext
  • serviceAccount
  • serviceAccountName
  • shareProcessNamespace
  • subdomain
  • tolerations
  • topologySpreadConstraints
  • volumes
Type
Required
object
No

tasks[].resource.kind

​tasks > resource > kind
The type of Kubernetes resource to sync files to.
Type
Allowed Values
Default
Required
string
"Deployment", "DaemonSet", "StatefulSet"
"Deployment"
Yes

tasks[].resource.name

​