k8s-api-pager-demo

module
v0.0.0-...-c4470db Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2017 License: MIT

README

Kubernetes custom API types Pager demo

This repository contains a demo application showing how you can use the Kubernetes generator applications to automatically create supporting code for your own apiserver or controller component.

It implements a very simple controller that will watch for 'Alert' resources, and fire Pushbullet alerts for any unsent alerts in the API.

You can see the automation for generating the required code in the Makefile, and in hack/update-client-gen.sh script.

Generating code

If you change any API types, you must regenerate all of the supporting code. This can be done by using the generate make target, e.g.

$ make generate

The generators tend not to error even if something you may consider to be a problem occurs, thus it's important to ensure you can still build your application after running the generators.

Building

The actual golang app can be built with a simple go build. The generated files required are committed to the repo to ensure it stays in sync. We should also use a verify step to ensure that the generated files are in sync with their respective types.go files, but for brevity have omitted that here.

$ go build

Running

To run this demo, you will need a Pushbullet account. You can sign up for free on their website. Once done, you will need to create yourself an API key before running the application as follows:

$ ./k8s-api-pager-demo -pushbullet-token 'token-goes-here'

Optionally, you can set the -apiserver flag too. This particular demo will not automatically detect credentials for the API server if it is running within a cluster, once again for brevity.

Once started, you will also need to create the CustomResourceDefinition in the target API server, as we have not implemented our own API server in this repo.

$ kubectl create -f docs/crd.yaml

Then we can go ahead and create an Alert!

$ kubectl create -f docs/test-alert.yaml

Directories

Path Synopsis
cmd
pkg
apis/pager
Package api is the internal version of the API.
Package api is the internal version of the API.
apis/pager/install
Package install installs the experimental API group, making it available as an option to all of the API encoding/decoding machinery.
Package install installs the experimental API group, making it available as an option to all of the API encoding/decoding machinery.
apis/pager/v1alpha1
Package v1alpha1 is the v1alpha1 version of the API.
Package v1alpha1 is the v1alpha1 version of the API.
apis/pager/v1beta1
Package v1beta1 is the v1beta1 version of the API.
Package v1beta1 is the v1beta1 version of the API.
client/clientset/internalversion
This package has the automatically generated clientset.
This package has the automatically generated clientset.
client/clientset/internalversion/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
client/clientset/internalversion/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
client/clientset/internalversion/typed/pager/internalversion
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/internalversion/typed/pager/internalversion/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
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/pager/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/versioned/typed/pager/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
client/clientset/versioned/typed/pager/v1beta1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/versioned/typed/pager/v1beta1/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