diff --git a/core/src/plugins/kubernetes/kubectl.ts b/core/src/plugins/kubernetes/kubectl.ts index 968444db1b..6018328674 100644 --- a/core/src/plugins/kubernetes/kubectl.ts +++ b/core/src/plugins/kubernetes/kubectl.ts @@ -63,6 +63,7 @@ export interface ApplyParams { pruneLabels?: { [label: string]: string } validate?: boolean retryOpts?: RetryOpts + applyArgs?: string[] } export const KUBECTL_DEFAULT_TIMEOUT = 300 @@ -77,6 +78,7 @@ export async function apply({ namespace, pruneLabels, validate = true, + applyArgs, }: ApplyParams) { // Hash the raw input and add as an annotation on each manifest (this is helpful beyond kubectl's own annotation, // because kubectl applies some normalization/transformation that is sometimes difficult to reason about). @@ -122,6 +124,7 @@ export async function apply({ dryRun && args.push("--dry-run") args.push("--output=json", "-f", "-") !validate && args.push("--validate=false") + applyArgs && args.push(...applyArgs) let result: string try { diff --git a/core/src/plugins/kubernetes/kubernetes-type/config.ts b/core/src/plugins/kubernetes/kubernetes-type/config.ts index cd33f42d8f..12c9cb8705 100644 --- a/core/src/plugins/kubernetes/kubernetes-type/config.ts +++ b/core/src/plugins/kubernetes/kubernetes-type/config.ts @@ -114,6 +114,9 @@ export const kubernetesPatchResourcesSchema = () => ` ) +export const kubernetesApplyArgsSchema = () => + joi.array().items(joi.string()).description("Additional arguments to pass to `kubectl apply`.") + export const kubernetesCommonDeploySpecKeys = () => ({ files: kubernetesFilesSchema(), kustomize: kustomizeSpecSchema(), @@ -122,6 +125,7 @@ export const kubernetesCommonDeploySpecKeys = () => ({ namespace: namespaceNameSchema(), portForwards: portForwardsSchema(), timeout: k8sDeploymentTimeoutSchema(), + applyArgs: kubernetesApplyArgsSchema(), // TODO-0.14: flip this to true and change default behavior to // wait for the jobs waitForJobs: joi diff --git a/docs/reference/action-types/Deploy/kubernetes.md b/docs/reference/action-types/Deploy/kubernetes.md index e9c21e2efa..38b8bf79a2 100644 --- a/docs/reference/action-types/Deploy/kubernetes.md +++ b/docs/reference/action-types/Deploy/kubernetes.md @@ -498,6 +498,16 @@ The maximum duration (in seconds) to wait for resources to deploy and become hea | -------- | ------- | -------- | | `number` | `300` | No | +### `spec.applyArgs[]` + +[spec](#spec) > applyArgs + +Additional arguments to pass to `kubectl apply`. + +| Type | Required | +| --------------- | -------- | +| `array[string]` | No | + ### `spec.waitForJobs` [spec](#spec) > waitForJobs diff --git a/docs/reference/module-types/kubernetes.md b/docs/reference/module-types/kubernetes.md index 3c7ae21ae6..2a2861ddc0 100644 --- a/docs/reference/module-types/kubernetes.md +++ b/docs/reference/module-types/kubernetes.md @@ -258,6 +258,9 @@ portForwards: # The maximum duration (in seconds) to wait for resources to deploy and become healthy. timeout: 300 +# Additional arguments to pass to `kubectl apply`. +applyArgs: + # Wait until the jobs have been completed. Garden will wait for as long as `timeout`. waitForJobs: false @@ -1122,6 +1125,14 @@ The maximum duration (in seconds) to wait for resources to deploy and become hea | -------- | ------- | -------- | | `number` | `300` | No | +### `applyArgs[]` + +Additional arguments to pass to `kubectl apply`. + +| Type | Required | +| --------------- | -------- | +| `array[string]` | No | + ### `waitForJobs` Wait until the jobs have been completed. Garden will wait for as long as `timeout`.