02-core-controller

module
v0.0.0-...-d7ce96e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2020 License: MIT

README

Custom Controller - Core Resource Handling

What is this?

An example of a custom controller that's only purpose is to delete the completed job whose completed time is large than retention time (in all namespace). We also apply learning 01's leader election to support high available. For more knowledge about how to create custom controller, please refer to Extending Kubernetes: Create Controllers for Core and Custom Resources

In order to implement a custom controller, there's five steps to do:

  • Construct a skeleton of base controller to handle resource
  • Create a JobController to support job retention as demo
  • Implement the main func to provide flags as arguments, initialise K8s Clientset, K8s Informer, Job Controller
  • Use leader election package for high available
  • Define the deployment, service account and its RBAC role and cluster roles.

Running

# install controller as kubernetes deployment
$ kubectl apply -f deploy/install.yaml
# create some job resources to trigger event
$ kubectl create -f deploy/example.yaml

Directories

Path Synopsis
cmd
job
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL