Skip to content

Commit

Permalink
tool(kuztomize): support version 5.4.2 and use it by default (#6144)
Browse files Browse the repository at this point in the history
* chore(kustomize): rename constants

* tool(kustomize): add binaries for the latest version `5.4.2`

* chore: linting

* tool(kustomize): multi-version support (4 and 5)

* tool(kustomize): use version 5 by default

Version 4 is still available over an explicit configuration.

* tool(kustomize): include the latest `kustomize` binary version into Docker images

* docs: re-generate docs
  • Loading branch information
vvagaytsev authored Jun 5, 2024
1 parent 0778c75 commit 98a5504
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 17 deletions.
4 changes: 2 additions & 2 deletions core/src/plugins/kubernetes/kubernetes-type/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ async function readKustomizeManifests(
return []
}

const kustomizePath = spec.kustomize!.path
const kustomize = ctx.tools["kubernetes.kustomize"]
const kustomizePath = spec.kustomize.path
const kustomize = ctx.tools["kubernetes.kustomize-" + spec.kustomize.version]

const extraArgs = spec.kustomize.extraArgs || []

Expand Down
85 changes: 74 additions & 11 deletions core/src/plugins/kubernetes/kubernetes-type/kustomize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { PluginToolSpec } from "../../../plugin/tools.js"

export interface KubernetesKustomizeSpec {
path: string
version: number
extraArgs?: string[]
}

Expand All @@ -25,6 +26,7 @@ export const kustomizeSpecSchema = () =>
.description(
"The directory path where the desired kustomization.yaml is, or a git repository URL. This could be the path to an overlay directory, for example. If it's a path, must be a relative POSIX-style path and must be within the action root. Defaults to the action root. If you set this to null, kustomize will not be run."
),
version: joi.number().integer().valid(4, 5).default(5).description("The Kustomize version to use."),
extraArgs: joiSparseArray(joi.string()).description(
"A list of additional arguments to pass to the `kustomize build` command. Note that specifying '-o' or '--output' is not allowed."
),
Expand All @@ -33,19 +35,18 @@ export const kustomizeSpecSchema = () =>
"Resolve the specified kustomization and include the resulting resources. Note that if you specify `files` or `manifests` as well, these are also included."
)

export const kustomizeVersion = "4.5.7"
export const kustomize4Version = "4.5.7"

export const kustomizeSpec: PluginToolSpec = {
name: "kustomize",
version: kustomizeVersion,
description: `The kustomize config management CLI, v${kustomizeVersion}`,
export const kustomize4Spec: PluginToolSpec = {
name: "kustomize-4",
version: kustomize4Version,
description: `The kustomize config management CLI, v${kustomize4Version}`,
type: "binary",
_includeInGardenImage: true,
builds: [
{
platform: "darwin",
architecture: "amd64",
url: `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${kustomizeVersion}/kustomize_v${kustomizeVersion}_darwin_amd64.tar.gz`,
url: `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${kustomize4Version}/kustomize_v${kustomize4Version}_darwin_amd64.tar.gz`,
sha256: "6fd57e78ed0c06b5bdd82750c5dc6d0f992a7b926d114fe94be46d7a7e32b63a",
extract: {
format: "tar",
Expand All @@ -55,7 +56,7 @@ export const kustomizeSpec: PluginToolSpec = {
{
platform: "darwin",
architecture: "arm64",
url: `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${kustomizeVersion}/kustomize_v${kustomizeVersion}_darwin_arm64.tar.gz`,
url: `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${kustomize4Version}/kustomize_v${kustomize4Version}_darwin_arm64.tar.gz`,
sha256: "3c1e8b95cef4ff6e52d5f4b8c65b8d9d06b75f42d1cb40986c1d67729d82411a",
extract: {
format: "tar",
Expand All @@ -65,7 +66,7 @@ export const kustomizeSpec: PluginToolSpec = {
{
platform: "linux",
architecture: "amd64",
url: `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${kustomizeVersion}/kustomize_v${kustomizeVersion}_linux_amd64.tar.gz`,
url: `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${kustomize4Version}/kustomize_v${kustomize4Version}_linux_amd64.tar.gz`,
sha256: "701e3c4bfa14e4c520d481fdf7131f902531bfc002cb5062dcf31263a09c70c9",
extract: {
format: "tar",
Expand All @@ -75,7 +76,7 @@ export const kustomizeSpec: PluginToolSpec = {
{
platform: "linux",
architecture: "arm64",
url: `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${kustomizeVersion}/kustomize_v${kustomizeVersion}_linux_arm64.tar.gz`,
url: `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${kustomize4Version}/kustomize_v${kustomize4Version}_linux_arm64.tar.gz`,
sha256: "65665b39297cc73c13918f05bbe8450d17556f0acd16242a339271e14861df67",
extract: {
format: "tar",
Expand All @@ -85,7 +86,7 @@ export const kustomizeSpec: PluginToolSpec = {
{
platform: "windows",
architecture: "amd64",
url: `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${kustomizeVersion}/kustomize_v${kustomizeVersion}_windows_amd64.tar.gz`,
url: `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${kustomize4Version}/kustomize_v${kustomize4Version}_windows_amd64.tar.gz`,
sha256: "79af25f97bb10df999e540def94e876555696c5fe42d4c93647e28f83b1efc55",
extract: {
format: "tar",
Expand All @@ -94,3 +95,65 @@ export const kustomizeSpec: PluginToolSpec = {
},
],
}

export const kustomize5Version = "5.4.2"

export const kustomize5Spec: PluginToolSpec = {
name: "kustomize-5",
version: kustomize5Version,
description: `The kustomize config management CLI, v${kustomize5Version}`,
type: "binary",
_includeInGardenImage: true,
builds: [
{
platform: "darwin",
architecture: "amd64",
url: `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${kustomize5Version}/kustomize_v${kustomize5Version}_darwin_amd64.tar.gz`,
sha256: "d1dadf6d51058cdda6470344c95767e1c283cc5a36d5019eb32f8e43e63bd0df",
extract: {
format: "tar",
targetPath: "kustomize",
},
},
{
platform: "darwin",
architecture: "arm64",
url: `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${kustomize5Version}/kustomize_v${kustomize5Version}_darwin_arm64.tar.gz`,
sha256: "9b7da623cb40542f2dd220fa31d906d9254759b4e27583706e4e846fccba9fab",
extract: {
format: "tar",
targetPath: "kustomize",
},
},
{
platform: "linux",
architecture: "amd64",
url: `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${kustomize5Version}/kustomize_v${kustomize5Version}_linux_amd64.tar.gz`,
sha256: "881c6e9007c7ea2b9ecc214d13f4cdd1f837635dcf4db49ce4479898f7d911a3",
extract: {
format: "tar",
targetPath: "kustomize",
},
},
{
platform: "linux",
architecture: "arm64",
url: `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${kustomize5Version}/kustomize_v${kustomize5Version}_linux_arm64.tar.gz`,
sha256: "175af88af8a7d8d7d6b1f26659060950f0764d00b9979b4e11b61b8b212b7c22",
extract: {
format: "tar",
targetPath: "kustomize",
},
},
{
platform: "windows",
architecture: "amd64",
url: `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${kustomize5Version}/kustomize_v${kustomize5Version}_windows_amd64.zip`,
sha256: "56a91ef90f2f3a9625004a053d002e15039dfe3c6222113d97be9568511a6ae4",
extract: {
format: "zip",
targetPath: "kustomize.exe",
},
},
],
}
4 changes: 2 additions & 2 deletions core/src/plugins/kubernetes/kubernetes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
import { getHelmDeployDocs, helmDeployDefinition } from "./helm/action.js"
import { jibContainerHandlers, k8sJibContainerBuildExtension } from "./jib-container.js"
import { kubernetesDeployDefinition, kubernetesDeployDocs } from "./kubernetes-type/deploy.js"
import { kustomizeSpec } from "./kubernetes-type/kustomize.js"
import { kustomize4Spec, kustomize5Spec } from "./kubernetes-type/kustomize.js"
import { syncPause, syncResume, syncStatus } from "./commands/sync.js"
import { helmPodRunDefinition, helmPodTestDefinition } from "./helm/helm-pod.js"
import { kubernetesPodRunDefinition, kubernetesPodTestDefinition } from "./kubernetes-type/kubernetes-pod.js"
Expand Down Expand Up @@ -221,6 +221,6 @@ export const gardenPlugin = () => {
needsBuild: true,
},
],
tools: [kubectlSpec, kustomizeSpec, helm3Spec, mutagenCliSpec],
tools: [kubectlSpec, kustomize4Spec, kustomize5Spec, helm3Spec, mutagenCliSpec],
})
}
10 changes: 8 additions & 2 deletions core/test/unit/src/verify-ext-tool-binary-hashes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { mutagenCliSpecLegacy, mutagenCliSpecNative, mutagenFauxSshSpec } from "../../../src/mutagen.js"
import { kubectlSpec } from "../../../src/plugins/kubernetes/kubectl.js"
import { kustomizeSpec } from "../../../src/plugins/kubernetes/kubernetes-type/kustomize.js"
import { kustomize4Spec, kustomize5Spec } from "../../../src/plugins/kubernetes/kubernetes-type/kustomize.js"
import { helm3Spec } from "../../../src/plugins/kubernetes/helm/helm-cli.js"
import { downloadBinariesAndVerifyHashes } from "../../../src/util/testing.js"
import { dockerSpec, namespaceCliSpec } from "../../../src/plugins/container/container.js"
Expand All @@ -34,7 +34,13 @@ describe("Kubectl binaries", () => {
})

describe("Kustomize binaries", () => {
downloadBinariesAndVerifyHashes([kustomizeSpec])
describe("Version 4", () => {
downloadBinariesAndVerifyHashes([kustomize4Spec])
})

describe("Version 5", () => {
downloadBinariesAndVerifyHashes([kustomize5Spec])
})
})

describe("Helm binaries", () => {
Expand Down
10 changes: 10 additions & 0 deletions docs/reference/action-types/Deploy/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,16 @@ The directory path where the desired kustomization.yaml is, or a git repository
| --------------------- | ------- | -------- |
| `posixPath \| string` | `"."` | No |

### `spec.kustomize.version`

[spec](#spec) > [kustomize](#speckustomize) > version

The Kustomize version to use.

| Type | Allowed Values | Default | Required |
| -------- | -------------- | ------- | -------- |
| `number` | 4, 5 | `5` | Yes |

### `spec.kustomize.extraArgs[]`

[spec](#spec) > [kustomize](#speckustomize) > extraArgs
Expand Down
10 changes: 10 additions & 0 deletions docs/reference/action-types/Run/kubernetes-pod.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,16 @@ The directory path where the desired kustomization.yaml is, or a git repository
| --------------------- | ------- | -------- |
| `posixPath \| string` | `"."` | No |

### `spec.kustomize.version`

[spec](#spec) > [kustomize](#speckustomize) > version

The Kustomize version to use.

| Type | Allowed Values | Default | Required |
| -------- | -------------- | ------- | -------- |
| `number` | 4, 5 | `5` | Yes |

### `spec.kustomize.extraArgs[]`

[spec](#spec) > [kustomize](#speckustomize) > extraArgs
Expand Down
10 changes: 10 additions & 0 deletions docs/reference/action-types/Test/kubernetes-pod.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,16 @@ The directory path where the desired kustomization.yaml is, or a git repository
| --------------------- | ------- | -------- |
| `posixPath \| string` | `"."` | No |

### `spec.kustomize.version`

[spec](#spec) > [kustomize](#speckustomize) > version

The Kustomize version to use.

| Type | Allowed Values | Default | Required |
| -------- | -------------- | ------- | -------- |
| `number` | 4, 5 | `5` | Yes |

### `spec.kustomize.extraArgs[]`

[spec](#spec) > [kustomize](#speckustomize) > extraArgs
Expand Down
13 changes: 13 additions & 0 deletions docs/reference/module-types/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ kustomize:
# root. Defaults to the action root. If you set this to null, kustomize will not be run.
path: .

# The Kustomize version to use.
version: 5

# A list of additional arguments to pass to the `kustomize build` command. Note that specifying '-o' or '--output'
# is not allowed.
extraArgs: []
Expand Down Expand Up @@ -946,6 +949,16 @@ The directory path where the desired kustomization.yaml is, or a git repository
| --------------------- | ------- | -------- |
| `posixPath \| string` | `"."` | No |

### `kustomize.version`

[kustomize](#kustomize) > version

The Kustomize version to use.

| Type | Allowed Values | Default | Required |
| -------- | -------------- | ------- | -------- |
| `number` | 4, 5 | `5` | Yes |

### `kustomize.extraArgs[]`

[kustomize](#kustomize) > extraArgs
Expand Down

0 comments on commit 98a5504

Please sign in to comment.