customresource

package
v0.0.0-...-e889ff3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrVersionOutdated indicates that the custom resource is outdated and needs to be refreshed
	ErrVersionOutdated = errors.New("requested version is outdated in apiserver")
)

Functions

func CreateCustomResources

func CreateCustomResources(context Context, resources []CustomResource) error

CreateCustomResources creates the given custom resources and waits for them to initialize The resource is of kind CRD if the Kubernetes server is 1.7.0 and above. The resource is of kind TPR if the Kubernetes server is below 1.7.0.

Types

type Context

type Context struct {
	Clientset             kubernetes.Interface
	APIExtensionClientset apiextensionsclient.Interface
	Interval              time.Duration
	Timeout               time.Duration
	Context               contextpkg.Context
}

Context hold the clientsets used for creating and watching custom resources

type CustomResource

type CustomResource struct {
	// Name of the custom resource
	Name string

	// Plural of the custom resource in plural
	Plural string

	// Group the custom resource belongs to
	Group string

	// Version which should be defined in a const above
	Version string

	// Scope of the CRD. Namespaced or cluster
	Scope apiextensionsv1.ResourceScope

	// Kind is the serialized interface of the resource.
	Kind string
}

CustomResource is for creating a Kubernetes TPR/CRD

type ResourceWatcher

type ResourceWatcher struct {
	// contains filtered or unexported fields
}

ResourceWatcher watches a custom resource for desired state

func NewWatcher

func NewWatcher(resource CustomResource, namespace string, handlers cache.ResourceEventHandlerFuncs, client rest.Interface) *ResourceWatcher

NewWatcher creates an instance of a custom resource watcher for the given resource

func (*ResourceWatcher) Watch

func (w *ResourceWatcher) Watch(objType runtime.Object, done <-chan struct{})

Watch begins watching the custom resource (TPR/CRD). The call will block until a Done signal is raised during in the context. When the watch has detected a create, update, or delete event, it will handled by the functions in the resourceEventHandlers. After the callback returns, the watch loop will continue for the next event. If the callback returns an error, the error will be logged.

Jump to

Keyboard shortcuts

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