This is an operator-demo. You can use it to create CRD, and listen the events that contains ADD/UPDATE/DELETE event.
Event ADD: Create apps of nginx, k8s cluster can access it through cluster ip
Event UPDATE: Update the version of nginx
Event DELETE: Delete all of pods, deployments, and services
cd $GOPATH/src/github.com/liqingsanjin
git clone https://github.com/liqingsanjin/operator-demo.git
-
Enter the root dir of the project, $operator-demo is the project dir
cd $GOPATH/src/github.com/liqingsanjin/operator-demo
-
Build app, docker image and push the image
sh dockerfiles/qiniu-nginx/build.sh yourImage
-
Update the the image in the file (yaml/demo/qiniu_nginx.yaml). Then deploy the app in k8s cluster
kubectl create -f yaml/demo/qiniu_nginx.yaml
-
Create/Update/Delete an instance of the crd
kubectl create -f yaml/demo/test_qiniu_nginx.yaml kubectl replace -f yaml/demo/test_qiniu_nginx.yaml kubectl delete -f yaml/demo/test_qiniu_nginx.yaml
- Create service account
kubectl create -f yaml/demo/service_account.yaml -n yourNamespace
- Create cluster role
kubectl create -f yaml/demo/cluster_role.yaml
- Create cluster role binding
kubectl create -f yaml/demo/cluster_role_binding.yaml
Then you need update the files(yaml/demo/qiniu_nginx.yaml, yaml/demo/cluster_role_binding.yaml), add the serviceAccountName and your namespace in them.
serviceAccountName: yourServiceAccountName
Create the app
kubectl create -f yaml/demo/qiniu_nginx.yaml -n yourNamespace
helm install helm/operator-demo