Documentation ¶
Overview ¶
Package k8sutils provides Kubernetes utilities
Package k8sutils provides Kubernetes utilities ¶
Package k8sutils provides Kubernetes utilities ¶
Package k8sutils provides Kubernetes utilities ¶
Package k8sutils provides Kubernetes utilities ¶
Package k8sutils provides Kubernetes utilities
Index ¶
- Constants
- func WithHandler[T runtime.Object](handler cache.ResourceEventHandlerFuncs) func(*ResourceAccessor[T]) error
- func WithIndexers[T runtime.Object](indexers cache.Indexers) func(*ResourceAccessor[T]) error
- func WithTransformer[T runtime.Object](transform cache.TransformFunc) func(*ResourceAccessor[T]) error
- type ConfigmapOps
- type Interface
- type KubeClient
- func (k *KubeClient) Activate()
- func (k *KubeClient) CreateConfigmap(ctx context.Context, configmap *coreV1.ConfigMap) (*coreV1.ConfigMap, error)
- func (k *KubeClient) CreateSecret(ctx context.Context, secret *corev1.Secret) (*corev1.Secret, error)
- func (k *KubeClient) Deactivate()
- func (k *KubeClient) DeleteConfigmap(ctx context.Context, configmap *coreV1.ConfigMap) error
- func (k *KubeClient) DeleteSecret(ctx context.Context, secretName, namespace string) error
- func (k *KubeClient) GetConfigmap(ctx context.Context, name, namespace string) (*coreV1.ConfigMap, error)
- func (k *KubeClient) GetNodeTopology(ctx context.Context, nodeName string) (map[string]string, error)
- func (k *KubeClient) GetPVByName(ctx context.Context, name string) (*corev1.PersistentVolume, error)
- func (k *KubeClient) GetPod(ctx context.Context, namespace, podName string) (*corev1.Pod, error)
- func (k *KubeClient) GetSecret(ctx context.Context, secretName, namespace string) (*corev1.Secret, error)
- func (k *KubeClient) GetVolume(ctx context.Context, nodeName string, driverName string) (map[string]struct{}, error)
- func (k *KubeClient) GetVolumeAttrByVolumeId(volumeId string) (map[string]string, error)
- func (k *KubeClient) GetVolumeAttributes(ctx context.Context, pvName string) (map[string]string, error)
- func (k *KubeClient) GetVolumeConfiguration(ctx context.Context, pvName string) (map[string]string, error)
- func (k *KubeClient) ListPods(ctx context.Context, namespace string) (*corev1.PodList, error)
- func (k *KubeClient) UpdateConfigmap(ctx context.Context, configmap *coreV1.ConfigMap) (*coreV1.ConfigMap, error)
- func (k *KubeClient) UpdateSecret(ctx context.Context, secret *corev1.Secret) (*corev1.Secret, error)
- type ResourceAccessor
Constants ¶
const ( // TopologyPrefix supported by CSI plugin TopologyPrefix = "topology.kubernetes.io" // ProtocolTopologyPrefix supported by CSI plugin ProtocolTopologyPrefix = TopologyPrefix + "/protocol." )
Variables ¶
This section is empty.
Functions ¶
func WithHandler ¶
func WithHandler[T runtime.Object](handler cache.ResourceEventHandlerFuncs) func(*ResourceAccessor[T]) error
WithHandler sets event handler for the resource.
func WithIndexers ¶
WithIndexers sets indexers for the resource.
func WithTransformer ¶
func WithTransformer[T runtime.Object](transform cache.TransformFunc) func(*ResourceAccessor[T]) error
WithTransformer sets transformer for the resource.
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) // GetVolumeAttrByVolumeId returns volume attributes of PV from volume id GetVolumeAttrByVolumeId(volumeId 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
type KubeClient ¶
type KubeClient struct {
// contains filtered or unexported fields
}
KubeClient provides a wrapper for kubernetes client interface.
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) DeleteConfigmap ¶
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) 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) GetVolumeAttrByVolumeId ¶
func (k *KubeClient) GetVolumeAttrByVolumeId(volumeId string) (map[string]string, error)
GetVolumeAttrByVolumeId returns volume attributes of PV by volume id
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) 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
type ResourceAccessor ¶
ResourceAccessor provides the methods to get kubernetes resource.
func NewResourceAccessor ¶
func NewResourceAccessor[T runtime.Object](informer cache.SharedIndexInformer, options ...func(*ResourceAccessor[T]) error) (*ResourceAccessor[T], error)
NewResourceAccessor returns a ResourceAccessor instance.
func (*ResourceAccessor[T]) GetByIndex ¶
func (rw *ResourceAccessor[T]) GetByIndex(indexName, indexValue string) (T, error)
GetByIndex gets resource by index. To use this method, you must add the indexer first.