sample-operator

command module
v0.0.0-...-31344b6 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2022 License: Apache-2.0 Imports: 28 Imported by: 0

README

sample-operator

Base sample for a custom controller in Kubernetes working with custom resources. Operator=CRD+CustomController

Thanks: kubernetes/sample-controller resouer/k8s-controller-custom-resource

Code generator

  • create CRD(custom resource definitions)
  • copy code-generator hack folder and script file, and modify script file for yourself
  • go mod vendor
  • Execute under the sample-operator folder: ./hack/update-codegen.sh

Build&Run

# Clone repo
$ git clone https://github.com/aaronmegs/sample-operator
$ cd sample-operator
# Build
$ go build -o samplecrd-operator .
$ ./samplecrd-operator -kubeconfig=$HOME/.kube/config -alsologtostderr=true

Usage

You should create the CRD of Foo and Network first:

$ kubectl apply -f artifacts/example/crd-foo.yaml
$ kubectl apply -f artifacts/example/crd-network.yaml

You can then trigger an event by creating a Foo or Network API instance:

$ kubectl apply -f artifacts/example/example-foo.yaml
$ kubectl apply -f artifacts/example/example-network.yaml

CURD the Foo and Network API instance, and check the logs of controller.

Enjoy!

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg
apis/samplecrd/v1alpha1
Package v1alpha1 is the v1alpha1 version of the API.
Package v1alpha1 is the v1alpha1 version of the API.
client/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
client/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
client/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
client/clientset/versioned/typed/samplecrd/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/versioned/typed/samplecrd/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