resource

package
v0.26.4 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// (Ctrl-C) to interrupt or terminate a program or process.
	EndOfText = "\u0003"
	// (Ctrl-D) to indicate end-of-file on a terminal.
	EndOfTransmission = "\u0004"
)

Variables

This section is empty.

Functions

func AddPodAnnotation

func AddPodAnnotation(ctx context.Context, client *k8sclient.K8sClient, podName, namespace string, addAnnotations map[string]string) error

func AddPodLabel

func AddPodLabel(ctx context.Context, client *k8sclient.K8sClient, podName, namespace string, addLabels map[string]string) error

func AddSecretFinalizer

func AddSecretFinalizer(ctx context.Context, client *k8s.K8sClient, secret *v1.Secret, finalizer string) error

func CanUpgrade added in v0.26.0

func CanUpgrade(pod corev1.Pod, recreate bool) (bool, string, error)

CanUpgrade if the pod can be upgraded 1. pod has hash label 2. pod image support upgrade 3. pod is ready

func CanUpgradeWithHash added in v0.26.0

func CanUpgradeWithHash(ctx context.Context, client *k8sclient.K8sClient, pod corev1.Pod, recreate bool) (bool, string, error)

func CheckForSecretFinalizer

func CheckForSecretFinalizer(ctx context.Context, client *k8s.K8sClient, volume *v1.PersistentVolume) (shouldRemoveFinalizer bool, err error)

func CheckForSubPath

func CheckForSubPath(ctx context.Context, client *k8s.K8sClient, volume *v1.PersistentVolume, pathPattern string) (shouldDeleted bool, err error)

func CreateOrUpdateSecret added in v0.26.0

func CreateOrUpdateSecret(ctx context.Context, client *k8sclient.K8sClient, secret *corev1.Secret) error

func DelPodAnnotation

func DelPodAnnotation(ctx context.Context, client *k8sclient.K8sClient, podName, namespace string, delAnnotations []string) error

func DeleteResourceOfPod

func DeleteResourceOfPod(pod *corev1.Pod)

func DownloadPodFile added in v0.24.5

func DownloadPodFile(ctx context.Context, client kubernetes.Interface, cfg *rest.Config, writer io.Writer, namespace, name, container string, cmd []string) error

func ExecInPod added in v0.24.5

func ExecInPod(ctx context.Context, client kubernetes.Interface, cfg *rest.Config, h Handler, namespace, name, container string, cmd []string) error

func FilterPodsToUpgrade added in v0.26.0

func FilterPodsToUpgrade(podLists corev1.PodList, recreate bool) []corev1.Pod

func FilterVars added in v0.25.2

func FilterVars[T any](vars []T, excludeName string, getName func(T) string) []T

func GetAllRefKeys

func GetAllRefKeys(pod corev1.Pod) map[string]string

func GetCommPath added in v0.25.0

func GetCommPath(basePath string, pod corev1.Pod) (string, error)

func GetNamespace

func GetNamespace(ctx context.Context, client *k8sclient.K8sClient, pod *corev1.Pod) (namespace string, err error)

GetNamespace get juicefs pv & pvc from pod when pod namespace is empty

func GetPVWithVolumeHandleOrAppInfo added in v0.24.6

func GetPVWithVolumeHandleOrAppInfo(ctx context.Context, client *k8s.K8sClient, volumeHandle string, volCtx map[string]string) (*corev1.PersistentVolume, *corev1.PersistentVolumeClaim, error)

func GetSecretNameByUniqueId added in v0.26.0

func GetSecretNameByUniqueId(uniqueId string) string

func GetUniqueId added in v0.25.1

func GetUniqueId(pod corev1.Pod) string

func GetUpgradeUUID added in v0.26.0

func GetUpgradeUUID(pod *corev1.Pod) string

func IsJobCompleted

func IsJobCompleted(job *batchv1.Job) bool

func IsJobFailed

func IsJobFailed(job *batchv1.Job) bool

func IsJobShouldBeRecycled

func IsJobShouldBeRecycled(job *batchv1.Job) bool

func IsPodComplete added in v0.25.0

func IsPodComplete(pod *corev1.Pod) bool

func IsPodError

func IsPodError(pod *corev1.Pod) bool

func IsPodHasResource

func IsPodHasResource(pod corev1.Pod) bool

func IsPodReady

func IsPodReady(pod *corev1.Pod) bool

func IsPodResourceError

func IsPodResourceError(pod *corev1.Pod) bool

func MergeEnvs added in v0.25.2

func MergeEnvs(pod *corev1.Pod, env []corev1.EnvVar)

func MergeMountOptions added in v0.25.2

func MergeMountOptions(pod *corev1.Pod, jfsSetting *config.JfsSetting)

func MergeVolumes added in v0.25.2

func MergeVolumes(pod *corev1.Pod, jfsSetting *config.JfsSetting)

MergeVolumes merges the cache volumes and volume mounts specified in the JfsSetting into the given pod's spec.

func NewTerminalSession added in v0.24.5

func NewTerminalSession(ctx context.Context, conn *websocket.Conn, endOfTransmission string) *terminalSession

func RemoveFinalizer

func RemoveFinalizer(ctx context.Context, client *k8sclient.K8sClient, pod *corev1.Pod, finalizer string) error

func RemoveSecretFinalizer

func RemoveSecretFinalizer(ctx context.Context, client *k8s.K8sClient, secret *v1.Secret, finalizer string) error

func ReplacePodAnnotation

func ReplacePodAnnotation(ctx context.Context, client *k8sclient.K8sClient, podName, namespace string, annotation map[string]string) error

func ShouldDelay

func ShouldDelay(ctx context.Context, pod *corev1.Pod, Client *k8s.K8sClient) (shouldDelay bool, err error)

func WaitForJobComplete added in v0.25.0

func WaitForJobComplete(ctx context.Context, client *k8s.K8sClient, name string, timeout time.Duration) error

func WaitUtilMountReady

func WaitUtilMountReady(ctx context.Context, podName, mntPath string, timeout time.Duration) error

Types

type Handler added in v0.24.5

type Handler interface {
	io.Reader
	io.Writer
	remotecommand.TerminalSizeQueue
}

type ObjectMeta

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

func NewObjectMeta

func NewObjectMeta(pvc v1.PersistentVolumeClaim, node *v1.Node) *ObjectMeta

func (*ObjectMeta) ResolveSecret

func (meta *ObjectMeta) ResolveSecret(str string, pvName string) string

func (*ObjectMeta) StringParser

func (meta *ObjectMeta) StringParser(str string) string

type PVPair

type PVPair struct {
	PV  *corev1.PersistentVolume
	PVC *corev1.PersistentVolumeClaim
}

func GetVolumes

func GetVolumes(ctx context.Context, client *k8sclient.K8sClient, pod *corev1.Pod) (used bool, pvPairGot []PVPair, err error)

GetVolumes get juicefs pv & pvc from pod

type VolumeLocks

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

func NewVolumeLocks

func NewVolumeLocks() *VolumeLocks

func (*VolumeLocks) Release

func (vl *VolumeLocks) Release(volumeID string)

Release deletes the lock on volumeID.

func (*VolumeLocks) TryAcquire

func (vl *VolumeLocks) TryAcquire(volumeID string) bool

Jump to

Keyboard shortcuts

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