k8s

package
v0.0.0-...-250d599 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2021 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrForbidden = errors.New("Forbidden")

Functions

func NormalizeError

func NormalizeError(err error) error

func ObjectType

func ObjectType(o interface{}) string

Types

type Category

type Category string
const (
	CategoryStatefulSet Category = "Stateful Set"
	CategoryDeployment  Category = "Deployment"
	CategoryDaemonSet   Category = "Daemon Set"
	CategoryJob         Category = "Job"
	CategoryCronJob     Category = "Cron Job"
	CategoryService     Category = "Service"
)

func (Category) Plural

func (c Category) Plural() string

type Client

type Client struct {
	*kubernetes.Clientset
	// contains filtered or unexported fields
}

Client provides functions around the k8s clientset api.

func New

func New(ctx context.Context, configPath string) (*Client, error)

New returns a new k8s Client, using the kubeconfig specified by the path, or by reading the KUBECONFIG environment variable.

func NewForConfig

func NewForConfig(ctx context.Context, config *rest.Config) (*Client, error)

func (*Client) DeleteObject

func (c *Client) DeleteObject(ctx context.Context, object ObjectMetaGetter, timeout time.Duration) error

func (*Client) Events

func (c *Client) Events(ctx context.Context, obj ObjectMetaGetter) ([]cv1.Event, error)

func (*Client) Logs

func (c *Client) Logs(ctx context.Context, object ObjectMetaGetter, container string, colors []string) (<-chan []byte, error)

func (*Client) Namespaces

func (c *Client) Namespaces(ctx context.Context) ([]string, error)

func (*Client) PodTree

func (c *Client) PodTree(ctx context.Context, nsName string) (PodTree, error)

func (*Client) PodTreeWatcher

func (c *Client) PodTreeWatcher(ctx context.Context, nsName string) (<-chan PodWatcherEvent, error)

func (*Client) RegisterControllerOperator

func (c *Client) RegisterControllerOperator(kind ControllerType, op ControllerOperator)

func (*Client) RestClient

func (c *Client) RestClient(uri string) (*rest.RESTClient, error)

func (*Client) ResultToObject

func (c *Client) ResultToObject(result rest.Result) (ObjectMetaGetter, error)

func (*Client) ResultToObjectList

func (c *Client) ResultToObjectList(result rest.Result) ([]GenericObj, error)

func (*Client) ScaleDeployment

func (c *Client) ScaleDeployment(ctx context.Context, o Controller, replicas int) error

func (*Client) UpdateObject

func (c *Client) UpdateObject(ctx context.Context, object ObjectMetaGetter, data []byte) error

type Controller

type Controller interface {
	PodManager
	ObjectMetaGetter
	Controller() ObjectMetaGetter
	Category() Category
	Selector() Selector
	DeepCopy() Controller
}

type ControllerDelete

type ControllerDelete func(c *Client, obj ObjectMetaGetter, opts meta.DeleteOptions) error

type ControllerFactory

type ControllerFactory func(o ObjectMetaGetter, tree PodTree) Controller

type ControllerGenerator

type ControllerGenerator func(tree PodTree) Controllers

type ControllerList

type ControllerList func(c *Client, ns string, opts meta.ListOptions) (
	ControllerGenerator, error,
)

type ControllerOperator

type ControllerOperator struct {
	Factory ControllerFactory
	List    ControllerList
	Watch   ControllerWatch
	Update  ControllerUpdate
	Delete  ControllerDelete
}

type ControllerOperators

type ControllerOperators map[ControllerType]ControllerOperator

func (ControllerOperators) Types

func (c ControllerOperators) Types() []ControllerType

type ControllerType

type ControllerType string
const (
	StatefulSetType ControllerType = "StatefulSet"
	DeploymentType  ControllerType = "Deployment"
	DaemonSetType   ControllerType = "DaemonSet"
	JobType         ControllerType = "Job"
	CronJobType     ControllerType = "CronJob"
	ServiceType     ControllerType = "Service"
)

type ControllerUpdate

type ControllerUpdate func(c *Client, obj ObjectMetaGetter) error

type ControllerWatch

type ControllerWatch func(c *Client, ns string, opts meta.ListOptions) (watch.Interface, error)

type Controllers

type Controllers []Controller

func (Controllers) DeepCopy

func (c Controllers) DeepCopy() Controllers

type Ctrl

type Ctrl struct {
	ObjectMetaGetter
	// contains filtered or unexported fields
}

func NewCtrlWithPods

func NewCtrlWithPods(o ObjectMetaGetter, category Category, selector Selector, pods Pods) *Ctrl

func NewGenericCtrl

func NewGenericCtrl(o ObjectMetaGetter, category Category, selector Selector, tree PodTree) *Ctrl

func NewInheritCtrl

func NewInheritCtrl(o ObjectMetaGetter, category Category, tree PodTree) *Ctrl

func (*Ctrl) Category

func (c *Ctrl) Category() Category

func (*Ctrl) Controller

func (c *Ctrl) Controller() ObjectMetaGetter

func (*Ctrl) DeepCopy

func (c *Ctrl) DeepCopy() Controller

func (*Ctrl) Pods

func (c *Ctrl) Pods() Pods

func (*Ctrl) Selector

func (c *Ctrl) Selector() Selector

func (*Ctrl) SetPods

func (c *Ctrl) SetPods(pods Pods)

type ErrMultipleContainers

type ErrMultipleContainers struct {
	Containers []string
	// contains filtered or unexported fields
}

type ErrReason

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

func (ErrReason) Error

func (e ErrReason) Error() string

type GenericObj

type GenericObj struct {
	meta.TypeMeta   `json:",inline"`
	meta.ObjectMeta `json:"metadata,omitempty"`

	Spec   map[string]interface{} `json:"spec,omitempty"`
	Data   map[string]interface{} `json:"data,omitempty"`
	Status map[string]interface{} `json:"status,omitempty"`
	Other  map[string]interface{} `json:"other-unknown,omitempty"`
}

func (*GenericObj) UnmarshalJSON

func (o *GenericObj) UnmarshalJSON(data []byte) error

type GenericObjList

type GenericObjList struct {
	Items []GenericObj `json:"items"`
}

type ObjectMetaGetter

type ObjectMetaGetter interface {
	GetObjectMeta() meta.Object
	GetObjectKind() schema.ObjectKind
}

type PodManager

type PodManager interface {
	Pods() Pods
	SetPods(Pods)
}

type PodTree

type PodTree struct {
	Controllers Controllers
	// contains filtered or unexported fields
}

func (PodTree) DeepCopy

func (p PodTree) DeepCopy() PodTree

type PodWatcherEvent

type PodWatcherEvent struct {
	Tree      PodTree
	EventType watch.EventType
}

type Pods

type Pods []*cv1.Pod

func (Pods) AddSlice

func (p Pods) AddSlice(pods []cv1.Pod) Pods

type Selector

type Selector map[string]string

type UnsupportedObjectError

type UnsupportedObjectError struct {
	TypeName string
}

func (UnsupportedObjectError) Error

func (e UnsupportedObjectError) Error() string

Jump to

Keyboard shortcuts

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