kubernetes-sigs / kubebuilder Goto Github PK
View Code? Open in Web Editor NEWKubebuilder - SDK for building Kubernetes APIs using CRDs
Home Page: http://book.kubebuilder.io
License: Apache License 2.0
Kubebuilder - SDK for building Kubernetes APIs using CRDs
Home Page: http://book.kubebuilder.io
License: Apache License 2.0
kubebuilder docs
generates a config.yaml
file that is used to control the table of contents for docs. The config.yaml can also be used to set warnings and description notes on specific APIs, however since the file is generated, users shouldn't edit it directly.
Instead we should support the following annotations on resource structs:
// +kubebuilder:docs:warning
// +kubebuilder:docs:note
These should be added to the generated config.yaml after group here as is shown here and here
The test framework requires the following environment variables to be set:
export TEST_ASSET_KUBECTL=/usr/local/kubebuilder/bin/kubectl
export TEST_ASSET_KUBE_APISERVER=/usr/local/kubebuilder/bin/kube-apiserver
export TEST_ASSET_ETCD=/usr/local/kubebuilder/bin/etcd
Can we do something in the test harness (e.g. _suite.go) to make it so these are defaulted to this location?
Generated files such as zz_generated.kubebuilder.go
do not handle plural form kind name consistently. For instance, some informers call to AppReplicas
kind via .AppReplicases()
, but others via .AppReplicass()
.
Furthermore, k get redisreplicases
failed to list the objects.
Perhaps we can conform all kind names to singular form.
We parse the following tags, but don't actually set them on the CRDs:
We generate docs/reference/config.yaml from the resource types we find, however users may add notes and warnings to the config.yaml. We should look for these when regenerating, and keep them.
Currently, kubebuilder update vendor
only updates the vendor
directory, not the Gopkg.lock
and Gopkg.toml
files. This leaves them out-of-sync, which is not ideal for understanding the versions of dependencies in the repo.
Alternatively, kubebuilder
could not initialize a project with the Gopkg
files, and leave that to the project's discretion.
When I try to create a resource with a name that's already it's own plural, the resource creation fails:
$ kubebuilder create resource --group foo --version v1alpha1 --kind Metadata
2018/05/14 14:22:16 Client code generation expects singular --kind.
It looks like the code here is triggering this. Perhaps it would be useful to add a flag to bypass this check?
When trying to download the release under https://storage.googleapis.com/kubebuilder-release/kubebuilder-release-v1.9-alpha.30-darwin-amd64.tar.gz I get an access denied message:
wget https://storage.googleapis.com/kubebuilder-release/kubebuilder-release-v1.9-alpha.30-darwin-amd64.tar.gz
--2018-03-15 10:55:18-- https://storage.googleapis.com/kubebuilder-release/kubebuilder-release-v1.9-alpha.30-darwin-amd64.tar.gz
Resolving storage.googleapis.com... 172.217.22.240
Connecting to storage.googleapis.com|172.217.22.240|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2018-03-15 10:55:20 ERROR 403: Forbidden.
To fix #62.
Allow users to annotate fields with the format so they can specify "email" or "date" formats for strings.
When running kubebuilder create config
to generate a controller image, I encountered a CRD validation
bug that specifies AdditionalConfiguration
field cannot be set to false.
For instance, I have the bug for options
field in my types.go
file:
// Options is additional configuration options that will be passed to the pods.
// +optional
Options map[string]string `json:"options,omitempty"`
In zz_generated.kubebuilder.go
file, the AdditionalConfiguration
field is initialized as follow:
AdditionalProperties: &v1beta1.JSONSchemaPropsOrBool{
Allows: true,
//Schema: &,
},
We realized we have less than adequate test coverage of Generic Controller's watchControllerOf API. For ex. this fix uncovered a bug where we end up an infinite loop be1a28b
Make sure it actually works
Kubebuilder generates integration testing framework in pkg/controller/<some-controller-name>/controller_test.go
. It would be great if kubebuilder also generates e2e testing framework too.
/cc @droot @pwittrock
add annotation to the CRD itself like kubebuilder.k8s.io/version: v1.2.3
Version helps with debugging reports.
AAUI can run dep ensure
to install the dependencies for building a project with Kubebuilder and I can add new dependencies to the Gopkg.toml file and run dep ensure
to additional pkgs.
The Gopkg.toml could use some cleanup
dep
runs cleanly on clients. Fix errors:Warning: the following project(s) have [[constraint]] stanzas in Gopkg.toml:
✗ github.com/pkg/errors
✗ github.com/spf13/cobra
✗ k8s.io/apiserver
✗ k8s.io/kube-aggregator
In the cloudbuild.yaml also create checksums for the binaries and upload them to gcs alongside the binaries. Look at how other projects do this such as etcd
Check the following are backwards compatible in a test:
Many of the codegen labels don't have this prefix
https://godoc.org/github.com/kubernetes-sigs/kubebuilder/pkg/gen/apis#example-package
https://godoc.org/github.com/kubernetes-sigs/kubebuilder/pkg/gen/controller
Must be done in a backward compatible way - add support for the new label and change the defaults created when bootstrapping.l
Categories are groups of resources (example: all
is a category). CRDs can be part of categories:
It would be useful to drive the categories of a resource via a kubebuilder:categories=foo,bar,zab
annotation.
http
packagegenerate
create config
create config
that allows the controller to update the WebHook (and only that webhook) if installing a webhook.The created code would be simpler if it just uses the InjectArguments directly
The go struct CRD generated in the versioned resource package should match the install.yaml CRDs from create config
. We should test this against some cases. Got a report the map[string][string] fields are represented differently.
Figure out if there is anything in the commit history from the apiserver-builder repo we should copy over.
The generated code from create resource should create a Recorder
The change log for the most recent release includes the very first commit ever :P
Kubebuilder doesn't work with go 1.8. We should check the go version is sufficient when creating a new project.
The team working on apply is running into this same issue. We should work together to make sure we solve it once in a canonical fashion. Lets work with the folks building CRDs to come up with a design doc for the canonical way to generate CRDs from goidl.
I am getting following error when trying to create a resource with kind as 'Postgres'.
$ kubebuilder create resource --group group1 --version v1alpha1 --kind Postgres
2018/05/14 16:18:00 Client code generation expects singular --kind.
I think line 47 in https://github.com/kubernetes-sigs/kubebuilder/blob/f6d054862aeb05016b0b5c1c39d4f867d93dc944/cmd/kubebuilder/create/util/util.go needs to accommodate Kind names which are singular and ending with a 's'.
kubebuilder version
v
is dropped0.1.5
When walking through the files generated through kubebuilder
, I found codes in some files are not well-aligned, for example in cmd/controller-manager/main.go
:
import (
"flag"
"log"
// Import auth/gcp to connect to GKE clusters remotely
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
configlib "github.com/kubernetes-sigs/kubebuilder/pkg/config"
"github.com/kubernetes-sigs/kubebuilder/pkg/inject/run"
"github.com/kubernetes-sigs/kubebuilder/pkg/install"
"github.com/kubernetes-sigs/kubebuilder/pkg/signals"
extensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
"example.com/pkg/inject"
"example.com/pkg/inject/args"
)
var installCRDs = flag.Bool("install-crds", true, "install the CRDs used by the controller as part of startup")
// Controller-manager main.
func main() {
flag.Parse()
stopCh := signals.SetupSignalHandler()
Of course a user can easily format the files via go fmt
, but for better experience, I think we'd better
go format
for output files automatically@pwittrock WDYT?
The following getting started link in the main README is broken.
Same issue as code-generator:
I can work around it with a simple script that does a search/replace
Kubebuilder should support access to old objects. Currently, the Reconcile
loop only provides a key. There is no easy way to access the old objects after update operations. A workaround is to save the object state periodically via global variables, but there should be a better way to access the old objects.
...and we should find a way to clarify which version of kubernetes are supported. 1.10 definitely is.
I have a use case that as part of handling a newly added CRD object, a StatefulSet
gets created and owned by the CRD object (through an OwnerReference
added on the StatefulSet
). The generated controller code for the CRD resource allows me to add a watch on StatefulSet
s. But how can I register/add functions that react to events on the StatefulSet
s and reconcile them?
Also it appears to me that watches with custom label selectors are not yet supported.
We need to be able to run e2e tests that
New project
Right an e2e test that runs kubebuilder docs
and verifies the output.
docs/reference/includes/*
, docs/reference/config.yaml
and docs/reference/manifest.json
files since they are relatively stable.Not sure if this is still an issue.
CRD spec lists bool, when it should be boolean, int32 should be integer
Is there a way to specify validation for things just as email and URL/URI?
Some generated structs have missing fields.
For instance, InjectArgs
struct does not have some necessary fields such as Clientset
:
arguments.Clientset undefined (type args.InjectArgs has no field or method Clientset)
There are several import issues after generating the codes too.
For instance, in /cmd/controller-manager/main.go
, there is a conflicting import for k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1
due to 2 vendor
packages in the repo (one is <pkg>/vendor
, another is <pkg>/cmd/vendor
).
Same errors happened after re-downloading kubebuilder and re-generating the files.
Currently, Reconcile
loop will be triggered periodically or by any event. It would be great if the controller provides the functionality to perform specific reconcile effort based on event type. For example, there are 3 loops for add
, update
, and delete
events (or one reconcile loop that performs differently based on event type).
Steps to repro, in an empty directory in $GOPATH/src
:
$ kubebuilder init --domain example.com
$ kubebuilder create resource --group example --version v1alpha1 --kind Example --controller=false
$ kubebuilder docs
Failure:
$ kubebuilder docs
2018/05/01 14:46:37 docker run -v $GOPATH/src/example.com/example:/host/repo -e DOMAIN=example.com -e DIR=src/example.com/example -e OUTPUT=docs/reference gcr.io/kubebuilder/gendocs
+ export D=src/example.com/example/docs/reference
+ D=src/example.com/example/docs/reference
+ mkdir -p src/example.com/example/docs/reference
+ cp -r /host/repo/pkg src/example.com/example/pkg
+ '[' -d /host/repo/docs/reference ']'
+ cp -r /host/repo/docs/reference/config.yaml /host/repo/docs/reference/examples /host/repo/docs/reference/openapi-spec /host/repo/docs/reference/static_includes src/example.com/exampledocs/reference
+ '[' '!' -d src/example.com/example/boilerplate.go.txt ']'
+ touch src/example.com/example/boilerplate.go.txt
+ cd src/example.com/example
+ apiserver-boot init repo --domain example.com
2018/05/01 21:46:38 installing vendor/ directory. To disable this, run with --install-deps=false.
+ apiserver-boot build generated clean
+ apiserver-boot build generated
/usr/local/apiserver-builder/bin/apiregister-gen --input-dirs src/example.com/exampler/pkg/apis/... --input-dirs src/example.com/example/pkg/controller/...
2018/05/01 21:46:40 failed to run apiregister-gen panic: Could not find string matching // +domain=.+ in apis/doc.go
goroutine 1 [running]:
github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators.(*APIsBuilder).ParseDomain(0xc427e3a7e0)
/Users/pwittroc/apiserver-builder/src/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/parser.go:566 +0x12d
github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators.NewAPIsBuilder(0xc427e13f20, 0xc42001a780, 0x4cba11)
/Users/pwittroc/apiserver-builder/src/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/parser.go:186 +0x81
github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators.(*Gen).Packages(0xc42000a800, 0xc427e13f20, 0xc42001a780, 0x6000104, 0x0, 0xffffffffffffffff)
/Users/pwittroc/apiserver-builder/src/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/package.go:89 +0xa1
github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators.(*Gen).Packages-fm(0xc427e13f20, 0xc42001a780, 0x765a6e, 0x6, 0xc427e13f20)
/Users/pwittroc/apiserver-builder/src/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/package.go:45 +0x3e
github.com/kubernetes-incubator/apiserver-builder/cmd/vendor/k8s.io/gengo/args.(*GeneratorArgs).Execute(0xc42001a780, 0xc4200f83f0, 0x765a6e, 0x6, 0xc426711ee8, 0x20, 0x718e60)
/Users/pwittroc/apiserver-builder/src/github.com/kubernetes-incubator/apiserver-builder/cmd/vendor/k8s.io/gengo/args/args.go:165 +0x1e6
github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators.(*Gen).Execute(0xc42000a800, 0xc42001a780, 0x0, 0x0)
/Users/pwittroc/apiserver-builder/src/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/package.go:45 +0x85
main.main()
/Users/pwittroc/apiserver-builder/src/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/main.go:47 +0x136
exit status 2
2018/05/01 14:46:41 error: exit status 1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.