Skip to content

Latest commit

 

History

History
37 lines (27 loc) · 936 Bytes

README.md

File metadata and controls

37 lines (27 loc) · 936 Bytes

The project is designed to implement a K8s Operator with as few tools as possible and understand the K8s Operator core logic.

How to write an Operator

  1. Write CRD and register CR with kube-apiserver: crd.yaml
  2. Write resource definitions through code:

apis.png

  1. Generate clients:
$ make build-resource

You may need to prepare the code generation tool by doing the following:

$ go get k8s.io/code-generator/cmd/defaulter-gen
$ go get k8s.io/code-generator/cmd/client-gen
$ go get k8s.io/code-generator/cmd/lister-gen
$ go get k8s.io/code-generator/cmd/informer-gen
$ go get k8s.io/code-generator/cmd/deepcopy-gen
  1. Write controller and add event handlers to informer.

Usage

# Register CR.
$ kubectl apply -f yaml/crd.yaml

# Build Operator.
$ make build-operator

# Run operator outside of Cluster.
$ ./release/operator -kubeconfig ~/.kube/config