Skip to content

Latest commit

 

History

History
89 lines (55 loc) · 1.8 KB

README.md

File metadata and controls

89 lines (55 loc) · 1.8 KB

What is it

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

How to get it

    
    cd $GOPATH/src/github.com/liqingsanjin
    
    git clone https://github.com/liqingsanjin/operator-demo.git

How to use it

  1. Enter the root dir of the project, $operator-demo is the project dir

    
    cd $GOPATH/src/github.com/liqingsanjin/operator-demo
    
    
    
  2. Build app, docker image and push the image

    
    sh dockerfiles/qiniu-nginx/build.sh yourImage
    
    
  3. 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
    
    
  4. 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
    
    

Run it on other namespace

  1. Create service account
    kubectl create -f yaml/demo/service_account.yaml -n yourNamespace
  1. Create cluster role
    kubectl create -f yaml/demo/cluster_role.yaml
  1. 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

Run it with helm

    helm install helm/operator-demo