Skip to content

crashdump/k8s-crd-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

k8s-crd-boilerplate

⚠️ Kubernetes has evolved a lot since I wrote this boilerplate, these days I recommend you look in the directory of: https://github.com/operator-framework/operator-sdk

As I started writing Kubernetes CDR (Custom Resource Definitions) I found there was a lot of documentation on the details but very little on what was necessary or not to create a project.

This boilerplate contains only what is needed to bootstrap a CRD.

  1. Rename files/packages name from CrdBoilerplate to whatever you are working on
  2. Edit types.go and register.go (in 'pkg/apis/crdboilerplate/v1alpha1/')
  3. Edit ./hack/update-codegen.sh to reflect the change
  4. Generate the code
./hack/update-codegen.sh
  1. Build the controller
go build -o list-things cmd/ls-things/main.go
  1. Edit the CRD manifest (in './artifacts/')
  2. Apply it to the cluster and run your binary
kubectl apply -f artifacts/cdr.yml
  1. Add a new test resource
kubectl apply -f artifacts/example-thing.yml
  1. List all the things
./ls-things -kubeconfig ~/.kube/config
Found a thing with the name 'a-thing' and the content 'something'

I choose not to include the controller daemon code as you can find a very good and up-to-date example on github.com/kubernetes/sample-controller.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published