Skip to content

Fix kubectl-readonly Dockerfile to respect TARGETARCH - #212

Merged
imaustink merged 1 commit into
mainfrom
fix/kubectl-readonly-arch
Aug 18, 2026
Merged

Fix kubectl-readonly Dockerfile to respect TARGETARCH#212
imaustink merged 1 commit into
mainfrom
fix/kubectl-readonly-arch

Conversation

@imaustink

Copy link
Copy Markdown
Owner

Summary

  • tools/kubectl-readonly/Dockerfile hardcoded linux/amd64 when downloading the pinned kubectl binary, regardless of the actual build host architecture.
  • On an arm64 host (e.g. Apple Silicon minikube), the downloaded binary can't exec() — the kernel returns ENOEXEC, and the libc/shell fallback re-runs the raw ELF bytes as a shell script, surfacing at tool-run time as /usr/local/bin/kubectl: 1: Syntax error: ")" unexpected.
  • Fixed by wiring ARG TARGETARCH (set automatically by BuildKit) through to kubectl's release asset path, mirroring the pattern already used in tools/github/Dockerfile. Checksum verification is unchanged since kubectl.sha256 has no filename in it.

Test plan

  • docker build -f tools/kubectl-readonly/Dockerfile -t kubectl-readonly:latest . succeeds on this arm64 host
  • docker run --rm --entrypoint /usr/local/bin/kubectl kubectl-readonly:latest version --client now runs cleanly instead of failing with the syntax error
  • Rebuild/redeploy in the cluster and re-run the kubectl tool end-to-end

🤖 Generated with Claude Code

https://claude.ai/code/session_01DuP65eSctHC9RYHkMBzJoU

Hardcoded linux/amd64 downloaded an amd64 kubectl binary regardless of
build host. On arm64 (e.g. Apple Silicon minikube), the binary can't
exec -- ENOEXEC triggers the shell fallback that tries to interpret
the raw ELF bytes as a script, surfacing as "Syntax error: \")\"
unexpected" at tool-run time. Mirrors the same TARGETARCH pattern
already used in tools/github/Dockerfile.
@imaustink
imaustink merged commit 914cca2 into main Aug 18, 2026
6 checks passed
@imaustink
imaustink deleted the fix/kubectl-readonly-arch branch August 18, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant