Documentation ¶
Index ¶
- Constants
- Variables
- func BuildStrictRegex(regex string) string
- func CompileStrictRegex(pattern string) (*regexp.Regexp, error)
- func CopyAnnotations(m map[string]string) map[string]string
- func CopyLabels(m map[string]string) map[string]string
- func IsManagedBy(source metav1.Object) bool
- func MatchStrictRegex(pattern, str string) (bool, error)
- func MustGetKey(obj interface{}) string
- func MustGetObject(obj interface{}) metav1.Object
- func PrepareAnnotations(source metav1.ObjectMeta) map[string]string
- func PrepareLabels(source metav1.ObjectMeta) map[string]string
- func PrepareOwnerReferences(source metav1.ObjectMeta) []metav1.OwnerReference
- func PrepareTLD(namespace, tld string) string
- func StringToPatternList(list string) (result []*regexp.Regexp)
- type AddFunc
- type GenericReplicator
- func (r *GenericReplicator) HasDefaultIngressHostname() bool
- func (r *GenericReplicator) ListFilteredNamespaces(current string, patterns string) ([]v1.Namespace, error)
- func (r *GenericReplicator) ListLabelSelectedNamespaces(namespaceSelectorString string) ([]v1.Namespace, error)
- func (r *GenericReplicator) ListNamespaces(listOptions ...metav1.ListOptions) ([]v1.Namespace, error)
- func (r *GenericReplicator) NamespaceAdded(ns *v1.Namespace)
- func (r *GenericReplicator) NamespaceUpdated(nsOld *v1.Namespace, nsNew *v1.Namespace)
- func (r *GenericReplicator) ObjectFromStore(key string) (interface{}, error)
- func (r *GenericReplicator) ResourceAdded(obj interface{})
- func (r *GenericReplicator) ResourceDeleted(source interface{})
- func (r *GenericReplicator) ResourceUpdated(old interface{}, new interface{})
- func (r *GenericReplicator) Run()
- func (r *GenericReplicator) Synced() bool
- type NamespaceWatcher
- type Replicator
- type ReplicatorConfig
- type UpdateFunc
- type UpdateFuncs
Constants ¶
const ( ReplicateTo = "kube-external-sync.io/replicate-to" ReplicateToMatching = "kube-external-sync.io/replicate-to-matching" StripLabels = "kube-external-sync.io/strip-labels" StripAnnotations = "kube-external-sync.io/strip-annotations" TopLevelDomain = "kube-external-sync.io/top-level-domain" TLDSecretName = "kube-external-sync.io/tld-secret-name" ExternalNameSuffix = "kube-external-sync.io/external-name-suffix" KeepOwnerReferences = "kube-external-sync.io/keep-owner-references" )
Annotations that are added to resources and used by this Controller
const ( ReplicatedFromAnnotation = "kube-external-sync.io/replicated-from" ReplicatedAtAnnotation = "kube-external-sync.io/replicated-at" ReplicatedFromVersionAnnotation = "kube-external-sync.io/replicated-from-version" )
Annotations that are added to replicated resources by this Controller
const ( DefaultExternalNameSuffix = "svc.cluster.local" TraefikMeshExternalNameSuffix = "traefik.mesh" )
ExternalName suffix options
const LastAppliedConfigurationAnnotationKey = "kubectl.kubernetes.io/last-applied-configuration"
LastAppliedConfigurationAnnotationKey is an annotation created by Kubernetes to keep track of last config
const ManagedByLabelKey = "app.kubernetes.io/managed-by"
ManagedByLabelKey is an label key appended to kube-external-sync managed resources.
const ManagedByLabelValue = "kube-external-sync"
ManagedByLabelValue is an label value appended to kube-external-sync managed resources.
Variables ¶
var DefaultStripAnnotations = map[string]struct{}{ LastAppliedConfigurationAnnotationKey: {}, ReplicateTo: {}, ReplicateToMatching: {}, StripLabels: {}, StripAnnotations: {}, TopLevelDomain: {}, TLDSecretName: {}, }
DefaultStripAnnotations contains the annotations that are to be stripped when replicating a resource
Functions ¶
func BuildStrictRegex ¶
func CopyAnnotations ¶
CopyAnnotations copies all non-controlled annotations
func CopyLabels ¶
CopyLabels copies all non-controlled Labels
func IsManagedBy ¶
IsManagedBy checks the sources labels to see if the resource is currently being managed-by this controller
func MatchStrictRegex ¶
func MustGetKey ¶
func MustGetKey(obj interface{}) string
MustGetKey creates a key from Kubernetes resource in the format <namespace>/<name>
func MustGetObject ¶
MustGetObject casts the object into a Kubernetes `metav1.Object`
func PrepareAnnotations ¶
func PrepareAnnotations(source metav1.ObjectMeta) map[string]string
PrepareAnnotations prepares a new map of annotations based on the provided resource
func PrepareLabels ¶
func PrepareLabels(source metav1.ObjectMeta) map[string]string
PrepareLabels prepares a new map of labels based on the provided resource
func PrepareOwnerReferences ¶
func PrepareOwnerReferences(source metav1.ObjectMeta) []metav1.OwnerReference
PrepareOwnerReferences prepares the OwnerReferences array
func PrepareTLD ¶ added in v1.1.0
func StringToPatternList ¶
Types ¶
type GenericReplicator ¶
type GenericReplicator struct { ReplicatorConfig Store cache.Store Controller cache.Controller Context context.Context UpdateFuncs UpdateFuncs // ReplicateToList is a set that caches the names of all resources that have a // "replicate-to" annotation. ReplicateToList map[string]struct{} // ReplicateToMatchingList is a set that caches the names of all resources // that have a "replicate-to-matching" annotation. ReplicateToMatchingList map[string]labels.Selector }
GenericReplicator represents the top-level Replicator
func NewGenericReplicator ¶
func NewGenericReplicator(ctx context.Context, config ReplicatorConfig) *GenericReplicator
NewGenericReplicator creates a new GenericReplicator
func (*GenericReplicator) HasDefaultIngressHostname ¶ added in v1.2.0
func (r *GenericReplicator) HasDefaultIngressHostname() bool
HasDefaultIngressHostname returns a boolean value determining whether or not a default Ingress hostname was provided.
func (*GenericReplicator) ListFilteredNamespaces ¶
func (r *GenericReplicator) ListFilteredNamespaces(current string, patterns string) ([]v1.Namespace, error)
ListFilteredNamespaces retrieve list of namespaces that match the provided patterns
func (*GenericReplicator) ListLabelSelectedNamespaces ¶
func (r *GenericReplicator) ListLabelSelectedNamespaces(namespaceSelectorString string) ([]v1.Namespace, error)
ListLabelSelectedNamespaces retrieves list of namespaces that meet the label selector
func (*GenericReplicator) ListNamespaces ¶
func (r *GenericReplicator) ListNamespaces(listOptions ...metav1.ListOptions) ([]v1.Namespace, error)
ListNamespaces is a simple wrapper for listing namespaces
func (*GenericReplicator) NamespaceAdded ¶
func (r *GenericReplicator) NamespaceAdded(ns *v1.Namespace)
NamespaceAdded replicates resources with ReplicateTo and ReplicateToMatching annotations into newly created namespaces.
func (*GenericReplicator) NamespaceUpdated ¶
func (r *GenericReplicator) NamespaceUpdated(nsOld *v1.Namespace, nsNew *v1.Namespace)
NamespaceUpdated checks if namespace's labels changed and deletes any 'replicate-to-matching' resources the namespace no longer qualifies for. Then it attempts to replicate resources into the updated ns based on the updated set of labels
func (*GenericReplicator) ObjectFromStore ¶
func (r *GenericReplicator) ObjectFromStore(key string) (interface{}, error)
ObjectFromStore gets object from store cache
func (*GenericReplicator) ResourceAdded ¶
func (r *GenericReplicator) ResourceAdded(obj interface{})
ResourceAdded checks resources with ReplicateTo or ReplicateFromAnnotation annotation
func (*GenericReplicator) ResourceDeleted ¶
func (r *GenericReplicator) ResourceDeleted(source interface{})
ResourceDeleted watches for the deletion of resources
func (*GenericReplicator) ResourceUpdated ¶
func (r *GenericReplicator) ResourceUpdated(old interface{}, new interface{})
ResourceUpdated checks resources with ReplicateTo or ReplicateFromAnnotation annotation
func (*GenericReplicator) Synced ¶
func (r *GenericReplicator) Synced() bool
Synced reports whether or not the controller has been synced
type NamespaceWatcher ¶
type NamespaceWatcher struct { NamespaceStore cache.Store NamespaceController cache.Controller AddFuncs []AddFunc UpdateFuncs []UpdateFunc // contains filtered or unexported fields }
func (*NamespaceWatcher) OnNamespaceAdded ¶
func (nw *NamespaceWatcher) OnNamespaceAdded(ctx context.Context, client kubernetes.Interface, resyncPeriod time.Duration, addFunc AddFunc)
OnNamespaceAdded will add another method to a list of functions to be called when a new namespace is created
func (*NamespaceWatcher) OnNamespaceUpdated ¶
func (nw *NamespaceWatcher) OnNamespaceUpdated(ctx context.Context, client kubernetes.Interface, resyncPeriod time.Duration, updateFunc UpdateFunc)
OnNamespaceUpdated will add another method to a list of functions to be called when a namespace is updated
type Replicator ¶
type ReplicatorConfig ¶
type ReplicatorConfig struct { Kind string Client kubernetes.Interface TraefikClient *versioned.Clientset ResyncPeriod time.Duration DefaultIngressHostname string ListFunc cache.ListFunc WatchFunc cache.WatchFunc ObjType runtime.Object }
ReplicatorConfig represents configuration for individual resource controllers