Giter VIP home page Giter VIP logo

crd-example's Introduction

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

crd-example's People

Contributors

mestery avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.