tests/k8s: add a kustomize installer

Kustomize has been used on some of our internal components (e.g.
kata-deploy) to manage k8s deployments. On CI it has been used
the `sed` tool to edit kustomization.yaml files, but `kustomize` is
more suitable for that purpose. So in order to use that tool on CI
scripts in the future, this commit introduces the `install_kustomize()`
function that is going to download and install the binary in
/usr/local/bin in case it's found on $PATH.

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
This commit is contained in:
Wainer dos Santos Moschetta 2024-02-08 16:51:49 -03:00
parent daab76de36
commit 6a28c94d99
2 changed files with 38 additions and 0 deletions

View File

@ -94,6 +94,33 @@ function install_kubectl() {
sudo az aks install-cli sudo az aks install-cli
} }
# Install the kustomize tool in /usr/local/bin if it doesn't exist on
# the system yet.
#
function install_kustomize() {
local arch
local checksum
local version
if command -v kustomize >/dev/null; then
return
fi
ensure_yq
version=$(get_from_kata_deps "externals.kustomize.version")
arch=$(arch_to_golang)
checksum=$(get_from_kata_deps "externals.kustomize.checksum.${arch}")
local tarball="kustomize_${version}_linux_${arch}.tar.gz"
curl -Lf -o "$tarball" "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/${version}/${tarball}"
local rc=0
echo "${checksum} $tarball" | sha256sum -c || rc=$?
[ $rc -eq 0 ] && sudo tar -xvzf "${tarball}" -C /usr/local/bin || rc=$?
rm -f "$tarball"
[ $rc -eq 0 ]
}
function get_cluster_credentials() { function get_cluster_credentials() {
test_type="${1:-k8s}" test_type="${1:-k8s}"

View File

@ -260,6 +260,17 @@ externals:
.*/v?([\d\.]+)\.tar\.gz .*/v?([\d\.]+)\.tar\.gz
version: "1.23.1-00" version: "1.23.1-00"
kustomize:
description: "Kubernetes native configuration management"
url: "https://github.com/kubernetes-sigs/kustomize"
version: "v5.3.0"
checksum:
amd64: "3ab32f92360d752a2a53e56be073b649abc1e7351b912c0fb32b960d1def854c"
arm64: "a1ec622d4adeb483e3cdabd70f0d66058b1e4bcec013c4f74f370666e1e045d8"
# yamllint disable-line rule:line-length
ppc64le: "946b1aa9325e7234157881fe2098e59c05c6834e56205bf6ec0a9a5fc83c9cc4"
s390x: "0b1a00f0e33efa2ecaa6cda9eeb63141ddccf97a912425974d6b65e66cf96cd4"
libseccomp: libseccomp:
description: "High level interface to Linux seccomp filter" description: "High level interface to Linux seccomp filter"
url: "https://github.com/seccomp/libseccomp" url: "https://github.com/seccomp/libseccomp"