k8sclient

package
v4.0.2 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 27 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.K8sCniCncfIoV1Interface
	EventBroadcaster record.EventBroadcaster
	EventRecorder    record.EventRecorder
}

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 NewClientInfo

func NewClientInfo(config *rest.Config) (*ClientInfo, error)

NewClientInfo returns a `ClientInfo` from a configuration created from an existing kubeconfig file.

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) GetPod

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

GetPod gets pod from kubernetes

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