kube

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindNodeRoles

func FindNodeRoles(node *corev1.Node) []string

FindNodeRoles returns the roles of a given node. The roles are determined by looking for: * a node-role.kubernetes.io/<role>="" label * a kubernetes.io/role="<role>" label

func GetObjectsFromYAML

func GetObjectsFromYAML(s, namespace string) (objs []runtime.Object, err error)

GetObjectsFromYAML get actual object from yaml text

func GetScheme

func GetScheme() *runtime.Scheme

GetScheme returns the scheme this project is using

func GetUnstructuredFromYAML

func GetUnstructuredFromYAML(s, namespace string) (objs []*unstructured.Unstructured, err error)

func NodeStatus

func NodeStatus(node *corev1.Node) (status []string)

func PodStatus

func PodStatus(pod *corev1.Pod) (reason string)

PodStatus returns the pod's current status source code: https://github.com/kubernetes/kubernetes/blob/master/pkg/printers/internalversion/printers.go#L740

func RolloutStatus

func RolloutStatus(obj runtime.Object) (msg string, done bool, err error)

RolloutStatus show the rollout status for a deployment/daemonset/statefulset

Types

type Client

type Client interface {
	GetContext() context.Context
	SetContext(ctx context.Context)

	GetRESTConfig() *rest.Config
	GetKubeClient() kubernetes.Interface
	GetDynamicClient() dynamic.Interface
	GetDiscoveryClient() discovery.DiscoveryInterface
	GetRESTMapper() meta.RESTMapper

	// health
	Ping() error

	// types
	ResourceToMapping(gvr schema.GroupVersionResource) (mapping *meta.RESTMapping, err error)
	KindToMapping(gvk schema.GroupVersionKind) (mapping *meta.RESTMapping, err error)
	ModelToMapping(model runtime.Object) (mapping *meta.RESTMapping, err error)

	// resources
	IsReady(obj runtime.Object) (ready bool, err error)
	IsReadyWithUpdate(obj runtime.Object) (ready bool, retObj runtime.Object, err error)
	ListAllResources(namespace string) (objs []unstructured.Unstructured, err error)
}

Client kubernetes client interface

func NewClient

func NewClient() (client Client, err error)

NewClient would try in-cluster then out-cluster, returns the kubernetes client

func NewClientForConfig

func NewClientForConfig(restConfig *rest.Config) (client Client, err error)

NewClientForConfig returns the kubernetes client with rest config

func NewClientInCluster

func NewClientInCluster() (client Client, err error)

NewClientInCluster returns the kubernetes client inside the cluster

func NewClientOutCluster

func NewClientOutCluster(context, kubeconfig string) (client Client, err error)

NewClientOutCluster returns the kubernetes client from the kubeconfig and context out of the cluster

type ClientImpl

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

ClientImpl describes the a kubernetes client

func (*ClientImpl) GetContext

func (c *ClientImpl) GetContext() context.Context

GetContext get current context

func (*ClientImpl) GetDiscoveryClient

func (c *ClientImpl) GetDiscoveryClient() discovery.DiscoveryInterface

GetDiscoveryClient returns the discovery client

func (*ClientImpl) GetDynamicClient

func (c *ClientImpl) GetDynamicClient() dynamic.Interface

GetDynamicClient returns the dynamic client

func (*ClientImpl) GetKubeClient

func (c *ClientImpl) GetKubeClient() kubernetes.Interface

GetKubeClient returns the kubernetes client

func (*ClientImpl) GetRESTConfig

func (c *ClientImpl) GetRESTConfig() *rest.Config

GetRESTConfig returns the REST config

func (*ClientImpl) GetRESTMapper

func (c *ClientImpl) GetRESTMapper() meta.RESTMapper

GetRESTMapper returns the rest mapper

func (*ClientImpl) IsReady

func (c *ClientImpl) IsReady(obj runtime.Object) (ready bool, err error)

IsReady returns whether the runtime object is ready or not

func (*ClientImpl) IsReadyWithUpdate

func (c *ClientImpl) IsReadyWithUpdate(obj runtime.Object) (ready bool, retObj runtime.Object, err error)

IsReadyWithUpdate returns whether the runtime object is ready or not with update

func (*ClientImpl) KindToMapping

func (c *ClientImpl) KindToMapping(gvk schema.GroupVersionKind) (mapping *meta.RESTMapping, err error)

KindToMapping gvk to mapping

func (*ClientImpl) ListAllResources

func (c *ClientImpl) ListAllResources(namespace string) (objs []unstructured.Unstructured, err error)

ListAllResources list all resources within namespace, if namespace is empty, the scale would be all namespaces

func (*ClientImpl) ModelToMapping

func (c *ClientImpl) ModelToMapping(model runtime.Object) (mapping *meta.RESTMapping, err error)

ModelToMapping model to mapping

func (*ClientImpl) Ping

func (c *ClientImpl) Ping() error

Ping returns if the API server is online or not

func (*ClientImpl) ResourceToMapping

func (c *ClientImpl) ResourceToMapping(gvr schema.GroupVersionResource) (mapping *meta.RESTMapping, err error)

ResourceToMapping gvr to mapping

func (*ClientImpl) SetContext

func (c *ClientImpl) SetContext(ctx context.Context)

SetContext set query context

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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