k8sclient

package
v4.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Overview

Package k8sclient is the package that contains the Kubernetes client libraries.

Index

Constants

View Source
const ConfigSourceAnnotationKey = "kubernetes.io/config.source"

ConfigSourceAnnotationKey specifies kubernetes annotation, defined in k8s.io/kubernetes/pkg/kubelet/types

Variables

This section is empty.

Functions

func GetDefaultNetworks

func GetDefaultNetworks(pod *v1.Pod, conf *types.NetConf, kubeClient *ClientInfo, resourceMap map[string]*types.ResourceInfo) (map[string]*types.ResourceInfo, error)

GetDefaultNetworks parses 'defaultNetwork' config, gets network json and put it into netconf.Delegates.

func GetK8sArgs

func GetK8sArgs(args *skel.CmdArgs) (*types.K8sArgs, error)

GetK8sArgs gets k8s related args from CNI args

func GetNetworkDelegates

func GetNetworkDelegates(k8sclient *ClientInfo, pod *v1.Pod, networks []*types.NetworkSelectionElement, conf *types.NetConf, resourceMap map[string]*types.ResourceInfo) ([]*types.DelegateNetConf, error)

GetNetworkDelegates returns delegatenetconf from net-attach-def annotation in pod

func GetPodNetwork

func GetPodNetwork(pod *v1.Pod) ([]*types.NetworkSelectionElement, error)

GetPodNetwork gets net-attach-def annotation from pod

func IsStaticPod

func IsStaticPod(pod *v1.Pod) bool

IsStaticPod returns true if the pod is static pod.

func SetNetworkStatus

func SetNetworkStatus(client *ClientInfo, k8sArgs *types.K8sArgs, netStatus []nettypes.NetworkStatus, conf *types.NetConf) error

SetNetworkStatus sets network status into Pod annotation

func SetPodNetworkStatusAnnotation

func SetPodNetworkStatusAnnotation(client *ClientInfo, podName string, podNamespace string, podUID string, netStatus []nettypes.NetworkStatus, conf *types.NetConf) error

SetPodNetworkStatusAnnotation sets network status into Pod annotation

Types

type ClientInfo

type ClientInfo struct {
	Client           kubernetes.Interface
	NetClient        netclient.Interface
	EventBroadcaster record.EventBroadcaster
	EventRecorder    record.EventRecorder

	// multus-thick uses these informer
	PodInformer    cache.SharedIndexInformer
	NetDefInformer cache.SharedIndexInformer
}

ClientInfo contains information given from k8s client

func GetK8sClient

func GetK8sClient(kubeconfig string, kubeClient *ClientInfo) (*ClientInfo, error)

GetK8sClient gets client info from kubeconfig

func InClusterK8sClient

func InClusterK8sClient() (*ClientInfo, error)

InClusterK8sClient returns the `k8s.ClientInfo` struct to use to connect to the k8s API.

func PerNodeK8sClient added in v4.1.0

func PerNodeK8sClient(nodeName, bootstrapKubeconfigFile string, certDuration time.Duration, certDir string) (*ClientInfo, error)

PerNodeK8sClient creates/reload new multus kubeconfig per-node.

func TryLoadPodDelegates

func TryLoadPodDelegates(pod *v1.Pod, conf *types.NetConf, clientInfo *ClientInfo, resourceMap map[string]*types.ResourceInfo) (int, *ClientInfo, error)

TryLoadPodDelegates attempts to load Kubernetes-defined delegates and add them to the Multus config. Returns the number of Kubernetes-defined delegates added or an error.

func (*ClientInfo) AddNetAttachDef

AddNetAttachDef adds net-attach-def into kubernetes

func (*ClientInfo) AddPod

func (c *ClientInfo) AddPod(pod *v1.Pod) (*v1.Pod, error)

AddPod adds pod into kubernetes

func (*ClientInfo) DeletePod

func (c *ClientInfo) DeletePod(namespace, name string) error

DeletePod deletes a pod from kubernetes

func (*ClientInfo) Eventf

func (c *ClientInfo) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{})

Eventf puts event into kubernetes events

func (*ClientInfo) GetNetAttachDef added in v4.1.0

func (c *ClientInfo) GetNetAttachDef(namespace, name string) (*nettypes.NetworkAttachmentDefinition, error)

GetNetAttachDef get net-attach-def from kubernetes

func (*ClientInfo) GetPod

func (c *ClientInfo) GetPod(namespace, name string) (*v1.Pod, error)

GetPod gets pod from kubernetes

func (*ClientInfo) SetK8sClientInformers added in v4.1.0

func (c *ClientInfo) SetK8sClientInformers(podInformer, netDefInformer cache.SharedIndexInformer)

SetK8sClientInformers adds informer structure to ClientInfo to utilize in thick daemon

type NoK8sNetworkError

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

NoK8sNetworkError indicates error, no network in kubernetes

func (*NoK8sNetworkError) Error

func (e *NoK8sNetworkError) Error() string

Jump to

Keyboard shortcuts

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