persistentvolumeclaim

Description

Creates a PersistentVolumeClaim in your namespace, that can be referenced and mounted by other resources and container modules.

See the Mounting volumes guide for more info and usage examples.

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.

persistentvolumeclaim 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.

# The schema version of this module's config (currently not used).
apiVersion: garden.io/v0
​
kind: Module
​
# The type of this module.
type:
​
# The name of this module.
name:
​
# A description of the module.
description:
​
# 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.
disabled: false
​
# 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](https://docs.garden.io/guides/configuration-files#including-excluding-files-and-directories) for details.
#
# Also note that specifying an empty list here means _no sources_ should be included.
include:
​
# 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](https://docs.garden.io/guides/configuration-files#including-excluding-files-and-directories)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.
exclude:
​
# A remote repository URL. Currently only supports git servers. Must contain a hash suffix pointing to a specific
# branch or tag, with the format: <git remote url>#<branch|tag>
#
# Garden will import the repository source code into this module, but read the module's config from the local
# garden.yml file.
repositoryUrl:
​
# When false, disables pushing this module to remote registries.
allowPublish: true
​
# Specify how to build the module. Note that plugins may define additional keys on this object.
build:
# A list of modules that must be built before this module is built.
dependencies:
- # Module name to build ahead of this module.
name:
​
# Specify one or more files or directories to copy from the built dependency to this module.
copy:
- # POSIX-style path or filename of the directory or file(s) to copy to the target.
source:
​
# POSIX-style path or filename to copy the directory or file(s), relative to the build directory.
# Defaults to to same as source path.
target: ''
​
# List of services and tasks to deploy/run before deploying this PVC.
dependencies: []
​
# The namespace to deploy the PVC in. Note that any module referencing the PVC must be in the same namespace, so in
# most cases you should leave this unset.
namespace:
​
# The spec for the PVC. This is passed directly to the created PersistentVolumeClaim resource. Note that the spec
# schema may include (or even require) additional fields, depending on the used `storageClass`. See the
# [PersistentVolumeClaim docs](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims)
# for details.
spec:
# AccessModes contains the desired access modes the volume should have. More info:
# https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1
accessModes:
​
# TypedLocalObjectReference contains enough information to let you locate the typed referenced object inside the
# same namespace.
dataSource:
# APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must
# be in the core API group. For any other third-party types, APIGroup is required.
apiGroup:
​
# Kind is the type of resource being referenced
kind:
​
# Name is the name of resource being referenced
name:
​
# ResourceRequirements describes the compute resource requirements.
resources:
# Limits describes the maximum amount of compute resources allowed. More info:
# https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
limits:
​
# Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it
# defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info:
# https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
requests:
​
# A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are
# ANDed. An empty label selector matches all objects. A null label selector matches no objects.
selector:
# matchExpressions is a list of label selector requirements. The requirements are ANDed.
matchExpressions:
​
# matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an
# element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only
# "value". The requirements are ANDed.
matchLabels:
​
# Name of the StorageClass required by the claim. More info:
# https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1
storageClassName:
​
# volumeMode defines what type of volume is required by the claim. Value of Filesystem is implied when not included
# in claim spec. This is a beta feature.
volumeMode:
​
# VolumeName is the binding reference to the PersistentVolume backing this claim.
volumeName:

Configuration Keys

apiVersion

The schema version of this module's 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:

type: "container"

name

The name of this module.

Type

Required

string

Yes

Example:

name: "my-sweet-module"

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.

Type

Required

array[posixPath]

No

Example:

include:
- Dockerfile
- my-app.js

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 guidefor 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:

exclude:
- tmp/**/*
- '*.log'

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: #

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`

No

Example:

repositoryUrl: "git+https://github.com/org/repo.git#v2.0"

allowPublish

When false, disables pushing this module to remote registries.

Type

Default

Required

boolean

true

No

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:

build:
...
dependencies:
- name: some-other-module-name

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

dependencies[]

List of services and tasks to deploy/run before deploying this PVC.

Type

Default

Required

array[string]

[]

No

namespace

The namespace to deploy the PVC in. Note that any module referencing the PVC must be in the same namespace, so in most cases you should leave this unset.

Type

Required

string

No

spec

The spec for the PVC. This is passed directly to the created PersistentVolumeClaim resource. Note that the spec schema may include (or even require) additional fields, depending on the used storageClass. See the PersistentVolumeClaim docs for details.

Type

Required

customObject

Yes

spec.accessModes[]

​spec > accessModes

AccessModes contains the desired access modes the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1​

Type

Required

array

No

spec.dataSource

​spec > dataSource

TypedLocalObjectReference contains enough information to let you locate the typed referenced object inside the same namespace.

Type

Required

object

No

spec.dataSource.apiGroup

​spec > dataSource > apiGroup

APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required.

Type

Required

string

No

spec.dataSource.kind

​spec > dataSource > kind

Kind is the type of resource being referenced

Type

Required

string

No

spec.dataSource.name

​spec > dataSource > name

Name is the name of resource being referenced

Type

Required

string

No

spec.resources

​spec > resources

ResourceRequirements describes the compute resource requirements.

Type

Required

object

No

spec.resources.limits

​spec > resources > limits

Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/​

Type

Required

object

No

spec.resources.requests

​spec > resources > requests

Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/​

Type

Required

object

No

spec.selector

​spec > selector

A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.

Type

Required

object

No

spec.selector.matchExpressions[]

​spec > selector > matchExpressions

matchExpressions is a list of label selector requirements. The requirements are ANDed.

Type

Required

array

No

spec.selector.matchLabels

​spec > selector > matchLabels

matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.

Type

Required

object

No

spec.storageClassName

​spec > storageClassName

Name of the StorageClass required by the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1​

Type

Required

string

No

spec.volumeMode

​spec > volumeMode

volumeMode defines what type of volume is required by the claim. Value of Filesystem is implied when not included in claim spec. This is a beta feature.

Type

Required

string

No

spec.volumeName

​spec > volumeName

VolumeName is the binding reference to the PersistentVolume backing this claim.

Type

Required

string

No

Outputs

Module Outputs

The following keys are available via the ${modules.<module-name>} template string key for persistentvolumeclaim modules.

${modules.<module-name>.buildPath}

The build path of the module.

Type

string

Example:

my-variable: ${modules.my-module.buildPath}

${modules.<module-name>.path}

The local path of the module.

Type

string

Example:

my-variable: ${modules.my-module.path}

${modules.<module-name>.version}

The current version of the module.

Type

string

Example:

my-variable: ${modules.my-module.version}