-
Notifications
You must be signed in to change notification settings - Fork 3.5k
kind-cluster/install.sh: add macOS support for Kind binary download (Intel and ARM) #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…x86_64 and arm64)
WalkthroughIntroduces OS- and architecture-aware branching in kind-cluster/install.sh to download the correct Kind binary for Linux (amd64/arm64) and macOS (amd64/arm64). Unsupported OS/ARCH combinations now exit with an error. Post-download steps (chmod, move to /usr/local/bin, success messages) remain. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant S as install.sh
participant OS as OS/ARCH Detector
participant GH as GitHub Kind Releases
participant BIN as /usr/local/bin
U->>S: Run install.sh
S->>OS: Detect uname -s / uname -m
OS-->>S: OS, ARCH
alt Supported combo
S->>GH: Download kind-{os}-{arch}
GH-->>S: Binary
S->>S: chmod +x kind
S->>BIN: mv kind -> /usr/local/bin/kind
S-->>U: Print success message
else Unsupported
S-->>U: Print unsupported OS/ARCH and exit
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
kind-cluster/install.sh (1)
65-71: kubectl download is hardcoded to Linux/amd64; breaks on Linux arm64 and macOSThis will install the wrong binary on arm64 Linux and will be incorrect for macOS. Reuse OS/ARCH detection to fetch the correct artifact. Also, drop -o/-g flags for broader portability (macOS doesn’t use group root by default).
-if ! command -v kubectl &>/dev/null; then - echo "📦 Installing kubectl (latest stable version)..." - - curl -LO "https://dl.k8s.io/release/$(curl -Ls https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" - sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl - rm -f kubectl - - echo "✅ kubectl installed successfully." +if ! command -v kubectl &>/dev/null; then + echo "📦 Installing kubectl (latest stable version)..." + case "$OS" in + Linux) K_OS="linux" ;; + Darwin) K_OS="darwin" ;; + *) echo "❌ Unsupported OS for kubectl: $OS"; exit 1 ;; + esac + + case "$ARCH" in + x86_64) K_ARCH="amd64" ;; + aarch64|arm64) K_ARCH="arm64" ;; + *) echo "❌ Unsupported architecture for kubectl: $ARCH"; exit 1 ;; + esac + + K_VERSION="$(curl -fsSL https://dl.k8s.io/release/stable.txt)" + curl -fLo kubectl "https://dl.k8s.io/release/${K_VERSION}/bin/${K_OS}/${K_ARCH}/kubectl" + sudo install -m 0755 kubectl /usr/local/bin/kubectl + rm -f kubectl + echo "✅ kubectl installed successfully."
🧹 Nitpick comments (5)
kind-cluster/install.sh (5)
32-50: Kind: OS/ARCH branching and URLs look correct for v0.29.0; add curl -f for HTTP error handlingThe Linux/macOS matrices and artifact names are right. To fail fast on HTTP errors (e.g., 404), use curl -f so the script exits under set -e if a download URL is wrong or a network issue returns an HTTP error page.
Apply this minimal hardening:
- curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.29.0/kind-linux-amd64 + curl -fLo ./kind https://kind.sigs.k8s.io/dl/v0.29.0/kind-linux-amd64 @@ - curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.29.0/kind-linux-arm64 + curl -fLo ./kind https://kind.sigs.k8s.io/dl/v0.29.0/kind-linux-arm64 @@ - curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.29.0/kind-darwin-amd64 + curl -fLo ./kind https://kind.sigs.k8s.io/dl/v0.29.0/kind-darwin-amd64 @@ - curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.29.0/kind-darwin-arm64 + curl -fLo ./kind https://kind.sigs.k8s.io/dl/v0.29.0/kind-darwin-arm64Optional: verify checksums to guard against partial/corrupt downloads. I can provide a snippet if you want to add that.
55-57: Prefer install over mv/chmod for correct mode and atomicityinstall sets the mode and copies in one step; avoids an extra chmod and is more portable.
- chmod +x ./kind - sudo mv ./kind /usr/local/bin/kind + sudo install -m 0755 ./kind /usr/local/bin/kind + rm -f ./kind
14-25: Docker install is Linux-specific; script will fail on macOS before reaching the Kind sectionHomebrew/Apple silicon users won’t have apt-get, so this block will error on macOS despite the new macOS support for Kind. If the intent is “Kind on macOS” but “Docker only on Linux,” gate this block by OS.
-# ---------------------------- -# 1. Install Docker -# ---------------------------- -if ! command -v docker &>/dev/null; then +# ---------------------------- +# 1. Install Docker (Linux only) +# ---------------------------- +if [ "$OS" = "Linux" ]; then + if ! command -v docker &>/dev/null; then echo "📦 Installing Docker..." sudo apt-get update -y sudo apt-get install -y docker.io @@ echo "✅ Docker installed and user added to docker group." -else - echo "✅ Docker is already installed." -fi + else + echo "✅ Docker is already installed." + fi +else + echo "⏭️ Skipping Docker installation on $OS. Install Docker via Docker Desktop or your OS package manager." +fi
80-85: Version summary can abort the script under set -e if a tool is missingIf Docker is intentionally skipped on macOS (or kubectl/kind not installed), these lines will exit the script due to set -e. Consider guarding with command -v to keep the summary informative and non-fatal.
-docker --version -kind --version -kubectl version --client --output=yaml +command -v docker >/dev/null 2>&1 && docker --version || echo "ℹ️ Docker not found in PATH" +command -v kind >/dev/null 2>&1 && kind --version || echo "ℹ️ kind not found in PATH" +command -v kubectl >/dev/null 2>&1 && kubectl version --client --output=yaml || echo "ℹ️ kubectl not found in PATH"
32-50: Optional: reduce duplication via small helpers for OS/ARCH mappingNot required, but you can map uname values once to normalized values (e.g., AMD64 vs arm64) and reuse for both Kind and kubectl URLs.
If you’d like, I can propose a small normalize_arch() and normalize_os() shell snippet to DRY this up.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
kind-cluster/install.sh(2 hunks)
🔇 Additional comments (1)
kind-cluster/install.sh (1)
8-10: Good baseline: explicit OS/ARCH detection addedUsing uname to derive OS and CPU architecture is correct and enables the new branching logic later in the script.
What
Why
The previous script handled only Linux binaries. On macOS, the install failed because the Linux binary was fetched.
Scope
Only the Kind installation section was changed. Docker and kubectl installation flows remain unchanged.
Summary by CodeRabbit