minimalist-operator

module
v0.0.0-...-1aa3e9c Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: Apache-2.0

README

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

Directories

Path Synopsis
pkg
clients/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
clients/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
clients/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
clients/clientset/versioned/typed/example/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
clients/clientset/versioned/typed/example/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.

Jump to

Keyboard shortcuts

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