syncer

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultGVRs = []schema.GroupVersionResource{
	{Group: "", Version: "v1", Resource: "namespaces"},
	{Group: "scheduling.k8s.io", Version: "v1", Resource: "priorityclasses"},
	{Group: "storage.k8s.io", Version: "v1", Resource: "storageclasses"},
	{Group: "", Version: "v1", Resource: "persistentvolumeclaims"},
	{Group: "", Version: "v1", Resource: "nodes"},
	{Group: "", Version: "v1", Resource: "persistentvolumes"},
	{Group: "", Version: "v1", Resource: "pods"},
}

DefaultGVRs is a list of GroupVersionResource that we sync by default (configurable with Options), which is a suitable resource set for the vanilla scheduler.

Note that this order matters - When first importing resources, we want to sync namespaces first, then priorityclasses, storageclasses...

Functions

This section is empty.

Types

type Clients

type Clients struct {
	// SrcDynamicClient is the dynamic client for the source cluster, which the resource is supposed to be copied from.
	SrcDynamicClient dynamic.Interface
	// DestDynamicClient is the dynamic client for the destination cluster, which the resource is supposed to be copied to.
	DestDynamicClient dynamic.Interface
	RestMapper        meta.RESTMapper
}

Note: Clients and its fields are exposed intentionally so that users can use it in MutatingFunction and FilteringFunction.

type Event

type Event int

Event is a type of events that occur in the source cluster.

const (
	Add Event = iota
	Update
)

type FilteringFunction

type FilteringFunction func(ctx context.Context, resource *unstructured.Unstructured, clients *Clients, event Event) (bool, error)

FilteringFunction is a function that filters a resource. If it returns false, the resource will not be imported.

type MutatingFunction

type MutatingFunction func(ctx context.Context, resource *unstructured.Unstructured, clients *Clients, event Event) (*unstructured.Unstructured, error)

MutatingFunction is a function that mutates a resource before importing it.

type Options

type Options struct {
	// GVRsToSync is a list of GroupVersionResource that will be synced.
	// If GVRsToSync is nil, defaultGVRs are used.
	GVRsToSync []schema.GroupVersionResource
	// AdditionalMutatingFunctions is a list of mutating functions that users add.
	AdditionalMutatingFunctions map[schema.GroupVersionResource]MutatingFunction
	// AdditionalFilteringFunctions is a list of filtering functions that users add.
	AdditionalFilteringFunctions map[schema.GroupVersionResource]FilteringFunction
}

type Service

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

func New

func New(srcDynamicClient, destDynamicClient dynamic.Interface, restMapper meta.RESTMapper, options Options) *Service

func (*Service) Run

func (s *Service) Run(ctx context.Context) error

Jump to

Keyboard shortcuts

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