k8sutil

package
v0.9.10 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: Apache-2.0 Imports: 35 Imported by: 20

Documentation

Index

Constants

View Source
const (
	ResourceRevisionLabel = "resource.alpha.banzaicloud.io/revision"
)

Variables

This section is empty.

Functions

func CheckResourceRevision

func CheckResourceRevision(obj runtime.Object, revisionConstraint string) (bool, error)

func DetachPodsFromDeployment

func DetachPodsFromDeployment(c client.Client, deployment *appsv1.Deployment, log logr.Logger, additionalLabels ...map[string]string) error

func GetHPAReplicaCountOrDefault

func GetHPAReplicaCountOrDefault(client client.Client, name types.NamespacedName, defaultReplicaCount int32) int32

GetHPAReplicaCountOrDefault get desired replica count from HPA if exists, returns the given default otherwise

func GetResourceRevision

func GetResourceRevision(obj runtime.Object) (string, error)

func GetServiceEndpointIPs

func GetServiceEndpointIPs(service corev1.Service) ([]string, bool, error)

func GetWatchPredicateForIstio

func GetWatchPredicateForIstio() predicate.Funcs

func GetWatchPredicateForIstioIngressGateway

func GetWatchPredicateForIstioIngressGateway() predicate.Funcs

func GetWatchPredicateForIstioService

func GetWatchPredicateForIstioService(name string) predicate.Funcs

func GetWatchPredicateForIstioServicePods

func GetWatchPredicateForIstioServicePods() predicate.Funcs

func GetWatchPredicateForMeshGateway

func GetWatchPredicateForMeshGateway() predicate.Funcs

func GetWatchPredicateForOwnedResources

func GetWatchPredicateForOwnedResources(owner runtime.Object, isController bool, scheme *runtime.Scheme, logger logr.Logger) predicate.Funcs

func GetWatchPredicateForRemoteIstio

func GetWatchPredicateForRemoteIstio() predicate.Funcs

func GetWatchPredicateForRemoteIstioAvailability

func GetWatchPredicateForRemoteIstioAvailability() predicate.Funcs

func IsObjectChanged

func IsObjectChanged(oldObj, newObj runtime.Object, ignoreStatusChange bool) (bool, error)

IsObjectChanged checks whether there is an actual difference between the two objects

func MergeEnvVars

func MergeEnvVars(envs []corev1.EnvVar, additionalEnvs []corev1.EnvVar) []corev1.EnvVar

MergeEnvVars merges env variables by name

func NewCachedRESTMapper

func NewCachedRESTMapper(config *rest.Config) (meta.RESTMapper, error)

func Reconcile

func Reconcile(log logr.Logger, client runtimeClient.Client, desired runtime.Object, desiredState DesiredState) error

func ReconcileNamespaceLabelsIgnoreNotFound

func ReconcileNamespaceLabelsIgnoreNotFound(log logr.Logger, client runtimeClient.Client, namespace string, labels map[string]string, labelsToRemove []string, customLabelsToIgnoreReconcile ...string) error

ReconcileNamespaceLabelsIgnoreNotFound patches namespaces by adding/removing labels, returns without error if namespace is not found

func ReconcileWithObjectModifiers

func ReconcileWithObjectModifiers(log logr.Logger, client runtimeClient.Client, desired runtime.Object, desiredState DesiredState, objectModifiers []ObjectModifierFunc) error

func RunObjectModifiers

func RunObjectModifiers(o runtime.Object, objectModifiers []ObjectModifierFunc) (runtime.Object, error)

func SetOwnerReferenceToObject

func SetOwnerReferenceToObject(obj runtime.Object, owner runtime.Object) ([]metav1.OwnerReference, error)

func SetResourceRevision

func SetResourceRevision(obj runtime.Object, revision string) error

Types

type Cached

type Cached struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Cached) KindFor

func (*Cached) KindsFor

func (c *Cached) KindsFor(resource schema.GroupVersionResource) ([]schema.GroupVersionKind, error)

func (*Cached) RESTMapping

func (c *Cached) RESTMapping(gk schema.GroupKind, versions ...string) (*meta.RESTMapping, error)

func (*Cached) RESTMappings

func (c *Cached) RESTMappings(gk schema.GroupKind, versions ...string) ([]*meta.RESTMapping, error)

func (*Cached) ResourceFor

func (*Cached) ResourceSingularizer

func (c *Cached) ResourceSingularizer(resource string) (singular string, err error)

func (*Cached) ResourcesFor

func (c *Cached) ResourcesFor(input schema.GroupVersionResource) ([]schema.GroupVersionResource, error)

type DesiredState

type DesiredState interface {
	AfterRecreate(current, desired runtime.Object) error
	BeforeRecreate(current, desired runtime.Object) error
	ShouldRecreate(current, desired runtime.Object) (bool, error)
	AfterCreate(desired runtime.Object) error
	BeforeCreate(desired runtime.Object) error
	ShouldCreate(desired runtime.Object) (bool, error)
	AfterUpdate(current, desired runtime.Object, inSync bool) error
	BeforeUpdate(current, desired runtime.Object) error
	ShouldUpdate(current, desired runtime.Object) (bool, error)
	AfterDelete(current runtime.Object) error
	BeforeDelete(current runtime.Object) error
	ShouldDelete(current runtime.Object) (bool, error)
}

type DynamicObject

type DynamicObject struct {
	Name      string
	Namespace string
	Labels    map[string]string
	Spec      map[string]interface{}
	Gvr       schema.GroupVersionResource
	Kind      string
	Owner     *istiov1beta1.Istio
}

func (*DynamicObject) Reconcile

func (d *DynamicObject) Reconcile(log logr.Logger, client dynamic.Interface, desiredState DesiredState) error

func (*DynamicObject) ReconcileWithObjectModifiers

func (d *DynamicObject) ReconcileWithObjectModifiers(log logr.Logger, client dynamic.Interface, desiredState DesiredState, objectModifiers []ObjectModifierFunc) error

type IngressSetupPendingError

type IngressSetupPendingError struct{}

func (IngressSetupPendingError) Error

func (e IngressSetupPendingError) Error() string

type MeshGatewayCreateOnlyDesiredState

type MeshGatewayCreateOnlyDesiredState struct {
	StaticDesiredState
}

func (MeshGatewayCreateOnlyDesiredState) ShouldUpdate

func (MeshGatewayCreateOnlyDesiredState) ShouldUpdate(current, desired runtime.Object) (bool, error)

type ObjectModifierFunc

type ObjectModifierFunc = resources.ObjectModifierFunc

func CombineObjectModifiers

func CombineObjectModifiers(modifiers ...[]ObjectModifierFunc) []ObjectModifierFunc

func GetGVKObjectModifier

func GetGVKObjectModifier(scheme *runtime.Scheme) ObjectModifierFunc

func GetObjectModifiersForOverlays

func GetObjectModifiersForOverlays(scheme *runtime.Scheme, overlays []resources.K8SResourceOverlay) ([]ObjectModifierFunc, error)

type OwnerReferenceMatcher

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

func NewOwnerReferenceMatcher

func NewOwnerReferenceMatcher(owner runtime.Object, ctrl bool, scheme *runtime.Scheme) *OwnerReferenceMatcher

NewOwnerReferenceMatcher initializes a new owner reference matcher

func (*OwnerReferenceMatcher) Match

Match matches if an object is owned by the initialised owner

type RecreateAwareDeploymentDesiredState

type RecreateAwareDeploymentDesiredState struct {
	StaticDesiredState
	// contains filtered or unexported fields
}

func NewRecreateAwareDeploymentDesiredState

func NewRecreateAwareDeploymentDesiredState(c client.Client, scheme *runtime.Scheme, log logr.Logger, podLabels map[string]string) RecreateAwareDeploymentDesiredState

func (RecreateAwareDeploymentDesiredState) AfterRecreate

func (r RecreateAwareDeploymentDesiredState) AfterRecreate(current, desired runtime.Object) error

func (RecreateAwareDeploymentDesiredState) AfterUpdate

func (r RecreateAwareDeploymentDesiredState) AfterUpdate(current, desired runtime.Object, inSync bool) error

func (RecreateAwareDeploymentDesiredState) BeforeRecreate

func (r RecreateAwareDeploymentDesiredState) BeforeRecreate(current, desired runtime.Object) error

type StaticDesiredState

type StaticDesiredState string
const (
	DesiredStatePresent StaticDesiredState = "present"
	DesiredStateAbsent  StaticDesiredState = "absent"
	DesiredStateExists  StaticDesiredState = "exists"
)

func (StaticDesiredState) AfterCreate

func (s StaticDesiredState) AfterCreate(_ runtime.Object) error

func (StaticDesiredState) AfterDelete

func (s StaticDesiredState) AfterDelete(_ runtime.Object) error

func (StaticDesiredState) AfterRecreate

func (s StaticDesiredState) AfterRecreate(_, _ runtime.Object) error

func (StaticDesiredState) AfterUpdate

func (s StaticDesiredState) AfterUpdate(_, _ runtime.Object, _ bool) error

func (StaticDesiredState) BeforeCreate

func (s StaticDesiredState) BeforeCreate(_ runtime.Object) error

func (StaticDesiredState) BeforeDelete

func (s StaticDesiredState) BeforeDelete(_ runtime.Object) error

func (StaticDesiredState) BeforeRecreate

func (s StaticDesiredState) BeforeRecreate(_, _ runtime.Object) error

func (StaticDesiredState) BeforeUpdate

func (s StaticDesiredState) BeforeUpdate(_, _ runtime.Object) error

func (StaticDesiredState) ShouldCreate

func (s StaticDesiredState) ShouldCreate(_ runtime.Object) (bool, error)

func (StaticDesiredState) ShouldDelete

func (s StaticDesiredState) ShouldDelete(_ runtime.Object) (bool, error)

func (StaticDesiredState) ShouldRecreate

func (s StaticDesiredState) ShouldRecreate(_, _ runtime.Object) (bool, error)

func (StaticDesiredState) ShouldUpdate

func (s StaticDesiredState) ShouldUpdate(_, _ runtime.Object) (bool, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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