crd-example

module
v0.0.0-...-0bdd209 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2018 License: Apache-2.0

README

Build Status GitHub license

Custom Resource Definition Example

This file shows an example of creating Custom Resource Definitions (CRDs) to integrate inside of a Ligato plugin. At their essence, CRDs are an extension of the Kubernetes API. This page describes CRDs in detail, while this page describes extending Kubernetes with CRDs.

To programmatically extend the Kubernetes API with CRDs, we will show an example comprising three distinct parts:

  • A protobuf file, in this case api/crdexample.proto, which defines the API resources you want to expose.
  • A types.go file, in this case pkg/apis/crdexample.io/v1/types.go, which defines the CRD API structures and uses the generated Go code from the protobuf file as it's schema.
  • The Kubernetes code generators to generate all the structural pieces necessary to build an application to handle the CRDs. This includes listers, watchers, and informers.

This combination is powerful and shows how extending the Kubernetes API is an effective way to introduce new resources types almost natively.

Running the Example

The example requires a working Kubernetes install. A Minikube install will work just fine.

To build and install the example using go v1.10.x:

make all

To build and install the example using go v1.11.x:

GO111MODULE=on make all

To run the example:

kubectl label --overwrite nodes docker-for-desktop app=crdservice-node
kubectl create -f conf/crd-daemonset.yaml

If you want to stop the example:

kubectl delete -f conf/crd-daemonset.yaml

Updating the Generated Code

To update the generated code:

PATH=$GOPATH/bin:$PATH go generate ./...
CODEGEN_PKG=./vendor/k8s.io/code-generator ./scripts/update-codegen.sh

Directories

Path Synopsis
cmd
crd
netmesh is ...
netmesh is ...
flavors
crdexample
Package crdexample defines flavor used for the netmesh agent.
Package crdexample defines flavor used for the netmesh agent.
pkg
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/crdexample.io/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/versioned/typed/crdexample.io/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
plugins
crd
Package exampleplugincrd implements the example CRD plugin
Package exampleplugincrd implements the example CRD plugin

Jump to

Keyboard shortcuts

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