util

package
v0.1.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: Apache-2.0 Imports: 16 Imported by: 7

Documentation

Index

Constants

View Source
const (
	VolumeResizing           = "Resizing"
	VolumeResizeFailed       = "VolumeResizeFailed"
	VolumeResizeSuccess      = "VolumeResizeSuccessful"
	FileSystemResizeRequired = "FileSystemResizeRequired"
)

These constants are PVC condition types related to resize operation.

Variables

This section is empty.

Functions

func HasFileSystemResizePendingCondition

func HasFileSystemResizePendingCondition(pvc *v1.PersistentVolumeClaim) bool

HasFileSystemResizePendingCondition returns true if a pvc has a FileSystemResizePending condition. This means the controller side resize operation is finished, and kublete side operation is in progress.

func MergeResizeConditionsOfPVC

func MergeResizeConditionsOfPVC(oldConditions, newConditions []v1.PersistentVolumeClaimCondition) []v1.PersistentVolumeClaimCondition

MergeResizeConditionsOfPVC updates pvc with requested resize conditions leaving other conditions untouched.

func NewK8sClient

func NewK8sClient(master, kubeConfig string) (kubernetes.Interface, error)

NewK8sClient is an utility function used to create a kubernetes sdk client.

func NewLeaderLock

func NewLeaderLock(
	kubeClient kubernetes.Interface,
	eventRecorder record.EventRecorder,
	config *LeaderElectionConfig) (resourcelock.Interface, error)

NewLeaderLock creates a ResourceLock, which can be used to create leaderElector.

func PVCKey

func PVCKey(pvc *v1.PersistentVolumeClaim) string

PVCKey returns an unique key of a PVC object,

func PatchPVCStatus

func PatchPVCStatus(
	oldPVC *v1.PersistentVolumeClaim,
	newPVC *v1.PersistentVolumeClaim,
	kubeClient kubernetes.Interface) (*v1.PersistentVolumeClaim, error)

PatchPVCStatus updates PVC status using PATCH verb

func RunAsLeader

func RunAsLeader(lock resourcelock.Interface, config *LeaderElectionConfig, startFunc func(context.Context))

RunAsLeader creates an leaderElector and starts the main function only after becoming a leader.

func SanitizeName

func SanitizeName(name string) string

SanitizeName changes any name to a sanitized name which can be accepted by kubernetes.

func UpdatePVCapacity

func UpdatePVCapacity(pv *v1.PersistentVolume, newCapacity resource.Quantity, kubeClient kubernetes.Interface) error

UpdatePVCapacity updates PVC capacity with requested size.

Types

type LeaderElectionConfig

type LeaderElectionConfig struct {
	Identity      string
	LockName      string
	Namespace     string
	RetryPeriod   time.Duration
	LeaseDuration time.Duration
	RenewDeadLine time.Duration
}

LeaderElectionConfig is a combination of common configurations to create an LeaderElector.

Jump to

Keyboard shortcuts

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