Skip to content

Commit

Permalink
fix(k8s): allow user to configure own storageClass for build-sync volume
Browse files Browse the repository at this point in the history
Previously, the `storage.sync.storageClass` parameter was silently
ignored. We now respect the parameter, and skip installing the NFS
provisioner if a storageClass is specified for the volume.

Fixes #1120
  • Loading branch information
edvald committed Aug 24, 2019
1 parent d2f5c8b commit fc0037f
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 12 deletions.
10 changes: 7 additions & 3 deletions docs/reference/providers/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ Only applies when `buildMode` is set to `cluster-docker`, ignored otherwise.

[providers](#providers) > [storage](#providers[].storage) > [builder](#providers[].storage.builder) > size

Volume size for the registry in megabytes.
Volume size in megabytes.

| Type | Required | Default |
| -------- | -------- | ------- |
Expand Down Expand Up @@ -572,7 +572,7 @@ Only applies when `buildMode` is set to `cluster-docker` or `kaniko`, ignored ot

[providers](#providers) > [storage](#providers[].storage) > [registry](#providers[].storage.registry) > size

Volume size for the registry in megabytes.
Volume size in megabytes.

| Type | Required | Default |
| -------- | -------- | ------- |
Expand All @@ -595,6 +595,10 @@ Storage class to use for the volume.
Storage parameters for the code sync volume, which build contexts are synced to ahead of running
in-cluster builds.

Important: The storage class configured here has to support _ReadWriteMany_ access.
If you don't specify a storage class, Garden creates an NFS provisioner and provisions an ephemeral
NFS volume for the sync data volume.

Only applies when `buildMode` is set to `cluster-docker` or `kaniko`, ignored otherwise.

| Type | Required | Default |
Expand All @@ -605,7 +609,7 @@ Only applies when `buildMode` is set to `cluster-docker` or `kaniko`, ignored ot

[providers](#providers) > [storage](#providers[].storage) > [sync](#providers[].storage.sync) > size

Volume size for the registry in megabytes.
Volume size in megabytes.

| Type | Required | Default |
| -------- | -------- | ------- |
Expand Down
10 changes: 7 additions & 3 deletions docs/reference/providers/local-kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ Only applies when `buildMode` is set to `cluster-docker`, ignored otherwise.

[providers](#providers) > [storage](#providers[].storage) > [builder](#providers[].storage.builder) > size

Volume size for the registry in megabytes.
Volume size in megabytes.

| Type | Required | Default |
| -------- | -------- | ------- |
Expand Down Expand Up @@ -572,7 +572,7 @@ Only applies when `buildMode` is set to `cluster-docker` or `kaniko`, ignored ot

[providers](#providers) > [storage](#providers[].storage) > [registry](#providers[].storage.registry) > size

Volume size for the registry in megabytes.
Volume size in megabytes.

| Type | Required | Default |
| -------- | -------- | ------- |
Expand All @@ -595,6 +595,10 @@ Storage class to use for the volume.
Storage parameters for the code sync volume, which build contexts are synced to ahead of running
in-cluster builds.

Important: The storage class configured here has to support _ReadWriteMany_ access.
If you don't specify a storage class, Garden creates an NFS provisioner and provisions an ephemeral
NFS volume for the sync data volume.

Only applies when `buildMode` is set to `cluster-docker` or `kaniko`, ignored otherwise.

| Type | Required | Default |
Expand All @@ -605,7 +609,7 @@ Only applies when `buildMode` is set to `cluster-docker` or `kaniko`, ignored ot

[providers](#providers) > [storage](#providers[].storage) > [sync](#providers[].storage.sync) > size

Volume size for the registry in megabytes.
Volume size in megabytes.

| Type | Required | Default |
| -------- | -------- | ------- |
Expand Down
6 changes: 5 additions & 1 deletion garden-service/src/plugins/kubernetes/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const storageSchema = (defaults: KubernetesStorageSpec) => joi.object()
size: joi.number()
.integer()
.default(defaults.size)
.description("Volume size for the registry in megabytes."),
.description("Volume size in megabytes."),
storageClass: joi.string()
.allow(null)
.default(null)
Expand Down Expand Up @@ -308,6 +308,10 @@ export const kubernetesConfigBase = providerConfigBaseSchema
Storage parameters for the code sync volume, which build contexts are synced to ahead of running
in-cluster builds.
Important: The storage class configured here has to support _ReadWriteMany_ access.
If you don't specify a storage class, Garden creates an NFS provisioner and provisions an ephemeral
NFS volume for the sync data volume.
Only applies when \`buildMode\` is set to \`cluster-docker\` or \`kaniko\`, ignored otherwise.
`),
})
Expand Down
4 changes: 3 additions & 1 deletion garden-service/src/plugins/kubernetes/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import chalk from "chalk"
import { deline } from "../../util/string"
import { combineStates, ServiceStatusMap } from "../../types/service"

const nfsStorageClass = "garden-system-nfs"

/**
* Performs the following actions to check environment status:
* 1. Checks Tiller status in the project namespace
Expand Down Expand Up @@ -254,7 +256,7 @@ export function getKubernetesSystemVariables(config: KubernetesConfig) {
"sync-requests-cpu": millicpuToString(config.resources.sync.requests.cpu),
"sync-requests-memory": megabytesToString(config.resources.sync.requests.memory),
"sync-storage-size": megabytesToString(config.storage.sync.size),
"sync-storage-class": config.storage.sync.storageClass,
"sync-storage-class": config.storage.sync.storageClass || nfsStorageClass,
}
}

Expand Down
7 changes: 6 additions & 1 deletion garden-service/src/plugins/kubernetes/kubernetes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,17 @@ export async function configureProvider({ projectName, config }: ConfigureProvid
}

// Deploy build services on init
config._systemServices.push("build-sync", "docker-registry", "registry-proxy", "nfs-provisioner")
config._systemServices.push("build-sync", "docker-registry", "registry-proxy")

if (config.buildMode === "cluster-docker") {
config._systemServices.push("docker-daemon")
}

// Set up an NFS provisioner if the user doesn't explicitly set a storage class for the shared sync volume
if (!config.storage.sync.storageClass) {
config._systemServices.push("nfs-provisioner")
}

} else if (config.name !== "local-kubernetes" && !config.deploymentRegistry) {
throw new ConfigurationError(
`kubernetes: must specify deploymentRegistry in config if using local build mode`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ values:
memory: ${var.sync-requests-memory}
storage:
request: ${var.sync-storage-size}
storageClass: garden-system-nfs
storageClass: ${var.sync-storage-class}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ values:
nameOverride: garden-nfs-provisioner
fullnameOverride: garden-nfs-provisioner
persistence:
enable: true
size: 50Gi
enabled: false
storageClass:
name: garden-system-nfs

0 comments on commit fc0037f

Please sign in to comment.