- kubernetes/code-generator
- kubernetes/sample-controller
- openshift-evangelists/crd-code-generation
- How to generate client codes for Kubernetes Custom Resource Definitions (CRD)
cd $GOPATH/src
mkdir k8s.io
cd k8s.io
git clone git@github.com:kubernetes/code-generator.git
git checkout tags/v0.20.5 -b v0.20.5
go install ./cmd/{defaulter-gen,client-gen,lister-gen,informer-gen,deepcopy-gen}
# need import k8s.io/code-generator
go get k8s.io/code-generator@v0.20.5
go mod vendor
go install ./vendor/k8s.io/code-generator/cmd/{defaulter-gen,client-gen,lister-gen,informer-gen,deepcopy-gen}
hack/generate-groups.sh all github.com/gaoxinge/website-v2-operator/pkg/client github.com/gaoxinge/website-v2-operator/pkg/apis extensions.example.com:v2
# need import k8s.io/code-generator
go get k8s.io/code-generator@v0.20.5
go mod vendor
vendor/k8s.io/code-generator/generate-groups.sh all github.com/gaoxinge/website-v2-operator/pkg/client github.com/gaoxinge/website-v2-operator/pkg/apis extensions.example.com:v2
You can build and push image by yourself
docker build -f docker/Dockerfile -t gaoxinge/website-v2-controller .
docker push gaoxinge/website-v2-controller:latest
or directly use
kubectl create -f yaml/website-v2-crd.yaml
kubectl create -f yaml/website-v2-controller.yaml
kubectl create serviceaccount website-v2-controller
kubectl create clusterrolebinding website-v2-controller --clusterrole=cluster-admin --serviceaccount=default:website-v2-controller
kubectl create -f yaml/website-v2-example.yaml
kubectl delete website kubia
kubectl delete clusterrolebinding website-v2-controller
kubectl delete serviceaccount website-v2-controller
kubectl delete deployment website-v2-controller
kubectl delete crd websites.extensions.example.com
- add update for website
- add watcher for deployment and service
- add unit test