conversion

package
v0.0.0-...-4d19ac6 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildVirtualEvent

func BuildVirtualEvent(cluster string, pEvent *v1.Event, vObj client.Object) *v1.Event

func BuildVirtualPersistentVolume

func BuildVirtualPersistentVolume(pPV *v1.PersistentVolume, vPVC *v1.PersistentVolumeClaim) *v1.PersistentVolume

func BuildVirtualPriorityClass

func BuildVirtualPriorityClass(cluster string, pPriorityClass *v1scheduling.PriorityClass) *v1scheduling.PriorityClass

func BuildVirtualStorageClass

func BuildVirtualStorageClass(cluster string, pStorageClass *storagev1.StorageClass) *storagev1.StorageClass

func CheckDWPodConditionEquality

func CheckDWPodConditionEquality(pPod, vPod *v1.Pod) *v1.PodStatus

CheckDWPodConditionEquality check whether super control plane Pod Status and virtual Pod Status are logically equal. In most cases, the source of truth is super pod status, because super control plane actually own the physical resources, status is reported by **real** kubelet. Besides, kubernetes allows user-defined conditions, such as pod readiness gate, it will report readiness state to pod conditions. In other words, the source of truth for user-defined pod conditions should be tenant side controller, only the condition reported by kubelet should keep consistent with super. It is not recommended that webhook in super append other readiness gate to pod. we left them unchanged in super, don't sync them upward to tenant side. ref https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-readiness-gate

func Equality

func Equality(syncerConfig *config.SyncerConfiguration, vc *v1alpha1.VirtualCluster) *vcEquality

func GetConfigMapName

func GetConfigMapName(name string) (string, string)

func GetKubeConfigOfVC

func GetKubeConfigOfVC(c v1core.CoreV1Interface, vc *v1alpha1.VirtualCluster) ([]byte, error)

func GetVirtualNamespace

func GetVirtualNamespace(nsLister listersv1.NamespaceLister, pNamespace string) (cluster, namespace string, err error)

GetVirtualNamespace is used to find the corresponding namespace in tenant control plane for objects created in super control plane originally, e.g., events.

func GetVirtualOwner

func GetVirtualOwner(meta client.Object) (cluster, namespace string)

func IsControlPlaneService

func IsControlPlaneService(service *v1.Service, cluster string) bool

IsControlPlaneService will return if the namespacedName matches the proper NamespacedName in the tenant control plane

func ResetMetadata

func ResetMetadata(obj metav1.Object)

func ToClusterKey

func ToClusterKey(vc *v1alpha1.VirtualCluster) string

ToClusterKey makes a unique key which is used to create the root namespace in super control plane for a virtual cluster. To avoid name conflict, the key uses the format <namespace>-<hash>-<name>

func ToSuperClusterNamespace

func ToSuperClusterNamespace(cluster, ns string) string

func WithSuperClusterLabels

func WithSuperClusterLabels(labels map[string]string) map[string]string

Types

type Conversion

type Conversion interface {
	BuildSuperClusterObject(cluster string, obj client.Object) (client.Object, error)
	BuildSuperClusterNamespace(cluster string, obj client.Object) (client.Object, error)
}

func Convertor

func Convertor(syncerConfig *config.SyncerConfiguration, mcc mc.MultiClusterInterface) Conversion

Convertor implement the Conversion interface.

type PodMutateCtx

type PodMutateCtx struct {
	Mc          *mc.MultiClusterController
	ClusterName string
	PPod        *v1.Pod
	VPod        *v1.Pod
}

PodMutateCtx is the context passed to the pod mutator

func (*PodMutateCtx) Mutate

func (p *PodMutateCtx) Mutate(ms ...PodMutator) error

Mutate convert the meta data of containers to super control plane namespace. replace the service account token volume mounts to super control plane side one.

type PodMutateInterface

type PodMutateInterface interface {
	Mutate(ms ...PodMutator) error
}

type PodMutator

type PodMutator func(p *PodMutateCtx) error

func PodAddExtensionMeta

func PodAddExtensionMeta(vPod *v1.Pod) PodMutator

for now, only Deployment Pods are mutated.

func PodMutateDefault

func PodMutateDefault(vPod *v1.Pod, saSecretMap map[string]string, services []*v1.Service, nameServer string, dnsOption []v1.PodDNSConfigOption) PodMutator

type SecretMutateInterface

type SecretMutateInterface interface {
	Mutate(vSecret *v1.Secret, clusterName string)
}

type ServiceMutateInterface

type ServiceMutateInterface interface {
	Mutate(vService *v1.Service)
}

type VCMutateInterface

type VCMutateInterface interface {
	Pod(pPod, vPod *v1.Pod) PodMutateInterface
	Service(pService *v1.Service) ServiceMutateInterface
	ServiceAccountTokenSecret(pSecret *v1.Secret) SecretMutateInterface
}

func VC

Directories

Path Synopsis
Package envvars is the package that build the environment variables that kubernetes provides to the containers run by it.
Package envvars is the package that build the environment variables that kubernetes provides to the containers run by it.

Jump to

Keyboard shortcuts

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