kubernetes-sigs / kind

Kubernetes IN Docker - local clusters for testing Kubernetes
https://kind.sigs.k8s.io/
Apache License 2.0
13.02k stars 1.51k forks source link

Add a new directory/remote builder - new modes to specify k8s binaries to build node-images #3614

Closed dims closed 1 month ago

dims commented 1 month ago

Related to https://github.com/kubernetes-sigs/kind/issues/381

Enabling the following command lines to build node image

  1. Specify a tar gzipped file from a local disk or from an url

    kind build node-image $HOME/Downloads/kubernetes-server-linux-amd64.tar.gz
    kind build node-image --type url https://dl.k8s.io/v1.30.0/kubernetes-server-linux-arm64.tar.gz

    This is aimed at someone who may have a different build system and do not use the k8s make file targets, but would love to build a node image for kind with their own patches and build systems

  2. kind build node-image v1.30.0

    This is aimed at the majority of the current requests on slack and other avenues who just want to play with a version we haven't created a node image for (but has an upstream k8s tag and release artifacts)

Please take a look!

Here are the list of files and directory structure needed by the new builder in the tar gzipped file (including the kubernetes directory. which should be at the root of the passed in root directory)

kubernetes
└── server
    └── bin
        ├── kube-apiserver.docker_tag
        ├── kube-apiserver.tar
        ├── kube-controller-manager.tar
        ├── kube-proxy.tar
        ├── kube-scheduler.tar
        ├── kubeadm
        ├── kubectl
        └── kubelet

With this PR, here are some of the possibilities:

kind build node-image https://dl.k8s.io/v1.30.0/kubernetes-server-linux-arm64.tar.gz
kind build node-image $HOME/Downloads/kubernetes-server-linux-amd64.tar.gz
kind build node-image v1.30.0
kind build node-image $HOME/go/src/k8s.io/kubernetes/

kind build node-image --type url https://dl.k8s.io/v1.30.0/kubernetes-server-linux-arm64.tar.gz
kind build node-image --type file $HOME/Downloads/kubernetes-server-linux-amd64.tar.gz
kind build node-image --type release v1.30.0
kind build node-image --type source $HOME/go/src/k8s.io/kubernetes/

kind build node-image
dims commented 1 month ago

built an image using:

kind build node-image v1.30.0

and looks like that does build the node image properly

$ kind create cluster --image kindest/node:latest
Creating cluster "kind" ...
 ✓ Ensuring node image (kindest/node:latest) 🖼
 ✓ Preparing nodes 📦
 ✓ Writing configuration 📜
 ✓ Starting control-plane 🕹️
 ✓ Installing CNI 🔌
 ✓ Installing StorageClass 💾
Set kubectl context to "kind-kind"
You can now use your cluster with:

kubectl cluster-info --context kind-kind

Have a nice day! 👋

$ kubectl cluster-info --context kind-kind
Kubernetes control plane is running at https://127.0.0.1:35929
CoreDNS is running at https://127.0.0.1:35929/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
dims commented 1 month ago

/retest

dims commented 1 month ago

@BenTheElder @aojea here's what i came up with. Please verify if we can go with this.

--type CLI parameter Action
NONE NONE Autodetect k8s directory to build
NONE resolves as a Directory Use directory as source to build
NONE resolves as a tarball file Treat as binary tar ball
NONE parses as a semver Download from dl.k8s.io
NONE parses as a url Download binary tarball
source Directory Use directory as source to build
file tarball file Treat as binary tar ball
release semver Download from dl.k8s.io
url URL to tarball Download binary tarball
dims commented 1 month ago

@stmcginnis @aojea @BenTheElder here are the latest command lines i tested. If these are good, then i'll update the docs in this PR itself.

kind build node-image https://dl.k8s.io/v1.30.0/kubernetes-server-linux-arm64.tar.gz
kind build node-image $HOME/junk/kubernetes-server-linux-amd64.tar.gz
kind build node-image v1.30.0
kind build node-image $HOME/go/src/k8s.io/kubernetes/

kind build node-image --type url https://dl.k8s.io/v1.30.0/kubernetes-server-linux-arm64.tar.gz
kind build node-image --type file ~/junk/kubernetes-server-linux-amd64.tar.gz
kind build node-image --type release v1.30.0
kind build node-image --type source $HOME/go/src/k8s.io/kubernetes/

kind build node-image
stmcginnis commented 1 month ago

This looks reasonable to me - thanks @dims!

dims commented 1 month ago

Updated docs and CLI help. thanks @stmcginnis

@aojea @BenTheElder PTAL

BenTheElder commented 1 month ago

If these are good, then i'll update the docs in this PR itself.

We'll want to add a note that modes other than source directory are only kind v0.24+

dims commented 1 month ago

We'll want to add a note that modes other than source directory are only kind v0.24+

Done!

dims commented 1 month ago

@BenTheElder is VM / VM (Fedora) (docker, rootless) (pull_request) failure a flake? exec format error seems like something wrong in the GH action itself?

aojea commented 1 month ago

/lgtm Thank you very much Dims, this is really great

dims commented 1 month ago

Thank you very much Dims, this is really great

thanks @aojea !

/assign @BenTheElder

stmcginnis commented 1 month ago

Thanks @dims!

/lgtm

dims commented 1 month ago

/test pull-kind-e2e-kubernetes-1-29

BenTheElder commented 1 month ago

@BenTheElder is VM / VM (Fedora) (docker, rootless) (pull_request) failure a flake? exec format error seems like something wrong in the GH action itself?

yeah, that sounds like a failed download or bad binfmt_misc, we have some flakes in these jobs with the environment and some flakes in prow with the e2e tests (like #3609, still waiting for those backports to merge)

k8s-ci-robot commented 1 month ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BenTheElder, dims

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/kubernetes-sigs/kind/blob/main/OWNERS)~~ [BenTheElder] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
tanvp112 commented 4 days ago

Hi, this is a kind v0.24.0 feature, right? Any thought when this will be release. Thanks!

BenTheElder commented 4 days ago

It is. When we're ready. There are other essentials to sort out and all of us only work on kind part time so no particular ETA.

you can install kind @ HEAD with the makefile, instructions in the docs, but it won't be fully supported yet and we may make some changes before releasing.