diff --git a/Dockerfile b/Dockerfile index 67d932d..0a6a76b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -70,6 +70,14 @@ RUN mkdir /tmp/terraform_env/ && \ cp terraform /usr/local/bin/ && \ rm terraform_${TERRAFORM_VERSION}_linux_amd64.zip +# Install Kubectl +ARG KUBECTL_VERSION=1.29.2 +RUN mkdir /tmp/kubectl_env/ && \ + cd /tmp/kubectl_env/ && \ + curl -LO "https://dl.k8s.io/release/v$KUBECTL_VERSION/bin/linux/amd64/kubectl" && \ + chmod +x kubectl && \ + mv ./kubectl /usr/local/bin/kubectl + # Cleanup RUN apt-get clean && \ rm -rf /var/lib/apt/lists/* diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md index 2be2b9a..fe89153 100644 --- a/docs/TROUBLESHOOTING.md +++ b/docs/TROUBLESHOOTING.md @@ -1 +1,6 @@ - https://stackoverflow.com/questions/62154016/docker-on-wsl2-very-slow + +- exec /usr/local/bin/kubectl: exec format error +See: https://stackoverflow.com/questions/73398714/docker-fails-when-building-on-m1-macs-exec-usr-local-bin-docker-entrypoint-sh + +- Check architecure: dpkg --print-architecture diff --git a/scripts/check_version_in_toolkit.sh b/scripts/check_version_in_toolkit.sh index a288a85..16642e3 100644 --- a/scripts/check_version_in_toolkit.sh +++ b/scripts/check_version_in_toolkit.sh @@ -7,6 +7,7 @@ declare -A tools=( [python3]="3.11.3" [ansible]="2.16.4" [terraform]="1.7.4" + [kubectl]="1.29.2" # Add more tools as needed ) @@ -15,11 +16,26 @@ check_tool_version() { local tool_name=$1 local expected_version=$2 echo "[$tool_name] Checking version..." - # Get the installed version - installed_version=$(docker run --rm $image_name $tool_name --version) - echo "$installed_version" + + # Possible version option flags for different tools + local version_flags=( + "--version" + "version" + ) + + installed_version="" + + # Iterate through possible version flags + for flag in "${version_flags[@]}"; do + installed_version=$(docker run --rm "$image_name" "$tool_name" "$flag" 2>&1) + # Check if the version information is in the output + if echo "$installed_version" | grep -q "$expected_version"; then + break + fi + done + # Compare the installed version with the expected version - if [[ "$installed_version" == *"$expected_version"* ]]; then + if echo "$installed_version" | grep -q "$expected_version"; then echo "[OK] $tool_name version is correct: $installed_version" else echo "[Error] Incorrect $tool_name version. Expected $expected_version but found $installed_version"