kubectl icon indicating copy to clipboard operation
kubectl copied to clipboard

How to build `kubectl` form source for FreeBSD?

Open YevheniiPokhvalii opened this issue 3 years ago • 4 comments

I cannot find any modern guide on how to build kubectl from source for FreeBSD. Any guide I found in the internet, does not work for me. Like this one from Microsoft: https://docs.microsoft.com/en-us/virtualization/windowscontainers/kubernetes/compiling-kubernetes-binaries

$ KUBE_BUILD_PLATFORMS=freebsd/amd64 build/run.sh make WHAT=cmd/kubectl
!!! [0807 23:48:15] Unsupported host OS.  Must be Linux or Mac OS X.

Here is the error I got. But there is kubectlv1.24.1 in FreeBSD ports, so it is absolutely possible to build it for FreeBSD: https://www.freshports.org/sysutils/kubectl

I need kubectlv1.22.2 for FreeBSDv13.

How to build it from source?

YevheniiPokhvalii avatar Aug 07 '22 21:08 YevheniiPokhvalii

@YevheniiPokhvalii: This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Aug 07 '22 21:08 k8s-ci-robot

I found a workaround. Ironically, the Linux kubectl binaries work on FreeBSD. I could not manage to install kubectlv1.22.2 so I tried a bit of a higher version, which was also OK for my needs:

$ curl -LO https://dl.k8s.io/release/v1.23.9/bin/linux/amd64/kubectl
$ ./kubectl version --short
Client Version: v1.23.9

I did not even have to enable the Linux compatibility mode: https://docs.freebsd.org/en/books/handbook/linuxemu/ So, it may seem to be working for 64bit as well on modern version of FreeBSD: https://www.freebsdhandbook.com/linuxemu

Though, It would still be nice to hear the solution on how to build binaries for FreeBSD.

YevheniiPokhvalii avatar Aug 08 '22 00:08 YevheniiPokhvalii

KUBE_BUILD_PLATFORMS=linux/amd64 build/run.sh make WHAT=cmd/kubectl

^^^^^^ should work on freebsd as well.

Or just use make kubectl

dims avatar Aug 08 '22 00:08 dims

KUBE_BUILD_PLATFORMS=linux/amd64 build/run.sh make WHAT=cmd/kubectl

^^^^^^ should work on freebsd as well.

Or just use make kubectl

I have this error:

$ KUBE_BUILD_PLATFORMS=linux/amd64 build/run.sh make WHAT=cmd/kubectl
!!! [0808 03:41:15] Unsupported host OS.  Must be Linux or Mac OS X.

That's the error from ./hack/local-up-cluster.sh:

function detect_binary {
    # Detect the OS name/arch so that we can find our binary
    case "$(uname -s)" in
      Darwin)
        host_os=darwin
        ;;
      Linux)
        host_os=linux
        ;;
      *)
        echo "Unsupported host OS.  Must be Linux or Mac OS X." >&2
        exit 1
        ;;
    esac

Also, make kubectl throws a lot of errors too, like:

make: "$HOME/go/src/k8s.io/kubernetes/Makefile" line 163: Invalid line type

YevheniiPokhvalii avatar Aug 08 '22 06:08 YevheniiPokhvalii

You should be able to specifically build kubectl from the main k/k repo with go build ./cmd/kubectl.

eddiezane avatar Aug 17 '22 16:08 eddiezane

I think the issue of supporting FreeBSD should be raised in the main Kubernetes repo. My guess is we'd be happy to take a PR to update the tooling but would need a committed maintainer using FreeBSD to keep up with it.

/close

eddiezane avatar Aug 17 '22 22:08 eddiezane

@eddiezane: Closing this issue.

In response to this:

I think the issue of supporting FreeBSD should be raised in the main Kubernetes repo. My guess is we'd be happy to take a PR to update the tooling but would need a committed maintainer using FreeBSD to keep up with it.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Aug 17 '22 22:08 k8s-ci-robot