kube

package
v0.0.0-...-6f6f2b9 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeKubeObj

func DecodeKubeObj(yml []byte) (k8sruntime.Object, *schema.GroupVersionKind, error)

DecodeKubeObj decode kubernetes object from yaml

func PatchImage

func PatchImage(deployment *appsv1.Deployment, image string) ([]byte, error)

PatchImage reutn bytes for a StrategicMergePatch of deployment

Types

type Client

type Client struct {
	*PodBox
	*EventBox
	*DeploymentBox
	*ServiceBox
	*StatefulSetBox
}

Client contains all kube resource client

func GetClient

func GetClient() (*Client, error)

GetClient get all kube resource client.

type DeploymentBox

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

DeploymentBox provide functions for kubernetes deployment.

func NewDeploymentBoxWithClient

func NewDeploymentBoxWithClient(c *clientset.Interface) *DeploymentBox

NewDeploymentBoxWithClient creates a DeploymentBox

func (*DeploymentBox) Create

func (b *DeploymentBox) Create(deployment *appsv1.Deployment, namespace string) (*appsv1.Deployment, error)

Create creates a deployment

func (*DeploymentBox) Delete

func (b *DeploymentBox) Delete(name, namespace string) error

Delete delete deployment

func (*DeploymentBox) Exists

func (b *DeploymentBox) Exists(name, namespace string) (bool, error)

Exists check if deployment exists.

func (*DeploymentBox) Get

func (b *DeploymentBox) Get(name, namespace string) (*appsv1.Deployment, error)

Get get specified deployment in specified namespace.

func (*DeploymentBox) GetLatestReplicaSet

func (b *DeploymentBox) GetLatestReplicaSet(name, namespace string) (*appsv1.Deployment, string, error)

GetLatestReplicaSet get latest replicaSet of deployment

func (*DeploymentBox) GetPods

func (b *DeploymentBox) GetPods(name, namespace string) (*corev1.PodList, error)

GetPods get pods of deployment

func (*DeploymentBox) List

func (b *DeploymentBox) List(namespace string) (*appsv1.DeploymentList, error)

List list deployments in specified namespace.

func (*DeploymentBox) Patch

func (b *DeploymentBox) Patch(name, namespace string, data []byte) (*appsv1.Deployment, error)

Patch patch deployment

func (*DeploymentBox) Scale

func (b *DeploymentBox) Scale(name, namespace string, replicas int32) error

Scale scale deployment replicas

func (*DeploymentBox) Watch

func (b *DeploymentBox) Watch(namespace, labelSelector string, timeoutSeconds *int64) (watch.Interface, error)

Watch watch deployment in specified namespace with timeoutSeconds

func (*DeploymentBox) WatchDeployment

func (b *DeploymentBox) WatchDeployment(namespace, deploymentName string, timeoutSeconds *int64) (watch.Interface, error)

WatchDeployment watch specified deployment in specified namespace with timeoutSeconds

type EventBox

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

EventBox provide functions for kubernetes event.

func (*EventBox) Search

func (b *EventBox) Search(namespace string, obj runtime.Object) (*corev1.EventList, error)

Search search events with labelselectors

type PodBox

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

PodBox provide functions for kubernetes pod.

func NewPodBoxWithClient

func NewPodBoxWithClient(c *clientset.Interface) *PodBox

NewPodBoxWithClient creates a PodBox

func (*PodBox) Create

func (b *PodBox) Create(pod *corev1.Pod, namespace string) (*corev1.Pod, error)

Create creates a pod

func (*PodBox) Delete

func (b *PodBox) Delete(name, namespace string) error

Delete delete pod

func (*PodBox) Exec

func (b *PodBox) Exec(cmd []string, ptyHandler terminal.PtyHandler, namespace, podName, containerName string) error

Exec exec into a pod

func (*PodBox) Exists

func (b *PodBox) Exists(name, namespace string) (bool, error)

Exists check if pod exists.

func (*PodBox) Get

func (b *PodBox) Get(name, namespace string) (*corev1.Pod, error)

Get get specified pod in specified namespace.

func (*PodBox) List

func (b *PodBox) List(namespace, labelSelector string) (*corev1.PodList, error)

List list pods in specified namespace.

func (*PodBox) LogStream

func (b *PodBox) LogStream(name, namespace string, opts *corev1.PodLogOptions, writer io.Writer) error

LogStream get logs of specified pod in specified namespace and copy to writer.

func (*PodBox) LogStreamLine

func (b *PodBox) LogStreamLine(name, namespace string, opts *corev1.PodLogOptions, writer io.Writer) error

LogStreamLine get logs of specified pod in specified namespace and copy to writer.

func (*PodBox) Logs

func (b *PodBox) Logs(name, namespace string, opts *corev1.PodLogOptions) *restclient.Request

Logs get logs of specified pod in specified namespace.

func (*PodBox) Watch

func (b *PodBox) Watch(namespace string, timeoutSeconds *int64, labelSelector string) (watch.Interface, error)

Watch watch pod in specified namespace with timeoutSeconds

func (*PodBox) WatchPod

func (b *PodBox) WatchPod(namespace, podName string, timeoutSeconds *int64) (watch.Interface, error)

WatchPod watch specified pod in specified namespace with timeoutSeconds

type ServiceBox

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

ServiceBox provide functions for kubernetes service.

func (*ServiceBox) Create

func (s *ServiceBox) Create(service *corev1.Service, namespace string) (*corev1.Service, error)

Create creates a service

func (*ServiceBox) Delete

func (s *ServiceBox) Delete(name, namespace string) error

Delete delete service

func (*ServiceBox) Exists

func (s *ServiceBox) Exists(name, namespace string) (bool, error)

Exists check if service exists.

func (*ServiceBox) Get

func (s *ServiceBox) Get(name, namespace string) (*corev1.Service, error)

Get get specified service in specified namespace.

func (*ServiceBox) List

func (s *ServiceBox) List(namespace string) (*corev1.ServiceList, error)

List list services in specified namespace.

type StatefulSetBox

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

StatefulSetBox provide functions for kubernetes statefulset.

func NewStatefulSetBoxWithClient

func NewStatefulSetBoxWithClient(c *clientset.Interface) *StatefulSetBox

NewStatefulSetBoxWithClient creates a statefulsetBox

func (*StatefulSetBox) Create

func (b *StatefulSetBox) Create(statefulset *appsv1.StatefulSet, namespace string) (*appsv1.StatefulSet, error)

Create creates a sts

func (*StatefulSetBox) Delete

func (b *StatefulSetBox) Delete(name, namespace string) error

Delete delete sts

func (*StatefulSetBox) Exists

func (b *StatefulSetBox) Exists(name, namespace string) (bool, error)

Exists check if statefulset exists.

func (*StatefulSetBox) Get

func (b *StatefulSetBox) Get(name, namespace string) (*appsv1.StatefulSet, error)

Get get specified statefulset in specified namespace.

func (*StatefulSetBox) GetLatestReplicaSet

func (b *StatefulSetBox) GetLatestReplicaSet(name, namespace string) (*appsv1.StatefulSet, string, error)

GetLatestReplicaSet get latest replicaSet of sts

func (*StatefulSetBox) List

func (b *StatefulSetBox) List(namespace string) (*appsv1.StatefulSetList, error)

List list statefulsets in specified namespace.

func (*StatefulSetBox) ListWithSelector

func (b *StatefulSetBox) ListWithSelector(namespace, labelSelector string) (*appsv1.StatefulSetList, error)

ListWithSelector list statefulsets in specified namespace.

func (*StatefulSetBox) Patch

func (b *StatefulSetBox) Patch(name, namespace string, data []byte) (*appsv1.StatefulSet, error)

Patch patch sts

func (*StatefulSetBox) Watch

func (b *StatefulSetBox) Watch(namespace, labelSelector string, timeoutSeconds *int64) (watch.Interface, error)

Watch watch sts in specified namespace with timeoutSeconds

func (*StatefulSetBox) WatchStatefulSetBox

func (b *StatefulSetBox) WatchStatefulSetBox(namespace, stsName string, timeoutSeconds *int64) (watch.Interface, error)

WatchStatefulSetBox watch specified sts in specified namespace with timeoutSeconds

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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