diff --git a/.github/workflows/test_chart.yaml b/.github/workflows/test_chart.yaml index 4b6dc7593..97ec9b999 100644 --- a/.github/workflows/test_chart.yaml +++ b/.github/workflows/test_chart.yaml @@ -59,7 +59,7 @@ jobs: uses: helm/kind-action@v1.9.0 with: cluster_name: kind - node_image: kindest/node:v1.30.0 + node_image: kindest/node:v1.30.4 - name: Add local docker image run: kind load docker-image ${{ env.MANIFEST_IMG }}:${{ env.TAG }} diff --git a/hack/ensure-kubectl.sh b/hack/ensure-kubectl.sh index 04e8c5f89..5a73940ca 100755 --- a/hack/ensure-kubectl.sh +++ b/hack/ensure-kubectl.sh @@ -26,20 +26,26 @@ fi source "$(dirname "${BASH_SOURCE[0]}")/utils.sh" GOPATH_BIN="$(go env GOPATH)/bin/" -MINIMUM_KUBECTL_VERSION=v1.30.0 +MINIMUM_KUBECTL_VERSION=v1.30.4 goarch="$(go env GOARCH)" goos="$(go env GOOS)" # Ensure the kubectl tool exists and is a viable version, or installs it verify_kubectl_version() { + local kubectl_version + IFS=" " read -ra kubectl_version <<< "$(kubectl version --client || echo 'v0.0.0')" + # If kubectl is not available on the path, get it - if ! [ -x "$(command -v kubectl)" ]; then + if ! [ -x "$(command -v kubectl)" ] || [[ "${MINIMUM_KUBECTL_VERSION}" != $(echo -e "${MINIMUM_KUBECTL_VERSION}\n${kubectl_version[2]}" | sort -s -t. -k 1,1 -k 2,2n -k 3,3n | head -n1) ]]; then if [ "$goos" == "linux" ] || [ "$goos" == "darwin" ]; then if ! [ -d "${GOPATH_BIN}" ]; then mkdir -p "${GOPATH_BIN}" fi - echo 'kubectl not found, installing' + + echo "kubectl not found or below ${MINIMUM_KUBECTL_VERSION}, installing" + echo "Updating to ${MINIMUM_KUBECTL_VERSION}." + curl -sLo "${GOPATH_BIN}/kubectl" "https://dl.k8s.io/release/${MINIMUM_KUBECTL_VERSION}/bin/${goos}/${goarch}/kubectl" chmod +x "${GOPATH_BIN}/kubectl" verify_gopath_bin @@ -48,17 +54,6 @@ verify_kubectl_version() { return 2 fi fi - - local kubectl_version - IFS=" " read -ra kubectl_version <<< "$(kubectl version --client)" - if [[ "${MINIMUM_KUBECTL_VERSION}" != $(echo -e "${MINIMUM_KUBECTL_VERSION}\n${kubectl_version[2]}" | sort -s -t. -k 1,1 -k 2,2n -k 3,3n | head -n1) ]]; then - cat <