kubernetes

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Synchronizer = "synchronizer"
	UpdateError  = "cached_client_update_total"
)

Variables

This section is empty.

Functions

func Add

func Add(mgr manager.Manager, hubconfig *rest.Config, syncid *types.NamespacedName, interval int, hub, standalone bool) error

Add creates the default syncrhonizer and add the start function as runnable into manager.

func GetAppsubReportStatus added in v0.13.0

func GetAppsubReportStatus(lclient client.Client, hub, standalone bool, appsubNs, appsubName string) (*v1alpha1.SubscriptionStatus, error)

Types

type Extension

type Extension interface {
	GetHostFromObject(metav1.Object) *types.NamespacedName
	SetSynchronizerToObject(metav1.Object, *types.NamespacedName) error
	SetHostToObject(metav1.Object, types.NamespacedName, *types.NamespacedName) error
	IsObjectOwnedByHost(metav1.Object, types.NamespacedName, *types.NamespacedName) bool
	IsObjectOwnedBySynchronizer(metav1.Object, *types.NamespacedName) bool
}

Extension defines the extension features of synchronizer

type KubeSynchronizer

type KubeSynchronizer struct {
	Interval              int
	LocalClient           client.Client
	LocalNonCachedClient  client.Client
	RemoteClient          client.Client
	RemoteNonCachedClient client.Client

	DynamicClient dynamic.Interface
	RestMapper    meta.RESTMapper

	SynchronizerID *types.NamespacedName // managed cluster Namespaced name
	Extension      Extension

	SkipAppSubStatusResDel bool // used by helm subscriber to skip resource delete based on AppSubStatus
	// contains filtered or unexported fields
}

KubeSynchronizer handles resources to a kube endpoint.

func CreateSynchronizer

func CreateSynchronizer(config, remoteConfig *rest.Config, scheme *runtime.Scheme, syncid *types.NamespacedName,
	interval int, ext Extension, hub, standalone bool) (*KubeSynchronizer, error)

CreateSynchronizer createa an instance of synchrizer with give api-server config.

func GetDefaultSynchronizer

func GetDefaultSynchronizer() *KubeSynchronizer

GetDefaultSynchronizer - return the default kubernetse synchronizer.

func (*KubeSynchronizer) DeleteSingleSubscribedResource added in v0.5.0

func (sync *KubeSynchronizer) DeleteSingleSubscribedResource(hostSub types.NamespacedName,
	pkgStatus appSubStatusV1alpha1.SubscriptionUnitStatus) error

DeleteSingleSubscribedResource delete a subcribed resource from a appsub.

func (*KubeSynchronizer) GetInterval

func (sync *KubeSynchronizer) GetInterval() int

func (*KubeSynchronizer) GetLocalClient

func (sync *KubeSynchronizer) GetLocalClient() client.Client

func (*KubeSynchronizer) GetLocalNonCachedClient added in v0.5.0

func (sync *KubeSynchronizer) GetLocalNonCachedClient() client.Client

func (*KubeSynchronizer) GetRemoteClient

func (sync *KubeSynchronizer) GetRemoteClient() client.Client

func (*KubeSynchronizer) GetRemoteNonCachedClient added in v0.5.0

func (sync *KubeSynchronizer) GetRemoteNonCachedClient() client.Client

func (*KubeSynchronizer) IsResourceNamespaced

func (sync *KubeSynchronizer) IsResourceNamespaced(rsc *unstructured.Unstructured) bool

func (*KubeSynchronizer) OverrideResource added in v0.5.0

func (sync *KubeSynchronizer) OverrideResource(hostSub types.NamespacedName, resource *ResourceUnit) (*unstructured.Unstructured, error)

OverrideResource updates resource based on the hosting appsub before the resource is deployed.

func (*KubeSynchronizer) ProcessSubResources added in v0.5.0

func (sync *KubeSynchronizer) ProcessSubResources(appsub *appv1alpha1.Subscription, resources []ResourceUnit,
	allowlist, denyList map[string]map[string]string, isAdmin, failOnStatusErr bool) error

func (*KubeSynchronizer) PurgeAllSubscribedResources added in v0.5.0

func (sync *KubeSynchronizer) PurgeAllSubscribedResources(appsub *appv1alpha1.Subscription) error

PurgeSubscribedResources purge all resources deployed by the appsub.

func (*KubeSynchronizer) Start

func (sync *KubeSynchronizer) Start(ctx context.Context) error

this will be triggered by the manager.

func (*KubeSynchronizer) SyncAppsubClusterStatus added in v0.5.0

func (sync *KubeSynchronizer) SyncAppsubClusterStatus(appsub *appv1.Subscription,
	appsubClusterStatus SubscriptionClusterStatus,
	skipOrphanDelete *bool, skipUpdate *bool) error

func (*KubeSynchronizer) UpdateAppsubOverallStatus added in v0.13.0

func (sync *KubeSynchronizer) UpdateAppsubOverallStatus(appsub *appv1.Subscription,
	deployFailed bool, message string) error

type ResourceUnit added in v0.5.0

type ResourceUnit struct {
	Resource *unstructured.Unstructured
	Gvk      schema.GroupVersionKind
}

type SubscriptionClusterStatus added in v0.5.0

type SubscriptionClusterStatus struct {
	Cluster                   string
	AppSub                    types.NamespacedName /* hosting appsub */
	Action                    string               /* "APPLY" or "DELETE" */
	SubscriptionPackageStatus []SubscriptionUnitStatus
}

type SubscriptionExtension

type SubscriptionExtension struct {
	IngoredGroupKindMap map[schema.GroupKind]bool
	// contains filtered or unexported fields
}

SubscriptionExtension provides default extension settings

func (*SubscriptionExtension) GetHostFromObject

func (se *SubscriptionExtension) GetHostFromObject(obj metav1.Object) *types.NamespacedName

GetHostFromObject defines update host status function for object

func (*SubscriptionExtension) IsObjectOwnedByHost

func (se *SubscriptionExtension) IsObjectOwnedByHost(obj metav1.Object, host types.NamespacedName, syncid *types.NamespacedName) bool

IsObjectOwnedByHost defines update host status function for object

func (*SubscriptionExtension) IsObjectOwnedBySynchronizer

func (se *SubscriptionExtension) IsObjectOwnedBySynchronizer(obj metav1.Object, syncid *types.NamespacedName) bool

IsObjectOwnedBySynchronizer defines update host status function for object

func (*SubscriptionExtension) SetHostToObject

func (se *SubscriptionExtension) SetHostToObject(obj metav1.Object, host types.NamespacedName, syncid *types.NamespacedName) error

SetHostToObject defines update host status function for object

func (*SubscriptionExtension) SetSynchronizerToObject

func (se *SubscriptionExtension) SetSynchronizerToObject(obj metav1.Object, syncid *types.NamespacedName) error

SetSynchronizerToObject defines update host status function for object

type SubscriptionUnitStatus added in v0.5.0

type SubscriptionUnitStatus struct {
	Name       string
	Namespace  string
	APIVersion string
	Kind       string
	Phase      string
	Message    string
}

Jump to

Keyboard shortcuts

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