kind as a Go library

Created on 28 Dec 2019  路  2Comments  路  Source: kubernetes-sigs/kind

What would you like to be added:

kind works great for adhoc local development or end-to-end tests written in bash/make 鉂わ笍it's currently a bit fiddly to invoke directly from Go as a library - I'm not sure how many people are trying to do this yet, but I couldn't find any good examples anywhere. I've written a small library here that provides a lightweight API in return for some opinionated defaults: https://github.com/milesbxf/empathy

This could just be a case of documenting how to do this somewhere/what boilerplate is needed, but I think it'd be helpful to provide a simple API folks can just drop into their tests. I'd be open to raising a PR that implements some of the things from the aforementioned library if that works :)

Why is this needed:

Being able to write integration tests/end-to-end tests that create and interact with Kube clusters entirely in Go is pretty handy:

  • you can run tests directly with, e.g. go test ./e2e which allows you to add flags easily
  • you can create a clientset and run assertions against the cluster
kinfeature

Most helpful comment

Hi, this is a neat project, however, we'd prefer people build their opinionated versions out of tree.

kind actually has its own opinionated defaults if you do not pass any options to Create(...).

we're not focused on the go library right now for a few reasons:

  • the internals are not stable while we rework kind to finish enabling important features that require broad changes
  • invoking the CLI from your tests avoids library coupling issues between kind and your app, we do not want more PRs trying to change kind's dependencies because they need to match someone's app :upside_down_face:

aside this should not be necessary? kind follows the rules for creating these files laid out by kubectl. If you explicitly specify the kubeconfig path it will use and create it.
https://github.com/milesbxf/empathy/blob/f4767ba3fede63e07b5ceb852c62623edf546eb7/cluster.go#L34-L41

thanks again for sharing. we'll add better examples and re-introduce "kind as a library" to our docs when it's internally more stable and ready for this.

All 2 comments

Hi, this is a neat project, however, we'd prefer people build their opinionated versions out of tree.

kind actually has its own opinionated defaults if you do not pass any options to Create(...).

we're not focused on the go library right now for a few reasons:

  • the internals are not stable while we rework kind to finish enabling important features that require broad changes
  • invoking the CLI from your tests avoids library coupling issues between kind and your app, we do not want more PRs trying to change kind's dependencies because they need to match someone's app :upside_down_face:

aside this should not be necessary? kind follows the rules for creating these files laid out by kubectl. If you explicitly specify the kubeconfig path it will use and create it.
https://github.com/milesbxf/empathy/blob/f4767ba3fede63e07b5ceb852c62623edf546eb7/cluster.go#L34-L41

thanks again for sharing. we'll add better examples and re-introduce "kind as a library" to our docs when it's internally more stable and ready for this.

Thanks @BenTheElder - that makes sense 馃檶

Was this page helpful?
0 / 5 - 0 ratings