mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +00:00
[Ubuntu] Improve kubectl installation script with retry logic and keyring checks (#12570)
* [Ubuntu] Fix kubectl error * [Ubuntu] Remove dependencies
This commit is contained in:
committed by
GitHub
parent
372fde29d0
commit
4423d3872f
@@ -20,8 +20,21 @@ use_checksum_comparison "${kind_binary_path}" "${kind_external_hash}"
|
|||||||
install "${kind_binary_path}" /usr/local/bin/kind
|
install "${kind_binary_path}" /usr/local/bin/kind
|
||||||
|
|
||||||
## Install kubectl
|
## Install kubectl
|
||||||
kubectl_minor_version=$(curl -fsSL "https://dl.k8s.io/release/stable.txt" | cut -d'.' -f1,2 )
|
|
||||||
curl -fsSL https://pkgs.k8s.io/core:/stable:/$kubectl_minor_version/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
|
# Ensure keyrings directory exists only if it doesn't already
|
||||||
|
[ -d /etc/apt/keyrings ] || sudo mkdir -p -m 755 /etc/apt/keyrings
|
||||||
|
|
||||||
|
kubectl_minor_version=$(curl -fsSL --retry 5 --retry-delay 10 "https://dl.k8s.io/release/stable.txt" | cut -d'.' -f1,2 )
|
||||||
|
|
||||||
|
# Download and validate GPG key
|
||||||
|
key_url="https://pkgs.k8s.io/core:/stable:/$kubectl_minor_version/deb/Release.key"
|
||||||
|
if curl -fsSL --retry 5 --retry-delay 10 -A "Mozilla/5.0" "$key_url" | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg; then
|
||||||
|
echo "Key downloaded and stored successfully."
|
||||||
|
else
|
||||||
|
echo "Failed to download valid GPG key from: $key_url"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/'$kubectl_minor_version'/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
|
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/'$kubectl_minor_version'/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install kubectl
|
apt-get install kubectl
|
||||||
|
|||||||
Reference in New Issue
Block a user