kubernetes

package
v0.19.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRuntimeClientFromFileName added in v0.14.0

func NewRuntimeClientFromFileName(kubeConfigFilename string) (client.Client, error)

NewRuntimeClientFromFileName creates a new controller runtime client given a kubeconfig filename.

func ObjectsToRuntimeObjects added in v0.17.0

func ObjectsToRuntimeObjects[T runtime.Object](objs []T) []runtime.Object

ObjectsToRuntimeObjects converts objects of another type to runtime.Object's.

Types

type ApplyServerSideOption added in v0.18.0

type ApplyServerSideOption interface {
	ApplyToApplyServerSide(*ApplyServerSideOptions)
}

ApplyServerSideOption is some configuration that modifies options for an apply request.

type ApplyServerSideOptions added in v0.18.0

type ApplyServerSideOptions struct {
	// ForceOwnership indicates that in case of conflicts with server-side apply,
	// the client should acquire ownership of the conflicting field.
	ForceOwnership bool
}

ApplyServerSideOptions contains options for server side apply requests.

func (ApplyServerSideOptions) ApplyToApplyServerSide added in v0.18.0

func (o ApplyServerSideOptions) ApplyToApplyServerSide(do *ApplyServerSideOptions)

ApplyToApplyServerSide implements ApplyServerSideOption.

type Client

type Client interface {
	Reader
	Writer
}

Client is Kubernetes API client.

type ClientFactory added in v0.15.0

type ClientFactory struct{}

ClientFactory builds clients from a kubeconfig file by wrapping around NewRuntimeClientFromFileName to facilitate mocking.

func (ClientFactory) BuildClientFromKubeconfig added in v0.15.0

func (f ClientFactory) BuildClientFromKubeconfig(kubeconfigPath string) (client.Client, error)

BuildClientFromKubeconfig builds a K8s client from a kubeconfig file.

type DeleteAllOfOption added in v0.15.2

type DeleteAllOfOption interface {
	// ApplyToDeleteAllOf applies this configuration to the given deletecollection options.
	ApplyToDeleteAllOf(*DeleteAllOfOptions)
}

DeleteAllOfOption is some configuration that modifies options for a delete request.

type DeleteAllOfOptions added in v0.15.2

type DeleteAllOfOptions struct {
	// HasLabels filters results by label and value. The requirement is an AND match
	// for all labels.
	HasLabels map[string]string

	// Namespace represents the namespace to list for, or empty for
	// non-namespaced objects, or to list across all namespaces.
	Namespace string
}

DeleteAllOfOptions contains options for deletecollection (deleteallof) requests.

func (*DeleteAllOfOptions) ApplyToDeleteAllOf added in v0.15.2

func (o *DeleteAllOfOptions) ApplyToDeleteAllOf(do *DeleteAllOfOptions)

ApplyToDeleteAllOf implements DeleteAllOfOption.

type KubeconfigClient

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

KubeconfigClient is an authenticated kubernetes API client it authenticates using the credentials of a kubeconfig file.

func NewKubeconfigClient

func NewKubeconfigClient(client *UnAuthClient, kubeconfig string) *KubeconfigClient

func (*KubeconfigClient) ApplyServerSide added in v0.18.0

func (c *KubeconfigClient) ApplyServerSide(ctx context.Context, fieldManager string, obj Object, opts ...ApplyServerSideOption) error

ApplyServerSide creates or patches and object using server side logic.

func (*KubeconfigClient) Create added in v0.15.2

func (c *KubeconfigClient) Create(ctx context.Context, obj Object) error

Create saves the object obj in the Kubernetes cluster.

func (*KubeconfigClient) Delete added in v0.15.2

func (c *KubeconfigClient) Delete(ctx context.Context, obj Object) error

Delete deletes the given obj from Kubernetes cluster.

func (*KubeconfigClient) DeleteAllOf added in v0.15.2

func (c *KubeconfigClient) DeleteAllOf(ctx context.Context, obj Object, opts ...DeleteAllOfOption) error

DeleteAllOf deletes all objects of the given type matching the given options.

func (*KubeconfigClient) Get

func (c *KubeconfigClient) Get(ctx context.Context, name, namespace string, obj Object) error

Get performs a GET call to the kube API server and unmarshalls the response into the provided Object.

func (*KubeconfigClient) List added in v0.15.2

func (c *KubeconfigClient) List(ctx context.Context, list ObjectList) error

List retrieves list of objects. On a successful call, Items field in the list will be populated with the result returned from the server.

func (*KubeconfigClient) Update added in v0.15.2

func (c *KubeconfigClient) Update(ctx context.Context, obj Object) error

Update updates the given obj in the Kubernetes cluster.

type Kubectl added in v0.15.2

type Kubectl interface {
	Get(ctx context.Context, resourceType, kubeconfig string, obj runtime.Object, opts ...KubectlGetOption) error
	Create(ctx context.Context, kubeconfig string, obj runtime.Object) error
	Replace(ctx context.Context, kubeconfig string, obj runtime.Object) error
	Apply(ctx context.Context, kubeconfig string, obj runtime.Object, opts ...KubectlApplyOption) error
	Delete(ctx context.Context, resourceType, kubeconfig string, opts ...KubectlDeleteOption) error
}

Kubectl is a client implemented with the kubectl binary.

type KubectlApplyOption added in v0.18.0

type KubectlApplyOption interface {
	// ApplyToApply applies this configuration to the given apply options.
	ApplyToApply(*KubectlApplyOptions)
}

KubectlApplyOption is some configuration that modifies options for an apply command.

type KubectlApplyOptions added in v0.18.0

type KubectlApplyOptions struct {
	// ServerSide configures kubectl so apply runs in the server instead of the client.
	ServerSide bool

	// ForceOwnership indicates that in case of conflicts with server-side apply,
	// kubectl should acquire ownership of the conflicting field.
	ForceOwnership bool

	// FieldManager sets the field owner name for the given server-side apply.
	FieldManager string
}

KubectlApplyOptions contains options for apply command.

func (KubectlApplyOptions) ApplyToApply added in v0.18.0

func (o KubectlApplyOptions) ApplyToApply(kao *KubectlApplyOptions)

ApplyToApply applies this configuration to the given apply options.

type KubectlDeleteOption added in v0.15.2

type KubectlDeleteOption interface {
	// ApplyToDelete applies this configuration to the given delete options.
	ApplyToDelete(*KubectlDeleteOptions)
}

KubectlDeleteOption is some configuration that modifies options for a delete command.

type KubectlDeleteOptions added in v0.15.2

type KubectlDeleteOptions struct {
	// Name specifies the name of a resource. Use to delete a single resource.
	// If set, Namespace is required.
	Name string

	// Namespace specifies the namespace to delete objects from. If not set,
	// all namespaces will be used.
	Namespace string

	// HasLabels applies a filter using labels to the objects to be deleted.
	// When multiple label-value pairs are specified, the condition is an AND
	// for all of them. If specified, Name should be empty.
	HasLabels map[string]string
}

KubectlDeleteOptions contains options for delete commands.

func (*KubectlDeleteOptions) ApplyToDelete added in v0.15.2

func (o *KubectlDeleteOptions) ApplyToDelete(kdo *KubectlDeleteOptions)

ApplyToDelete applies this configuration to the given delete options.

type KubectlGetOption added in v0.15.2

type KubectlGetOption interface {
	// ApplyToGet applies this configuration to the given get options.
	ApplyToGet(*KubectlGetOptions)
}

KubectlGetOption is some configuration that modifies options for a get request.

type KubectlGetOptions added in v0.15.2

type KubectlGetOptions struct {
	// Name specifies the name of a resource. If set, only one single resource
	// will be returned (at most). If set, Namespace is required.
	Name string

	// Namespace specifies the namespace to retrieve objects from. If not set,
	// all namespaces will be used.
	Namespace string

	// ClusterScoped identifies the resourced as no namespaced. This is mutually exclusive with
	// Namespace and requires to also specify a Name.
	ClusterScoped *bool
}

KubectlGetOptions contains options for get commands.

func (*KubectlGetOptions) ApplyToGet added in v0.15.2

func (o *KubectlGetOptions) ApplyToGet(kgo *KubectlGetOptions)

ApplyToGet applies this configuration to the given get options.

type Object added in v0.9.2

type Object client.Object

Object is a Kubernetes object.

type ObjectList added in v0.12.0

type ObjectList client.ObjectList

ObjectList is a Kubernetes object list.

type Reader added in v0.15.2

type Reader interface {
	// Get retrieves an obj for the given name and namespace from the Kubernetes Cluster.
	Get(ctx context.Context, name, namespace string, obj Object) error

	// List retrieves list of objects. On a successful call, Items field
	// in the list will be populated with the result returned from the server.
	List(ctx context.Context, list ObjectList) error
}

Reader knows how to read and list Kubernetes objects.

type UnAuthClient

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

UnAuthClient is a generic kubernetes API client that takes a kubeconfig file on every call in order to authenticate.

func NewUnAuthClient

func NewUnAuthClient(kubectl Kubectl) *UnAuthClient

NewUnAuthClient builds a new UnAuthClient.

func (*UnAuthClient) Apply added in v0.12.0

func (c *UnAuthClient) Apply(ctx context.Context, kubeconfig string, obj runtime.Object) error

Apply performs an upsert in the form of a client-side apply.

func (*UnAuthClient) ApplyServerSide added in v0.18.0

func (c *UnAuthClient) ApplyServerSide(ctx context.Context, kubeconfig, fieldManager string, obj Object, opts ...ApplyServerSideOption) error

ApplyServerSide creates or patches and object using server side logic.

func (*UnAuthClient) BuildClientFromKubeconfig added in v0.15.2

func (c *UnAuthClient) BuildClientFromKubeconfig(kubeconfig string) (Client, error)

BuildClientFromKubeconfig returns an equivalent authenticated client. It will never return an error but this helps satisfy a generic factory interface where errors are possible. It's basically an alias to KubeconfigClient.

func (*UnAuthClient) Create added in v0.15.2

func (c *UnAuthClient) Create(ctx context.Context, kubeconfig string, obj Object) error

Create saves the object obj in the Kubernetes cluster.

func (*UnAuthClient) Delete

func (c *UnAuthClient) Delete(ctx context.Context, kubeconfig string, obj Object) error

Delete deletes the given obj from Kubernetes cluster.

func (*UnAuthClient) DeleteAllOf added in v0.15.2

func (c *UnAuthClient) DeleteAllOf(ctx context.Context, kubeconfig string, obj Object, opts ...DeleteAllOfOption) error

DeleteAllOf deletes all objects of the given type matching the given options.

func (*UnAuthClient) Get

func (c *UnAuthClient) Get(ctx context.Context, name, namespace, kubeconfig string, obj runtime.Object) error

Get performs a GET call to the kube API server authenticating with a kubeconfig file and unmarshalls the response into the provdied Object.

func (*UnAuthClient) Init

func (c *UnAuthClient) Init() error

Init initializes the client internal API scheme It has always be invoked at least once before making any API call It is not thread safe.

func (*UnAuthClient) KubeconfigClient

func (c *UnAuthClient) KubeconfigClient(kubeconfig string) Client

KubeconfigClient returns an equivalent authenticated client.

func (*UnAuthClient) List added in v0.15.2

func (c *UnAuthClient) List(ctx context.Context, kubeconfig string, list ObjectList) error

List retrieves list of objects. On a successful call, Items field in the list will be populated with the result returned from the server.

func (*UnAuthClient) Update added in v0.15.2

func (c *UnAuthClient) Update(ctx context.Context, kubeconfig string, obj Object) error

Update updates the given obj in the Kubernetes cluster.

type Writer added in v0.15.2

type Writer interface {
	// Create saves the object obj in the Kubernetes cluster.
	Create(ctx context.Context, obj Object) error

	// Update updates the given obj in the Kubernetes cluster.
	Update(ctx context.Context, obj Object) error

	// ApplyServerSide creates or patches and object using server side logic.
	ApplyServerSide(ctx context.Context, fieldManager string, obj Object, opts ...ApplyServerSideOption) error

	// Delete deletes the given obj from Kubernetes cluster.
	Delete(ctx context.Context, obj Object) error

	// DeleteAllOf deletes all objects of the given type matching the given options.
	DeleteAllOf(ctx context.Context, obj Object, opts ...DeleteAllOfOption) error
}

Writer knows how to create, delete, and update Kubernetes objects.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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