Documentation ¶
Overview ¶
Package sync is used to sync the manifests defined in the GitSync object into the local cluster.
Index ¶
- func CascadeDeletion(ctx context.Context, k8sClient client.Client, cache LiveStateCache, ...) error
- func GetLiveManagedObjects(cache LiveStateCache, gitSync *v1alpha1.GitSync) (map[kube.ResourceKey]*unstructured.Unstructured, error)
- func KeyOfGitSync(gitSync *v1alpha1.GitSync) string
- func NewIgnoreNormalizer(overrides map[string]ResourceOverride) (diff.Normalizer, error)
- func NewNoopNormalizer() diff.Normalizer
- func ProcessGitSyncDeletion(ctx context.Context, gitSync *v1alpha1.GitSync, s *Syncer) error
- func StateDiffs(configs, lives []*unstructured.Unstructured, ...) (*diff.DiffResultList, error)
- type LiveStateCache
- type NoopNormalizer
- type ObjectUpdatedHandler
- type Option
- type OverrideIgnoreDiff
- type ResourceFilter
- type ResourceIgnoreDifferences
- type ResourceInfo
- type ResourceOverride
- type ResourceType
- type Syncer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CascadeDeletion ¶
func CascadeDeletion(ctx context.Context, k8sClient client.Client, cache LiveStateCache, gitSync *v1alpha1.GitSync) error
CascadeDeletion performs cascading deletion of live managed objects using GitSync. It utilizes the provided context, Kubernetes client, cache, and GitSync configuration. Returns an error if the deletion process encounters any issues.
func GetLiveManagedObjects ¶
func GetLiveManagedObjects(cache LiveStateCache, gitSync *v1alpha1.GitSync) (map[kube.ResourceKey]*unstructured.Unstructured, error)
GetLiveManagedObjects retrieves live managed objects from the provided cache for the given GitSync configuration. It returns a map of Kubernetes resource keys to unstructured objects and an error if any.
func KeyOfGitSync ¶
KeyOfGitSync returns the unique key of a gitsync
func NewIgnoreNormalizer ¶
func NewIgnoreNormalizer(overrides map[string]ResourceOverride) (diff.Normalizer, error)
NewIgnoreNormalizer creates diff normalizer which removes ignored fields according to given application spec and resource overrides
func NewNoopNormalizer ¶
func NewNoopNormalizer() diff.Normalizer
NewNoopNormalizer returns normalizer that does not apply any resource modifications
func ProcessGitSyncDeletion ¶
func StateDiffs ¶
func StateDiffs( configs, lives []*unstructured.Unstructured, overrides map[string]ResourceOverride, diffOpts []diff.Option) (*diff.DiffResultList, error)
StateDiffs will apply all required normalizations and calculate the diffs between the live and the config/desired states.
Types ¶
type LiveStateCache ¶
type LiveStateCache interface { // GetClusterCache returns synced cluster cache GetClusterCache() (clustercache.ClusterCache, error) // GetManagedLiveObjs returns state of live nodes which correspond to target nodes of specified gitsync. GetManagedLiveObjs(gitsync *v1alpha1.GitSync, targetObjs []*unstructured.Unstructured) (map[kube.ResourceKey]*unstructured.Unstructured, error) // Init must be executed before cache can be used Init(numaLogger *logger.NumaLogger) error // PopulateResourceInfo is called by the cache to update ResourceInfo struct for a managed resource PopulateResourceInfo(un *unstructured.Unstructured, isRoot bool) (interface{}, bool) }
LiveStateCache is a cluster caching that stores resource references and ownership references. It also stores custom metadata for resources managed by GitSyncs. It always ensures the cache is up-to-date before returning the resources.
func NewLiveStateCache ¶
func NewLiveStateCache( clusterCacheConfig *rest.Config, ) LiveStateCache
type NoopNormalizer ¶
type NoopNormalizer struct { }
func (*NoopNormalizer) Normalize ¶
func (n *NoopNormalizer) Normalize(un *unstructured.Unstructured) error
type ObjectUpdatedHandler ¶
type ObjectUpdatedHandler = func(managedByGitSync map[string]bool, ref v1.ObjectReference)
type Option ¶
type Option func(*options)
func WithTaskInterval ¶
WithTaskInterval sets the interval of picking up a task from the work queue.
func WithWorkers ¶
WithWorkers sets the number of workers working on autoscaling.
type OverrideIgnoreDiff ¶
type OverrideIgnoreDiff struct { // JSONPointers is a JSON path list following the format defined in RFC4627 (https://datatracker.ietf.org/doc/html/rfc6902#section-3) JSONPointers []string }
OverrideIgnoreDiff contains configurations about how fields should be ignored during diffs between the desired state and live state
type ResourceFilter ¶
type ResourceFilter struct {
// contains filtered or unexported fields
}
ResourceFilter filter resources based on allowed Resource Types
func (*ResourceFilter) IsExcludedResource ¶
func (n *ResourceFilter) IsExcludedResource(group, kind, _ string) bool
type ResourceIgnoreDifferences ¶
type ResourceIgnoreDifferences struct { Group string Kind string Name string Namespace string JSONPointers []string }
ResourceIgnoreDifferences contains resource filter and list of json paths which should be ignored during comparison with live state.
type ResourceInfo ¶
type ResourceInfo struct { GitSyncName string Health *health.HealthStatus // contains filtered or unexported fields }
type ResourceOverride ¶
type ResourceOverride struct {
IgnoreDifferences OverrideIgnoreDiff
}
ResourceOverride holds configuration to customize resource diffing and health assessment
type ResourceType ¶
type Syncer ¶
type Syncer struct {
// contains filtered or unexported fields
}
func NewSyncer ¶
func NewSyncer( client client.Client, config *rest.Config, metricServer *metrics.MetricsServer, kubectl kubeUtil.Kubectl, opts ...Option, ) *Syncer
NewSyncer returns a Synchronizer instance.
func (*Syncer) Start ¶
Start function starts the synchronizer worker group. Each worker keeps picking up tasks (which contains GitSync keys) to sync the resources.
func (*Syncer) StartWatching ¶
StartWatching put a key (namespace/name) into the synchronizer
func (*Syncer) StopWatching ¶
StopWatching stops watching on the key (namespace/name)