k8sutils

package
v4.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package k8sutils provides Kubernetes utilities

Package k8sutils provides Kubernetes utilities

Package k8sutils provides Kubernetes utilities

Package k8sutils provides Kubernetes utilities

Index

Constants

View Source
const (
	// TopologyPrefix supported by CSI plugin
	TopologyPrefix = "topology.kubernetes.io"
	// ProtocolTopologyPrefix supported by CSI plugin
	ProtocolTopologyPrefix = TopologyPrefix + "/protocol."
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigmapOps

type ConfigmapOps interface {
	// CreateConfigmap creates the given configmap
	CreateConfigmap(context.Context, *coreV1.ConfigMap) (*coreV1.ConfigMap, error)
	// GetConfigmap gets the configmap object given its name and namespace
	GetConfigmap(context.Context, string, string) (*coreV1.ConfigMap, error)
	// UpdateConfigmap update the configmap object given its name and namespace
	UpdateConfigmap(context.Context, *coreV1.ConfigMap) (*coreV1.ConfigMap, error)
	// DeleteConfigmap delete the configmap object given its name and namespace
	DeleteConfigmap(context.Context, *coreV1.ConfigMap) error
}

ConfigmapOps defines interfaces required by configmap

type Interface

type Interface interface {
	// GetNodeTopology returns configured kubernetes node's topological labels
	GetNodeTopology(ctx context.Context, nodeName string) (map[string]string, error)

	// GetVolume returns volumes on the node at K8S side
	GetVolume(ctx context.Context, nodeName string, driverName string) (map[string]struct{}, error)

	// GetPVByName get all pv info
	GetPVByName(ctx context.Context, name string) (*corev1.PersistentVolume, error)

	// ListPods get pods by namespace
	ListPods(ctx context.Context, namespace string) (*corev1.PodList, error)

	// GetPod get pod by name and namespace
	GetPod(ctx context.Context, namespace, podName string) (*corev1.Pod, error)

	// GetVolumeAttributes returns volume attributes of PV
	GetVolumeAttributes(ctx context.Context, pvName string) (map[string]string, error)

	// Activate the k8s helpers when start the service
	Activate()
	// Deactivate the k8s helpers when stop the service
	Deactivate()

	ConfigmapOps
	// contains filtered or unexported methods
}

Interface is a kubernetes utility interface required by CSI plugin to interact with Kubernetes

func NewK8SUtils

func NewK8SUtils(kubeConfig string, volumeNamePrefix string, volumeLabels map[string]string) (Interface, error)

NewK8SUtils returns an object of Kubernetes utility interface

type KubeClient

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

KubeClient provides a wrapper for kubernetes client interface.

func (*KubeClient) Activate

func (k *KubeClient) Activate()

Activate activate k8s helpers

func (*KubeClient) CreateConfigmap

func (k *KubeClient) CreateConfigmap(ctx context.Context, configmap *coreV1.ConfigMap) (*coreV1.ConfigMap, error)

CreateConfigmap creates the given configmap

func (*KubeClient) CreateSecret

func (k *KubeClient) CreateSecret(ctx context.Context, secret *corev1.Secret) (*corev1.Secret, error)

CreateSecret create secret

func (*KubeClient) Deactivate

func (k *KubeClient) Deactivate()

Deactivate deactivate k8s helpers

func (*KubeClient) DeleteConfigmap

func (k *KubeClient) DeleteConfigmap(ctx context.Context, configmap *coreV1.ConfigMap) error

DeleteConfigmap delete configmap

func (*KubeClient) DeleteSecret

func (k *KubeClient) DeleteSecret(ctx context.Context, secretName, namespace string) error

DeleteSecret delete secret

func (*KubeClient) GetConfigmap

func (k *KubeClient) GetConfigmap(ctx context.Context, name, namespace string) (*coreV1.ConfigMap, error)

GetConfigmap gets the configmap object given its name and namespace

func (*KubeClient) GetNodeTopology

func (k *KubeClient) GetNodeTopology(ctx context.Context, nodeName string) (map[string]string, error)

GetNodeTopology gets topology belonging to this node by node name

func (*KubeClient) GetPVByName

func (k *KubeClient) GetPVByName(ctx context.Context, name string) (*corev1.PersistentVolume, error)

GetPVByName gets the pv by pv name

func (*KubeClient) GetPod

func (k *KubeClient) GetPod(ctx context.Context, namespace, podName string) (*corev1.Pod, error)

GetPod gets a pod by pod name from this namespace

func (*KubeClient) GetSecret

func (k *KubeClient) GetSecret(ctx context.Context, secretName, namespace string) (*corev1.Secret, error)

GetSecret get secret

func (*KubeClient) GetVolume

func (k *KubeClient) GetVolume(ctx context.Context, nodeName string, driverName string) (map[string]struct{}, error)

GetVolume gets all volumes belonging to this node from K8S side

func (*KubeClient) GetVolumeAttributes

func (k *KubeClient) GetVolumeAttributes(ctx context.Context, pvName string) (map[string]string, error)

GetVolumeAttributes returns volume attributes of PV

func (*KubeClient) GetVolumeConfiguration

func (k *KubeClient) GetVolumeConfiguration(ctx context.Context, pvName string) (map[string]string, error)

GetVolumeConfiguration return pvc's annotations

func (*KubeClient) ListPods

func (k *KubeClient) ListPods(ctx context.Context, namespace string) (*corev1.PodList, error)

ListPods lists all pods from this namespace

func (*KubeClient) UpdateConfigmap

func (k *KubeClient) UpdateConfigmap(ctx context.Context, configmap *coreV1.ConfigMap) (*coreV1.ConfigMap, error)

UpdateConfigmap update configmap

func (*KubeClient) UpdateSecret

func (k *KubeClient) UpdateSecret(ctx context.Context, secret *corev1.Secret) (*corev1.Secret, error)

UpdateSecret update secret

Jump to

Keyboard shortcuts

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