k8scloudoperator

package
v3.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// StoragePoolAnnotationKey is a PVC annotation to specify the StoragePool
	// on which PV should be placed.
	StoragePoolAnnotationKey = "failure-domain.beta.vmware.com/storagepool"
	// ScNameAnnotationKey is a PVC annotation to specify storage class from
	// which PV should be provisioned.
	ScNameAnnotationKey = "volume.beta.kubernetes.io/storage-class"
)

Variables

This section is empty.

Functions

func GetSCNameFromPVC

func GetSCNameFromPVC(pvc *v1.PersistentVolumeClaim) (string, error)

GetSCNameFromPVC gets name of the storage class from provided PVC.

func GetSVMotionPlan

func GetSVMotionPlan(ctx context.Context, client kubernetes.Interface,
	storagePoolName string, maintenanceMode string) (map[string]string, error)

GetSVMotionPlan when decommissioning a SP, maps all the volumes present on the given SP to a suitable SP to migrate into. To reduce the friction to onboard new partners, the workflow for disk deconmmission does not involve partner participation. Eg. decommissioning a disk with "ensureAccessibility" MM, information of which volume can remain on the disk while ensuring accessibility is present only with the partner operator. Hence the svMotion plan generated is same for all maintenance mode provided and equivalent to "evacuateAll" MM. Once we move towards more deep integration between our partner and PSP, we will be able to communicate with partner to get only the necessary migrations for a given MM (for eg. "ensureAccessibility").

func InitK8sCloudOperatorService

func InitK8sCloudOperatorService(ctx context.Context) error

InitK8sCloudOperatorService initializes the K8s Cloud Operator Service.

func PlacePVConStoragePool

func PlacePVConStoragePool(ctx context.Context, client kubernetes.Interface,
	tops *csi.TopologyRequirement, curPVC *v1.PersistentVolumeClaim, spType string) error

PlacePVConStoragePool selects target storage pool to place the given PVC based on its profile and the topology information. If the placement is successful, the PVC will be annotated with the selected storage pool and PlacePVConStoragePool nil that means no error. For unsuccessful placement, PlacePVConStoragePool returns error that cause the failure.

func RegisterK8SCloudOperatorServer

func RegisterK8SCloudOperatorServer(s *grpc.Server, srv K8SCloudOperatorServer)

Types

type HostAnnotationRequest

type HostAnnotationRequest struct {
	// Name of the host
	HostName string `protobuf:"bytes,1,opt,name=hostName,proto3" json:"hostName,omitempty"`
	// Name of the annotation key of interest
	AnnotationKey        string   `protobuf:"bytes,2,opt,name=annotationKey,proto3" json:"annotationKey,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*HostAnnotationRequest) Descriptor

func (*HostAnnotationRequest) Descriptor() ([]byte, []int)

func (*HostAnnotationRequest) GetAnnotationKey

func (m *HostAnnotationRequest) GetAnnotationKey() string

func (*HostAnnotationRequest) GetHostName

func (m *HostAnnotationRequest) GetHostName() string

func (*HostAnnotationRequest) ProtoMessage

func (*HostAnnotationRequest) ProtoMessage()

func (*HostAnnotationRequest) Reset

func (m *HostAnnotationRequest) Reset()

func (*HostAnnotationRequest) String

func (m *HostAnnotationRequest) String() string

func (*HostAnnotationRequest) XXX_DiscardUnknown

func (m *HostAnnotationRequest) XXX_DiscardUnknown()

func (*HostAnnotationRequest) XXX_Marshal

func (m *HostAnnotationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*HostAnnotationRequest) XXX_Merge

func (m *HostAnnotationRequest) XXX_Merge(src proto.Message)

func (*HostAnnotationRequest) XXX_Size

func (m *HostAnnotationRequest) XXX_Size() int

func (*HostAnnotationRequest) XXX_Unmarshal

func (m *HostAnnotationRequest) XXX_Unmarshal(b []byte) error

type HostAnnotationResponse

type HostAnnotationResponse struct {
	// Value of the annotation key on the node `hostName`
	AnnotationValue      string   `protobuf:"bytes,2,opt,name=annotationValue,proto3" json:"annotationValue,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*HostAnnotationResponse) Descriptor

func (*HostAnnotationResponse) Descriptor() ([]byte, []int)

func (*HostAnnotationResponse) GetAnnotationValue

func (m *HostAnnotationResponse) GetAnnotationValue() string

func (*HostAnnotationResponse) ProtoMessage

func (*HostAnnotationResponse) ProtoMessage()

func (*HostAnnotationResponse) Reset

func (m *HostAnnotationResponse) Reset()

func (*HostAnnotationResponse) String

func (m *HostAnnotationResponse) String() string

func (*HostAnnotationResponse) XXX_DiscardUnknown

func (m *HostAnnotationResponse) XXX_DiscardUnknown()

func (*HostAnnotationResponse) XXX_Marshal

func (m *HostAnnotationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*HostAnnotationResponse) XXX_Merge

func (m *HostAnnotationResponse) XXX_Merge(src proto.Message)

func (*HostAnnotationResponse) XXX_Size

func (m *HostAnnotationResponse) XXX_Size() int

func (*HostAnnotationResponse) XXX_Unmarshal

func (m *HostAnnotationResponse) XXX_Unmarshal(b []byte) error

type K8SCloudOperatorClient

type K8SCloudOperatorClient interface {
	//
	// GetPodVMUUIDAnnotation gets the PV by querying the API server refering to the volumeID in the request.
	// Retrieves the PVC name and Namespace from the PV spec.
	//
	// It then gets the vmuuid annotation from the pod satisfying the below conditions
	// 1. Pod Scheduled on node with name "nodeName"
	// 2. Pod is in pending state in the same namespace as pvc specified using "pvcNamespace"
	// 3. Pod has a volume with name "pvcName" associated with it
	//
	// The annotation might not be available immediately when the Pod is created.
	// So polling the Pod periodically every pollInterval seconds to check if annotation is available.
	// If annotation is not available after a timeout period, the function errors out.
	GetPodVMUUIDAnnotation(ctx context.Context, in *PodListenerRequest, opts ...grpc.CallOption) (*PodListenerResponse, error)
	//
	// GetHostAnnotation gets the annotation value by querying the API server referring to the annotation key
	// and the host specified in the HostAnnotationRequest
	GetHostAnnotation(ctx context.Context, in *HostAnnotationRequest, opts ...grpc.CallOption) (*HostAnnotationResponse, error)
	//
	// Placement API in PlacePersistenceVolumeClaim selects target storage pool to place the given PVC based on its profile and the topology information.
	// If the given PVC should not be handled by PlacePersistenceVolumeClaim like on vSAN or SPBM based cases, this API is a no-op and returns immediately with PVCPlacementRequest.placeSuccess set to true
	// If the PVC has a mapped storage pool, PlacePersistenceVolumeClaim return true
	// If the placement is successful, the PVC will be annotated with the selected storage pool and the PVCPlacementRequest.placeSuccess is set to true.
	// For unsuccessful placement, the PVCPlacementRequest.placeSuccess will be set to false
	PlacePersistenceVolumeClaim(ctx context.Context, in *PVCPlacementRequest, opts ...grpc.CallOption) (*PVCPlacementResponse, error)
	//
	// To decommission a vSAN Direct datastore we need to migrate all the PSP volumes to other vSAN Direct datastores mounted on the same host.
	// GetStorageVMotionPlan creates a storage vMotion plan as a map where keys are PVs residing in the specified vSAN Direct Datastore
	// and values are other vSAN Direct Datastores into which the PV should be migrated.
	//
	// The outcome of the below service can be one of the two below:
	// 1. All the PSP PVs are mapped to a corresponding datastore. We return storage vMotion plan as response with no error.
	// 2. Some (or all) of the PSP PVs cannot be mapped (may be due to lack of capacity). We return with
	//    appropriate error and return vMotion plan as nil.
	GetStorageVMotionPlan(ctx context.Context, in *StorageVMotionRequest, opts ...grpc.CallOption) (*StorageVMotionResponse, error)
}

K8SCloudOperatorClient is the client API for K8SCloudOperator service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewK8SCloudOperatorClient

func NewK8SCloudOperatorClient(cc *grpc.ClientConn) K8SCloudOperatorClient

type K8SCloudOperatorServer

type K8SCloudOperatorServer interface {
	//
	// GetPodVMUUIDAnnotation gets the PV by querying the API server refering to the volumeID in the request.
	// Retrieves the PVC name and Namespace from the PV spec.
	//
	// It then gets the vmuuid annotation from the pod satisfying the below conditions
	// 1. Pod Scheduled on node with name "nodeName"
	// 2. Pod is in pending state in the same namespace as pvc specified using "pvcNamespace"
	// 3. Pod has a volume with name "pvcName" associated with it
	//
	// The annotation might not be available immediately when the Pod is created.
	// So polling the Pod periodically every pollInterval seconds to check if annotation is available.
	// If annotation is not available after a timeout period, the function errors out.
	GetPodVMUUIDAnnotation(context.Context, *PodListenerRequest) (*PodListenerResponse, error)
	//
	// GetHostAnnotation gets the annotation value by querying the API server referring to the annotation key
	// and the host specified in the HostAnnotationRequest
	GetHostAnnotation(context.Context, *HostAnnotationRequest) (*HostAnnotationResponse, error)
	//
	// Placement API in PlacePersistenceVolumeClaim selects target storage pool to place the given PVC based on its profile and the topology information.
	// If the given PVC should not be handled by PlacePersistenceVolumeClaim like on vSAN or SPBM based cases, this API is a no-op and returns immediately with PVCPlacementRequest.placeSuccess set to true
	// If the PVC has a mapped storage pool, PlacePersistenceVolumeClaim return true
	// If the placement is successful, the PVC will be annotated with the selected storage pool and the PVCPlacementRequest.placeSuccess is set to true.
	// For unsuccessful placement, the PVCPlacementRequest.placeSuccess will be set to false
	PlacePersistenceVolumeClaim(context.Context, *PVCPlacementRequest) (*PVCPlacementResponse, error)
	//
	// To decommission a vSAN Direct datastore we need to migrate all the PSP volumes to other SAN Direct datastores mounted on the same host.
	// GetStorageVMotionPlan creates a storage vMotion plan as a map where keys are PVs residing in the specified vSAN Direct Datastore
	// and values are other vSAN Direct Datastores into which the PV should be migrated.
	//
	// The outcome of the below service can be one of the two below:
	// 1. All the PSP PVs are mapped to a corresponding datastore. We return storage vMotion plan as response with no error.
	// 2. Some (or all) of the PSP PVs cannot be mapped (may be due to lack of capacity). We return with
	//    appropriate error and return vMotion plan as nil.
	GetStorageVMotionPlan(context.Context, *StorageVMotionRequest) (*StorageVMotionResponse, error)
}

K8SCloudOperatorServer is the server API for K8SCloudOperator service.

type PVCPlacementRequest

type PVCPlacementRequest struct {
	// Name of the PVC to place
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// Namespace of the PVC to place
	Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"`
	// Topology in AccessibilityRequirements to place a PVC
	AccessibilityRequirements *spec.TopologyRequirement `` /* 136-byte string literal not displayed */
	XXX_NoUnkeyedLiteral      struct{}                  `json:"-"`
	XXX_unrecognized          []byte                    `json:"-"`
	XXX_sizecache             int32                     `json:"-"`
}

func (*PVCPlacementRequest) Descriptor

func (*PVCPlacementRequest) Descriptor() ([]byte, []int)

func (*PVCPlacementRequest) GetAccessibilityRequirements

func (m *PVCPlacementRequest) GetAccessibilityRequirements() *spec.TopologyRequirement

func (*PVCPlacementRequest) GetName

func (m *PVCPlacementRequest) GetName() string

func (*PVCPlacementRequest) GetNamespace

func (m *PVCPlacementRequest) GetNamespace() string

func (*PVCPlacementRequest) ProtoMessage

func (*PVCPlacementRequest) ProtoMessage()

func (*PVCPlacementRequest) Reset

func (m *PVCPlacementRequest) Reset()

func (*PVCPlacementRequest) String

func (m *PVCPlacementRequest) String() string

func (*PVCPlacementRequest) XXX_DiscardUnknown

func (m *PVCPlacementRequest) XXX_DiscardUnknown()

func (*PVCPlacementRequest) XXX_Marshal

func (m *PVCPlacementRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PVCPlacementRequest) XXX_Merge

func (m *PVCPlacementRequest) XXX_Merge(src proto.Message)

func (*PVCPlacementRequest) XXX_Size

func (m *PVCPlacementRequest) XXX_Size() int

func (*PVCPlacementRequest) XXX_Unmarshal

func (m *PVCPlacementRequest) XXX_Unmarshal(b []byte) error

type PVCPlacementResponse

type PVCPlacementResponse struct {
	//Succeed or not for placement engine to find proper storage pool
	PlaceSuccess         bool     `protobuf:"varint,1,opt,name=placeSuccess,proto3" json:"placeSuccess,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*PVCPlacementResponse) Descriptor

func (*PVCPlacementResponse) Descriptor() ([]byte, []int)

func (*PVCPlacementResponse) GetPlaceSuccess

func (m *PVCPlacementResponse) GetPlaceSuccess() bool

func (*PVCPlacementResponse) ProtoMessage

func (*PVCPlacementResponse) ProtoMessage()

func (*PVCPlacementResponse) Reset

func (m *PVCPlacementResponse) Reset()

func (*PVCPlacementResponse) String

func (m *PVCPlacementResponse) String() string

func (*PVCPlacementResponse) XXX_DiscardUnknown

func (m *PVCPlacementResponse) XXX_DiscardUnknown()

func (*PVCPlacementResponse) XXX_Marshal

func (m *PVCPlacementResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PVCPlacementResponse) XXX_Merge

func (m *PVCPlacementResponse) XXX_Merge(src proto.Message)

func (*PVCPlacementResponse) XXX_Size

func (m *PVCPlacementResponse) XXX_Size() int

func (*PVCPlacementResponse) XXX_Unmarshal

func (m *PVCPlacementResponse) XXX_Unmarshal(b []byte) error

type PodListenerRequest

type PodListenerRequest struct {
	// The volumeID that needs to be attached to the node.
	VolumeID string `protobuf:"bytes,1,opt,name=volumeID,proto3" json:"volumeID,omitempty"`
	// Name of the node where the Pod is running.
	NodeName             string   `protobuf:"bytes,2,opt,name=nodeName,proto3" json:"nodeName,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*PodListenerRequest) Descriptor

func (*PodListenerRequest) Descriptor() ([]byte, []int)

func (*PodListenerRequest) GetNodeName

func (m *PodListenerRequest) GetNodeName() string

func (*PodListenerRequest) GetVolumeID

func (m *PodListenerRequest) GetVolumeID() string

func (*PodListenerRequest) ProtoMessage

func (*PodListenerRequest) ProtoMessage()

func (*PodListenerRequest) Reset

func (m *PodListenerRequest) Reset()

func (*PodListenerRequest) String

func (m *PodListenerRequest) String() string

func (*PodListenerRequest) XXX_DiscardUnknown

func (m *PodListenerRequest) XXX_DiscardUnknown()

func (*PodListenerRequest) XXX_Marshal

func (m *PodListenerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PodListenerRequest) XXX_Merge

func (m *PodListenerRequest) XXX_Merge(src proto.Message)

func (*PodListenerRequest) XXX_Size

func (m *PodListenerRequest) XXX_Size() int

func (*PodListenerRequest) XXX_Unmarshal

func (m *PodListenerRequest) XXX_Unmarshal(b []byte) error

type PodListenerResponse

type PodListenerResponse struct {
	// VM UUID annotation of the pod.
	VmuuidAnnotation     string   `protobuf:"bytes,1,opt,name=vmuuidAnnotation,proto3" json:"vmuuidAnnotation,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*PodListenerResponse) Descriptor

func (*PodListenerResponse) Descriptor() ([]byte, []int)

func (*PodListenerResponse) GetVmuuidAnnotation

func (m *PodListenerResponse) GetVmuuidAnnotation() string

func (*PodListenerResponse) ProtoMessage

func (*PodListenerResponse) ProtoMessage()

func (*PodListenerResponse) Reset

func (m *PodListenerResponse) Reset()

func (*PodListenerResponse) String

func (m *PodListenerResponse) String() string

func (*PodListenerResponse) XXX_DiscardUnknown

func (m *PodListenerResponse) XXX_DiscardUnknown()

func (*PodListenerResponse) XXX_Marshal

func (m *PodListenerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PodListenerResponse) XXX_Merge

func (m *PodListenerResponse) XXX_Merge(src proto.Message)

func (*PodListenerResponse) XXX_Size

func (m *PodListenerResponse) XXX_Size() int

func (*PodListenerResponse) XXX_Unmarshal

func (m *PodListenerResponse) XXX_Unmarshal(b []byte) error

type StoragePoolInfo

type StoragePoolInfo struct {
	Name                  string
	AllocatableCapInBytes int64
}

StoragePoolInfo is abstraction of a storage pool list. XXX Change all usage of this into a map.

type StorageVMotionRequest

type StorageVMotionRequest struct {
	// name of the Storage-Pool
	StoragePoolName string `protobuf:"bytes,1,opt,name=storage_pool_name,json=storagePoolName,proto3" json:"storage_pool_name,omitempty"`
	// Type of maintenance mode, either "ensureAccessibility"/"evacuateAll".
	MaintenanceMode      string   `protobuf:"bytes,2,opt,name=maintenance_mode,json=maintenanceMode,proto3" json:"maintenance_mode,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*StorageVMotionRequest) Descriptor

func (*StorageVMotionRequest) Descriptor() ([]byte, []int)

func (*StorageVMotionRequest) GetMaintenanceMode

func (m *StorageVMotionRequest) GetMaintenanceMode() string

func (*StorageVMotionRequest) GetStoragePoolName

func (m *StorageVMotionRequest) GetStoragePoolName() string

func (*StorageVMotionRequest) ProtoMessage

func (*StorageVMotionRequest) ProtoMessage()

func (*StorageVMotionRequest) Reset

func (m *StorageVMotionRequest) Reset()

func (*StorageVMotionRequest) String

func (m *StorageVMotionRequest) String() string

func (*StorageVMotionRequest) XXX_DiscardUnknown

func (m *StorageVMotionRequest) XXX_DiscardUnknown()

func (*StorageVMotionRequest) XXX_Marshal

func (m *StorageVMotionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*StorageVMotionRequest) XXX_Merge

func (m *StorageVMotionRequest) XXX_Merge(src proto.Message)

func (*StorageVMotionRequest) XXX_Size

func (m *StorageVMotionRequest) XXX_Size() int

func (*StorageVMotionRequest) XXX_Unmarshal

func (m *StorageVMotionRequest) XXX_Unmarshal(b []byte) error

type StorageVMotionResponse

type StorageVMotionResponse struct {
	// svMotion plan is returned to caller as a map of PV name to StoragePool name
	SvMotionPlan         map[string]string `` /* 187-byte string literal not displayed */
	XXX_NoUnkeyedLiteral struct{}          `json:"-"`
	XXX_unrecognized     []byte            `json:"-"`
	XXX_sizecache        int32             `json:"-"`
}

func (*StorageVMotionResponse) Descriptor

func (*StorageVMotionResponse) Descriptor() ([]byte, []int)

func (*StorageVMotionResponse) GetSvMotionPlan

func (m *StorageVMotionResponse) GetSvMotionPlan() map[string]string

func (*StorageVMotionResponse) ProtoMessage

func (*StorageVMotionResponse) ProtoMessage()

func (*StorageVMotionResponse) Reset

func (m *StorageVMotionResponse) Reset()

func (*StorageVMotionResponse) String

func (m *StorageVMotionResponse) String() string

func (*StorageVMotionResponse) XXX_DiscardUnknown

func (m *StorageVMotionResponse) XXX_DiscardUnknown()

func (*StorageVMotionResponse) XXX_Marshal

func (m *StorageVMotionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*StorageVMotionResponse) XXX_Merge

func (m *StorageVMotionResponse) XXX_Merge(src proto.Message)

func (*StorageVMotionResponse) XXX_Size

func (m *StorageVMotionResponse) XXX_Size() int

func (*StorageVMotionResponse) XXX_Unmarshal

func (m *StorageVMotionResponse) XXX_Unmarshal(b []byte) error

type VolumeInfo

type VolumeInfo struct {
	PVC         v1.PersistentVolumeClaim
	PVName      string
	SizeInBytes int64
}

VolumeInfo bundles up PVC info along with its bounded PV info (if any).

func GetVolumesOnStoragePool

func GetVolumesOnStoragePool(ctx context.Context, client kubernetes.Interface,
	StoragePoolName string) ([]VolumeInfo, []v1.PersistentVolumeClaim, error)

GetVolumesOnStoragePool returns volume information of all PVCs present on the given StoragePool.

Jump to

Keyboard shortcuts

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