k3s/BUILDING.md
Luther Monson 9a849b1bb7
[master] changing package to k3s-io (#4846)
* changing package to k3s-io

Signed-off-by: Luther Monson <luther.monson@gmail.com>

Co-authored-by: Derek Nola <derek.nola@suse.com>
2022-03-02 15:47:27 -08:00

2.0 KiB

Note: In case you are looking for the pre-built releases see the release page.

Build k3s from source

Before getting started, bear in mind that this repository includes all of Kubernetes history, so consider shallow cloning with (--depth 1) to speed up the process.

git clone --depth 1 https://github.com/k3s-io/k3s.git

The k3s build process requires some autogenerated code and remote artifacts that are not checked in to version control. To prepare these resources for your build environment, run:

mkdir -p build/data && make download && make generate

To build the full release binary, you may now run make, which will create ./dist/artifacts/k3s.

To build the binaries using make without running linting (i.e.: if you have uncommitted changes):

SKIP_VALIDATE=true make

In case you make any changes to go.mod, you should run go mod tidy before running make.

macOS considerations

The shell scripts in charge of the build process (the ones behind make) rely on GNU utils (i.e., sed), which slightly differ on macOS. So, if you need to build k3s on a macOS environment, it is suggested to use the virtual machine defined on this repository's Vagrantfile to perform the tasks mentioned above.

To start the virtual machine, you will need vagrant and virtual box installed. Then prompt:

$ vagrant up
[... vm provisioning logs ...]

Once the virtual machine is provisioned, you should be able to ssh into it by doing vagrant ssh and perform any building task there:

$ vagrant ssh
[... ssh connection logs ..]
$ uname -a
Linux k3s-0-alpine312 5.11.0-41-generic
$ make
[... k3s build logs ...]

All the artifacts built within the VM will be synchronized with the directory where the vagrant up command was issued. For vagrant related commands please refer to its cli documentation.