Skip to content

Commit d79c223

Browse files
abdurriqCopilot
andauthored
Fix kubectl-helm-minikube installation failures on debian:11 and ubuntu:focal (#1578)
* Fix kubectl-helm-minikube installation failures on debian:11 and ubuntu:focal (#1567) * Initial plan * Fix kubectl SHA256 download URL and bump version to 1.3.1 Co-authored-by: abdurriq <[email protected]> * Add timeout and fallback for kubectl version fetching Co-authored-by: abdurriq <[email protected]> * Improve error messages and diagnostics for kubectl version fetching Co-authored-by: abdurriq <[email protected]> * Address code review feedback: clean up error handling Co-authored-by: abdurriq <[email protected]> * Improve error message to reference VERSION option Co-authored-by: abdurriq <[email protected]> * Use hardcoded fallback version instead of git tags fallback Co-authored-by: abdurriq <[email protected]> * Add version validation and comment for fallback version Co-authored-by: abdurriq <[email protected]> * Extract fallback version to constant at top of file Co-authored-by: abdurriq <[email protected]> * Update fallback version of kubectl to v1.35.1 * Add alternative URL fallback before using hardcoded version Co-authored-by: abdurriq <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: abdurriq <[email protected]> Co-authored-by: Abdurrahmaan Iqbal <[email protected]> * Fix kubectl SHA256 URL in install script * Use configurable fallback kubectl version instead of just hardcoded one --------- Co-authored-by: Copilot <[email protected]>
1 parent 06d3f56 commit d79c223

2 files changed

Lines changed: 74 additions & 58 deletions

File tree

Lines changed: 62 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,66 @@
11
{
2-
"id": "kubectl-helm-minikube",
3-
"version": "1.2.2",
4-
"name": "Kubectl, Helm, and Minikube",
5-
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/kubectl-helm-minikube",
6-
"description": "Installs latest version of kubectl, Helm, and optionally minikube. Auto-detects latest versions and installs needed dependencies.",
7-
"options": {
8-
"version": {
9-
"type": "string",
10-
"proposals": [
11-
"latest",
12-
"none",
13-
"1.23",
14-
"1.22",
15-
"1.21",
16-
"none"
17-
],
18-
"default": "latest",
19-
"description": "Select or enter a Kubernetes version to install"
20-
},
21-
"helm": {
22-
"type": "string",
23-
"proposals": [
24-
"latest",
25-
"none"
26-
],
27-
"default": "latest",
28-
"description": "Select or enter a Helm version to install"
29-
},
30-
"minikube": {
31-
"type": "string",
32-
"proposals": [
33-
"latest",
34-
"none"
35-
],
36-
"default": "latest",
37-
"description": "Select or enter a Minikube version to install"
38-
}
2+
"id": "kubectl-helm-minikube",
3+
"version": "1.3.1",
4+
"name": "Kubectl, Helm, and Minikube",
5+
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/kubectl-helm-minikube",
6+
"description": "Installs latest version of kubectl, Helm, and optionally minikube. Auto-detects latest versions and installs needed dependencies.",
7+
"options": {
8+
"version": {
9+
"type": "string",
10+
"proposals": [
11+
"latest",
12+
"none",
13+
"1.23",
14+
"1.22",
15+
"1.21",
16+
"none"
17+
],
18+
"default": "latest",
19+
"description": "Select or enter a Kubernetes version to install"
3920
},
40-
"mounts": [
41-
{
42-
"source": "minikube-config",
43-
"target": "/home/vscode/.minikube",
44-
"type": "volume"
45-
}
46-
],
47-
"customizations": {
48-
"vscode": {
49-
"settings": {
50-
"github.copilot.chat.codeGeneration.instructions": [
51-
{
52-
"text": "This dev container includes kubectl, Helm, optionally minikube, and needed dependencies pre-installed and available on the `PATH`. When configuring Ingress for your Kubernetes cluster, note that by default Kubernetes will bind to a specific interface's IP rather than localhost or all interfaces. This is why you need to use the Kubernetes Node's IP when connecting - even if there's only one Node as in the case of Minikube."
53-
}
54-
]
55-
}
56-
}
21+
"helm": {
22+
"type": "string",
23+
"proposals": [
24+
"latest",
25+
"none"
26+
],
27+
"default": "latest",
28+
"description": "Select or enter a Helm version to install"
5729
},
58-
"installsAfter": [
59-
"ghcr.io/devcontainers/features/common-utils"
60-
]
30+
"minikube": {
31+
"type": "string",
32+
"proposals": [
33+
"latest",
34+
"none"
35+
],
36+
"default": "latest",
37+
"description": "Select or enter a Minikube version to install"
38+
},
39+
"kubectlFallbackVersion": {
40+
"type": "string",
41+
"default": "v1.35.1",
42+
"description": "Fallback kubectl version to use when the latest stable version cannot be fetched"
43+
}
44+
},
45+
"mounts": [
46+
{
47+
"source": "minikube-config",
48+
"target": "/home/vscode/.minikube",
49+
"type": "volume"
50+
}
51+
],
52+
"customizations": {
53+
"vscode": {
54+
"settings": {
55+
"github.copilot.chat.codeGeneration.instructions": [
56+
{
57+
"text": "This dev container includes kubectl, Helm, optionally minikube, and needed dependencies pre-installed and available on the `PATH`. When configuring Ingress for your Kubernetes cluster, note that by default Kubernetes will bind to a specific interface's IP rather than localhost or all interfaces. This is why you need to use the Kubernetes Node's IP when connecting - even if there's only one Node as in the case of Minikube."
58+
}
59+
]
60+
}
61+
}
62+
},
63+
"installsAfter": [
64+
"ghcr.io/devcontainers/features/common-utils"
65+
]
6166
}

src/kubectl-helm-minikube/install.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ set -e
1212
# Clean up
1313
rm -rf /var/lib/apt/lists/*
1414

15+
# Fallback version when stable.txt cannot be fetched
16+
KUBECTL_FALLBACK_VERSION="${KUBECTLFALLBACKVERSION:-"v1.35.1"}"
17+
1518
KUBECTL_VERSION="${VERSION:-"latest"}"
1619
HELM_VERSION="${HELM:-"latest"}"
1720
MINIKUBE_VERSION="${MINIKUBE:-"latest"}" # latest is also valid
@@ -164,7 +167,15 @@ if [ ${KUBECTL_VERSION} != "none" ]; then
164167
# Install the kubectl, verify checksum
165168
echo "Downloading kubectl..."
166169
if [ "${KUBECTL_VERSION}" = "latest" ] || [ "${KUBECTL_VERSION}" = "lts" ] || [ "${KUBECTL_VERSION}" = "current" ] || [ "${KUBECTL_VERSION}" = "stable" ]; then
167-
KUBECTL_VERSION="$(curl -sSL https://dl.k8s.io/release/stable.txt)"
170+
KUBECTL_VERSION="$(curl -fsSL --connect-timeout 10 --max-time 30 https://dl.k8s.io/release/stable.txt 2>/dev/null | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' || echo "")"
171+
if [ -z "${KUBECTL_VERSION}" ]; then
172+
echo "(!) Failed to fetch kubectl stable version from dl.k8s.io, trying alternative URL..."
173+
KUBECTL_VERSION="$(curl -fsSL --connect-timeout 10 --max-time 30 https://storage.googleapis.com/kubernetes-release/release/stable.txt 2>/dev/null | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' || echo "")"
174+
fi
175+
if [ -z "${KUBECTL_VERSION}" ]; then
176+
echo "(!) Failed to fetch kubectl stable version from both URLs. Using fallback version ${KUBECTL_FALLBACK_VERSION}"
177+
KUBECTL_VERSION="${KUBECTL_FALLBACK_VERSION}"
178+
fi
168179
else
169180
find_version_from_git_tags KUBECTL_VERSION https://github.com/kubernetes/kubernetes
170181
fi

0 commit comments

Comments
 (0)