k8s

package
v0.0.0-...-ac4f492 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2021 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RANDOM_SUFFIX_LEN = 10
	// k8s object name has a maximum length
	MAX_NAME_LEN = 63 - RANDOM_SUFFIX_LEN - 1
)
View Source
const (
	CtxTimeout = 10 * time.Second
)
View Source
const (
	WatchNamespaceEnvVar = "WATCH_NAMESPACE"
)

Variables

This section is empty.

Functions

func AddRandSuffix

func AddRandSuffix(name string) string

func GenerateKey

func GenerateKey(ln int) []byte

func GetOperatorNamespace

func GetOperatorNamespace() string

GetOperatorNamespace returns the namespace the operator should be running in.

func GetWatchNamespace

func GetWatchNamespace() (string, error)

GetWatchNamespace returns the namespace the operator should be watching for changes

func IsInCluster

func IsInCluster() bool

func TimeoutWrap

func TimeoutWrap(timeout time.Duration, fn func() error) error

Types

type Kcli

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

func NewKcli

func NewKcli(client ctrlcli.Client, scheme *runtime.Scheme, log *zap.SugaredLogger, obj metav1.Object) *Kcli

func (*Kcli) CreateObject

func (s *Kcli) CreateObject(obj runtime.Object) error

func (*Kcli) DeleteALLByLabel

func (s *Kcli) DeleteALLByLabel(obj ctrlcli.Object, namespace string, labels map[string]string) error

func (*Kcli) DeleteObject

func (s *Kcli) DeleteObject(obj ctrlcli.Object) error

func (*Kcli) Ensure

func (s *Kcli) Ensure(obj metav1.Object, found ctrlcli.Object) error

func (*Kcli) EnsureOrphan

func (s *Kcli) EnsureOrphan(obj metav1.Object, found ctrlcli.Object) error

not set ownerRef,用于公用资源

func (*Kcli) EnsurePVC

func (s *Kcli) EnsurePVC(obj *corev1.PersistentVolumeClaim) error

func (*Kcli) EnsureService

func (s *Kcli) EnsureService(obj *corev1.Service) error

func (*Kcli) EnsureStatefulSet

func (s *Kcli) EnsureStatefulSet(obj *appsv1.StatefulSet) error

func (*Kcli) Find

func (s *Kcli) Find(name, namespace string, found ctrlcli.Object) error

func (*Kcli) IsExists

func (s *Kcli) IsExists(obj metav1.Object, found ctrlcli.Object) (exists bool, err error)

func (*Kcli) ListByLabel

func (s *Kcli) ListByLabel(namespace string, labels map[string]string, found ctrlcli.ObjectList) error

func (*Kcli) PatchObject

func (s *Kcli) PatchObject(obj ctrlcli.Object, patch ctrlcli.Object) error

func (*Kcli) SetRefAndCreateObject

func (s *Kcli) SetRefAndCreateObject(obj interface{}) error

func (*Kcli) UpdateObject

func (s *Kcli) UpdateObject(obj ctrlcli.Object) error

func (*Kcli) WriteStatus

func (s *Kcli) WriteStatus(obj ctrlcli.Object) error

Jump to

Keyboard shortcuts

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