k8s

package
v1.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConnectFn = func(api *API) error {
	config, err := getConfig()
	if err != nil {
		return err
	}
	api.Client, err = NewConfigFn(config)
	if err != nil {
		return err
	}
	return nil
}

ConnectFn will connect the client to the k8s API

View Source
var InClusterConfigFn = func() (*rest.Config, error) {
	return rest.InClusterConfig()
}

InClusterConfigFn will return a valid configuration if we are running in a Pod on a kubernetes cluster

View Source
var NewConfigFn = func(config *rest.Config) (*kubernetes.Clientset, error) {
	return kubernetes.NewForConfig(config)
}

NewConfigFn will return a valid kubernetes.Clientset

View Source
var NewForConfigFn = func(k8sconfig *rest.Config) (*kubernetes.Clientset, error) {
	return kubernetes.NewForConfig(k8sconfig)
}

NewForConfigFn creates a new Clientset for the given config. If config's RateLimiter is not set and QPS and Burst are acceptable, NewForConfigFn will generate a rate-limiter in configShallowCopy

NewLeaderElectorFn creates a LeaderElector from a LeaderElectionConfig

Functions

func Contains

func Contains(slice []string, value string) bool

Contains will return true if the slice contains the given value

Types

type API

type API struct {
	Client kubernetes.Interface
	Lock   sync.Mutex
}

API holds data used to access the K8S API

func (*API) GetPersistentVolumes

func (api *API) GetPersistentVolumes() (*corev1.PersistentVolumeList, error)

GetPersistentVolumes will return a list of persistent volumes in the kubernetes cluster

func (*API) GetStorageClasses

func (api *API) GetStorageClasses() (*v1.StorageClassList, error)

GetStorageClasses will return a list of storage classes in the kubernetes clusteer

type LeaderElector

type LeaderElector struct {
	API     LeaderElectorGetter
	Elector *leaderelection.LeaderElector
}

LeaderElector holds LeaderElector struct for the client

func (*LeaderElector) InitLeaderElection

func (elect *LeaderElector) InitLeaderElection(endpoint string, namespace string) error

InitLeaderElection will run algorithm for leader election, call during service initialzation process

func (*LeaderElector) IsLeader

func (elect *LeaderElector) IsLeader() bool

IsLeader return true if the given client is leader at the moment

type LeaderElectorGetter

type LeaderElectorGetter interface {
	InitLeaderElection(string, string) error
	IsLeader() bool
}

LeaderElectorGetter is an interface for initialize and check elected leader

type StorageArrayID

type StorageArrayID struct {
	ID          string
	IsDefault   bool
	DriverNames []string
}

StorageArrayID contains Name, whether is default and associated drivernames

type StorageClassFinder

type StorageClassFinder struct {
	API            StorageClassGetter
	StorageArrayID []StorageArrayID
	Logger         *logrus.Logger
}

StorageClassFinder is a storage class finder that will query the Kubernetes API for storage classes provisioned by a matching DriverName and StorageSystemID

func (*StorageClassFinder) GetStorageClasses

func (f *StorageClassFinder) GetStorageClasses(_ context.Context) ([]v1.StorageClass, error)

GetStorageClasses will return a list of storage classes that match the given DriverName in Kubernetes

type StorageClassGetter

type StorageClassGetter interface {
	GetStorageClasses() (*v1.StorageClassList, error)
}

StorageClassGetter is an interface for getting a list of storage class information

type VolumeFinder

type VolumeFinder struct {
	API         VolumeGetter
	DriverNames []string
	Logger      *logrus.Logger
}

VolumeFinder is a volume finder that will query the Kubernetes API for Persistent Volumes created by a matching DriverName and StorageSystemID

func (VolumeFinder) GetPersistentVolumes

func (f VolumeFinder) GetPersistentVolumes(_ context.Context) ([]VolumeInfo, error)

GetPersistentVolumes will return a list of persistent volume information

type VolumeGetter

type VolumeGetter interface {
	GetPersistentVolumes() (*corev1.PersistentVolumeList, error)
}

VolumeGetter is an interface for getting a list of persistent volume information

type VolumeInfo

type VolumeInfo struct {
	Namespace              string `json:"namespace"`
	PersistentVolumeClaim  string `json:"persistent_volume_claim"`
	PersistentVolumeStatus string `json:"volume_status"`
	VolumeClaimName        string `json:"volume_claim_name"`
	PersistentVolume       string `json:"persistent_volume"`
	StorageClass           string `json:"storage_class"`
	Driver                 string `json:"driver"`
	ProvisionedSize        string `json:"provisioned_size"`
	CreatedTime            string `json:"created_time"`
	VolumeHandle           string `json:"volume_handle"`
	SRP                    string `json:"srp"`
	ServiceLevel           string `json:"service_level"`
	StorageGroup           string `json:"storage_group"`
	SymID                  string `json:"symid"`
}

VolumeInfo contains information about mapping a Persistent Volume to the volume created on a storage system

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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