This repo is a demo project, which is scaffoled by kubebuilder
for showing how Bounded Deployment
works. CRD will be created and installed to cluster as a Kubernetes resource. Requests of creating a CR object from kubectl
is received by Kubernetes API server, which will invoke Webhook
for handling. API server patches the response from Webhook for creating this object eventually. Controller
is consistently watching and reconciling this object.
- go 1.10 or newer
- dep v0.5.0 or newer
- kubebuilder v1.0.5 or newer
- a minikube cluster with version v0.30.0 or newer
git clone
the repo under your GOPATH
.
Run eval $(minikube docker-env)
after minikube starts.
We will reuse the docker daemon in minikube.
Run ./start_demo.sh
.
- Scaffold a project
- Scaffold a CRD API
- Scaffold a controller
- Scaffold a mutating webhook
- Fill the business logic by applying a patch
- Run
make
- Modify instances of CR by applying a patch.
- Build image by
make docker-build
- (Skipped) Push image by
make docker-push
- Deploy by
make deploy
Note: make docker-push
pushes images to your registry.
This step is skipped in the demo because we reuse the docker daemon in minikube.
Controller creates deployment with the same replicas specified in the CR.
The mutating webhook modifies the CR.
If the replicas
field is not set, default it to 2.
If the replicas > 2
, it change it to 2.
- Create a instance of CR with replicas=10
- Verify a deployment with replicas=2 has been created.