forked from vllm-project/production-stack
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall-kubectl.sh
More file actions
39 lines (31 loc) · 933 Bytes
/
install-kubectl.sh
File metadata and controls
39 lines (31 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
set -e
KUBECTL_DIR="$HOME/.local/bin"
KUBECTL_PATH="$KUBECTL_DIR/kubectl"
kubectl_exists() {
command -v kubectl >/dev/null 2>&1
}
# If kubectl is already installed, exit
if kubectl_exists; then
echo "kubectl is already installed"
exit 0
fi
# Ensure the target directory exists
mkdir -p "$KUBECTL_DIR"
# Install kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
mv kubectl "$KUBECTL_PATH"
# Add to PATH if not already included
if ! echo "$PATH" | grep -q "$KUBECTL_DIR"; then
echo "export PATH=\"\$HOME/.local/bin:\$PATH\"" >> ~/.bashrc
echo "export PATH=\"$HOME/.local/bin:\$PATH\"" >> ~/.profile
export PATH="$HOME/.local/bin:$PATH"
fi
# Test the installation
if kubectl_exists; then
echo "kubectl installed successfully in $KUBECTL_PATH"
else
echo "kubectl installation failed"
exit 1
fi