k8s

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2019 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsK8sObjectNotExists

func IsK8sObjectNotExists(err error) bool

Types

type PluginManager

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

A generic Plugin for managing k8s-resources. Plugin writers wishing to use K8s resource can use the simplified api specified in pluginmachinery.core

func NewPluginManager

func NewPluginManager(ctx context.Context, iCtx pluginsCore.SetupContext, entry k8s.PluginEntry) (*PluginManager, error)

Creates a K8s generic task executor. This provides an easier way to build task executors that create K8s resources.

Example
sCtx := &pluginsCoreMock.SetupContext{}
fakeKubeClient := mocks.NewFakeKubeClient()
sCtx.On("KubeClient").Return(fakeKubeClient)
sCtx.On("OwnerKind").Return("test")
sCtx.On("EnqueueOwner").Return(pluginsCore.EnqueueOwner(func(name k8stypes.NamespacedName) error { return nil }))
sCtx.On("MetricsScope").Return(promutils.NewTestScope())
exec, err := NewPluginManager(
	context.TODO(),
	sCtx,
	k8s.PluginEntry{
		ID:                  "SampleHandler",
		RegisteredTaskTypes: []pluginsCore.TaskType{"container"},
		ResourceToWatch:     &v1.Pod{},
		Plugin:              k8sSampleHandler{},
	})
if err == nil {
	fmt.Printf("Created executor: %v\n", exec.GetID())
} else {
	fmt.Printf("Error in creating executor: %s\n", err.Error())
}
Output:

Created executor: SampleHandler

func (PluginManager) Abort

func (*PluginManager) CheckResourcePhase

func (*PluginManager) ClearFinalizers

func (e *PluginManager) ClearFinalizers(ctx context.Context, o k8s.Resource) error

func (*PluginManager) Finalize

func (*PluginManager) GetID

func (e *PluginManager) GetID() string

func (*PluginManager) GetProperties

func (e *PluginManager) GetProperties() pluginsCore.PluginProperties

func (PluginManager) Handle

func (*PluginManager) LaunchResource

type PluginMetrics

type PluginMetrics struct {
	Scope           promutils.Scope
	GetCacheMiss    labeled.StopWatch
	GetCacheHit     labeled.StopWatch
	GetAPILatency   labeled.StopWatch
	ResourceDeleted labeled.Counter
}

type PluginPhase

type PluginPhase uint8
const (
	PluginPhaseNotStarted PluginPhase = iota
	PluginPhaseAllocationTokenAcquired
	PluginPhaseStarted
)

type PluginState

type PluginState struct {
	Phase PluginPhase
}

Jump to

Keyboard shortcuts

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