generated from devcontainers/feature-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
328f265
commit 3c226b9
Showing
7 changed files
with
185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"name": "Kubernetes Tools", | ||
"id": "kubernetes-tools", | ||
"version": "0.1.0", | ||
"description": "A feature to install K8s tools.", | ||
"options": { | ||
"kubectl-version": { | ||
"type": "string", | ||
"default": "latest", | ||
"description": "The version of kubectl to install, in format of 'v*'." | ||
}, | ||
"install-krew": { | ||
"type": "string", | ||
"proposals": [ | ||
"latest", | ||
"none" | ||
], | ||
"default": "none", | ||
"description": "Whether to install Krew. Use 'latest' to install the latest version. Use 'none' to skip installation." | ||
}, | ||
"install-k9s": { | ||
"type": "string", | ||
"proposals": [ | ||
"latest", | ||
"none" | ||
], | ||
"default": "none", | ||
"description": "Whether to install k9s. Use 'latest' to install the latest version. Use 'none' to skip installation." | ||
}, | ||
"install-helm": { | ||
"type": "string", | ||
"proposals": [ | ||
"latest", | ||
"none" | ||
], | ||
"default": "none", | ||
"description": "Whether to install Helm. Use 'latest' to install the latest version. Use 'none' to skip installation." | ||
} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-kubernetes-tools.vscode-kubernetes-tools", | ||
"Tim-Koehler.helm-intellisense" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
ARCH=$(dpkg --print-architecture) | ||
|
||
if ! command -v curl || ! command -v git; then | ||
echo "Installing curl, and git" | ||
apt-get update && apt-get install -y curl git | ||
fi | ||
|
||
# kubectl | ||
# ---------------------------------------------------------------------------- | ||
echo "Installing kubectl" | ||
|
||
if [ "$KUBECTL_VERSION" = "latest" ]; then | ||
KUBECTL_VERSION="$(curl -L -s https://dl.k8s.io/release/stable.txt)" | ||
fi | ||
|
||
curl -L --output /usr/bin/kubectl "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/${ARCH}/kubectl" && | ||
chmod +x /usr/bin/kubectl | ||
|
||
# Krew | ||
# ---------------------------------------------------------------------------- | ||
if [ "$INSTALL_KREW" != "none" ]; then | ||
if [ "$INSTALL_KREW" = "latest" ]; then | ||
krew_dl_url="$( | ||
curl -s https://api.github.com/repos/kubernetes-sigs/krew/releases/latest | | ||
grep -Eo -m 1 "https://.+krew-linux_${ARCH}\.tar\.gz" | ||
)" | ||
else | ||
krew_dl_url="https://github.com/kubernetes-sigs/krew/releases/download/${INSTALL_KREW}/krew-linux_${ARCH}.tar.gz" | ||
fi | ||
|
||
echo "Installing Krew from $krew_dl_url" | ||
( | ||
set -x | ||
cd "$(mktemp -d)" && | ||
KREW="krew-linux_${ARCH}" && | ||
curl -fsSLO "$krew_dl_url" && | ||
tar zxvf "${KREW}.tar.gz" && | ||
mv ./"${KREW}" /usr/local/bin/krew | ||
) | ||
fi | ||
|
||
# K9s | ||
# ---------------------------------------------------------------------------- | ||
if [ "$INSTALL_K9S" != "none" ]; then | ||
if [ "$INSTALL_K9S" = "latest" ]; then | ||
k9s_dl_url="$( | ||
curl -s https://api.github.com/repos/derailed/k9s/releases/latest | | ||
grep -Eo -m 1 "https://.+k9s_linux_${ARCH}\.deb" | ||
)" | ||
else | ||
k9s_dl_url="https://github.com/derailed/k9s/releases/download/${INSTALL_K9S}/k9s_linux_${ARCH}.deb" | ||
fi | ||
|
||
echo "Downloading K9s from $k9s_dl_url" | ||
curl -L --output /tmp/k9s.deb "$k9s_dl_url" && | ||
dpkg --install /tmp/k9s.deb && | ||
rm -f /tmp/k9s.deb | ||
fi | ||
|
||
# Helm | ||
# ---------------------------------------------------------------------------- | ||
if [ "$INSTALL_HELM" != "none" ]; then | ||
helm_version=$([ "$INSTALL_HELM" = "latest" ] && echo '' || echo "$INSTALL_HELM") | ||
|
||
echo "Installing Helm $helm_version" | ||
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | | ||
DESIRED_VERSION="$helm_version" bash | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# shellcheck source=/dev/null | ||
source dev-container-features-test-lib | ||
|
||
check "verify kubectl installation" kubectl version --client | grep -E 'Client Version: v.+' | ||
check "verify Krew installation" krew version | grep -E 'GitTag\s+v.+' | ||
check "verify k9s installation" k9s version --short | grep -E 'Version\s+v.+' | ||
check "verify Helm installation" helm version --short | grep -E 'v.+' | ||
|
||
reportResults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"full": { | ||
"image": "mcr.microsoft.com/devcontainers/base:bookworm", | ||
"features": { | ||
"kubernetes-tools": { | ||
"kubectl-version": "latest", | ||
"install-krew": "latest", | ||
"install-k9s": "latest", | ||
"install-helm": "latest" | ||
} | ||
} | ||
}, | ||
"specific-version": { | ||
"image": "mcr.microsoft.com/devcontainers/base:bookworm", | ||
"features": { | ||
"kubernetes-tools": { | ||
"kubectl-version": "v1.31.1", | ||
"install-krew": "v0.4.3", | ||
"install-k9s": "v0.32.4", | ||
"install-helm": "v3.16.2" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# shellcheck source=/dev/null | ||
source dev-container-features-test-lib | ||
|
||
check "verify kubectl installation" kubectl version --client | grep 'Client Version: v1.31.1' | ||
check "verify Krew installation" krew version | grep -E 'GitTag\s+v0\.4\.3' | ||
check "verify k9s installation" k9s version --short | grep -E 'Version\s+v0\.32\.4' | ||
check "verify Helm installation" helm version --short | grep 'v3.16.2' | ||
|
||
reportResults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# shellcheck source=/dev/null | ||
source dev-container-features-test-lib | ||
|
||
check "verify kubectl installation" kubectl version --client | grep -E 'Client Version: v.+' | ||
check "do not install Krew" command krew 2>&1 | grep 'krew: command not found' | ||
check "do not install k9s" command k9s 2>&1 | grep 'k9s: command not found' | ||
check "do not install Helm" command helm 2>&1 | grep 'helm: command not found' | ||
|
||
reportResults |