ahmetb / kubectx

Faster way to switch between clusters and namespaces in kubectl
https://kubectx.dev
Apache License 2.0
17.79k stars 1.27k forks source link

kubectx for ARM? #213

Closed alexellis closed 4 years ago

alexellis commented 4 years ago

Hi there @ahmetb 👋

Congrats on the relaunch.

I see a Linux binary for x86_64, but can't see ARM variants of kubectx. The Kubernetes project any many other projects in the CNCF ecosystem provide support out of the box, and it's relatively easy through cross-compilation.

Would you be open to taking a look at how we've provided ARM binaries for armhf (RPi) and aarch64 (AWS / Packet / Scaleway) in the arkade project and consider providing a binary? https://github.com/alexellis/arkade/blob/master/Makefile#L22

Alex

ahmetb commented 4 years ago

Yeah should be fairly easy. I'm not at all familiar with arm so I'll ask again if this looks good:

  1 binary=/Users/ahmetb/workspace/kubectx/dist/kubectx_windows_amd64/kubectx.exe
  2 binary=/Users/ahmetb/workspace/kubectx/dist/kubectx_linux_arm_6/kubectx
  3 binary=/Users/ahmetb/workspace/kubectx/dist/kubectx_linux_amd64/kubectx
  4 binary=/Users/ahmetb/workspace/kubectx/dist/kubectx_linux_arm64/kubectx
  5 binary=/Users/ahmetb/workspace/kubectx/dist/kubectx_darwin_amd64/kubectx
  6 binary=/Users/ahmetb/workspace/kubectx/dist/kubens_windows_amd64/kubens.exe
  7 binary=/Users/ahmetb/workspace/kubectx/dist/kubens_linux_amd64/kubens
  8 binary=/Users/ahmetb/workspace/kubectx/dist/kubens_linux_arm_6/kubens
  9 binary=/Users/ahmetb/workspace/kubectx/dist/kubens_linux_arm64/kubens
 10 binary=/Users/ahmetb/workspace/kubectx/dist/kubens_darwin_amd64/kubens

(I just added arm and arm64 to the goreleaser configs).

alexellis commented 4 years ago

Those names look a little off compared to defecto usage. I would typically expect to see something like this:

arm6 is for the original generation of RPi which almost nobody will be able to run K8s on (512mb RAM)

ahmetb commented 4 years ago

Oh I was just copying from your link. :) In your case you have GOOS=linux GOARCH=arm GOARM=6 named armhf. Are you sure armhf is always armv7? Or does armhf mean non-64bit arm?

alexellis commented 4 years ago

We could probably change that to 7 for arkade as it's not needed for the original PRi (6). There are purist approaches, but the community usually calls armv7 binaries armhf, armv7 would also be be OK as a suffix.

ahmetb commented 4 years ago

I'm looking for help on what exactly to do. I'm still unclear what armhf means and how many people use each of these. If you can provide 2-3 GOOS lists, I can fix it, otherwise we'll keep talking about something I don't understand at all. :) I'm not sure how to get armv7 (is it 32 bit or 64 bit) or armhf etc.

alexellis commented 4 years ago

Maybe @caarlos0 can give a hint on what to put in goreleaser.yml to get the desired filename output, I tried a few combinations to generate the output we usually see on OSS Go projects:

GOOS=linux, GOARM=6 or higher, is generally called "-linux-armhf"

See as a reference the: Golang wiki - https://github.com/golang/go/wiki/GoArm#supported-architectures

You probably don't need to compile for "6" since it's the first-gen RPi not suitable for Kubernetes.

kosmos:cmd alex$ GOOS=linux GOARCH=arm GOARM=7 go build
kosmos:cmd alex$ file cmd
cmd: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, not stripped

For your aarch64 / ARMv8 you need:

kosmos:cmd alex$ GOOS=linux GOARCH=arm64 go build
kosmos:cmd alex$ file cmd
cmd: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, not stripped

Those are the combinations you need, and if you can format it as "kubectx-linux-armhf" and "kubectx-linux-armv8" that would be great.

I'm not a goreleaser user, but gave it an hour this morning and didn't get anywhere 🤷‍♂️

caarlos0 commented 4 years ago

Hey,

looking at kubectx goreleaser config:

"kubectx{{ .Tag }}{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"

so, just need to add arm and arm64 to goos and 7 and 8 to goarch.

if you want different names, tuning the name templates should do the trick :)

alexellis commented 4 years ago

Those names should work well 👍

ahmetb commented 4 years ago

I was trying this config

  goos:
    - linux
    - darwin
    - windows
  goarch:
    - amd64
    - arm
    - arm64
  goarm: [7, 8]

but got failed to build for linux_arm_8: 2020/05/04 13:45:10 Invalid GOARM value. Must be 5, 6, or 7. error. :) So I guess armv8 isn't a thing? Can we just do arm7 @alexellis?

caarlos0 commented 4 years ago

armv8 is goarch=arm64 AFAIK :)

ahmetb commented 4 years ago

Ahha, that checks out. https://github.com/golang/go/wiki/GoArm

If these names are acceptable I'll commit:

archive=dist/kubectx_v0.9.0_linux_armv7.tar.gz
archive=dist/kubectx_v0.9.0_linux_arm64.tar.gz
alexellis commented 4 years ago

It's a thing, it's just specified differently. I gave the valid examples for GO parameters. I'm not a goreleaser user unfortunately. For 32-bit arm using "arm" is ambiguous, hence the armv7 or armhf which are commonly used.

ahmetb commented 4 years ago

hence the armv7 or armhf which are commonly used.

so I'm assuming you're suggesting we keep both goarm: [6, 7] then, but rename armv6 to armhf?

alexellis commented 4 years ago

If these names are acceptable I'll commit

Yes, as per my last comment, which appears to have arrived out of sync, those names are fine.

https://github.com/ahmetb/kubectx/issues/213#issuecomment-623699026