Documentation ¶
Index ¶
- Constants
- func ClusterMatches(cluster *clusterv1alpha1.Cluster, affinity v1alpha1.ClusterAffinity) bool
- func ClusterNamesMatches(cluster *clusterv1alpha1.Cluster, clusterNames []string) bool
- func ContextForChannel(parentCh <-chan struct{}) (context.Context, context.CancelFunc)
- func ConvertToClusterNames(clusters []workv1alpha1.TargetCluster) sets.String
- func CreateClusterIfNotExist(client client.Client, clusterObj *v1alpha1.Cluster) error
- func CreateClusterRole(client kubeclient.Interface, clusterRoleObj *rbacv1.ClusterRole) (*rbacv1.ClusterRole, error)
- func CreateClusterRoleBinding(client kubeclient.Interface, clusterRoleBindingObj *rbacv1.ClusterRoleBinding) (*rbacv1.ClusterRoleBinding, error)
- func CreateNamespace(client kubeclient.Interface, namespaceObj *corev1.Namespace) (*corev1.Namespace, error)
- func CreateNamespaceIfNotExist(client client.Client, namespaceObj *corev1.Namespace) error
- func CreateSecret(client kubeclient.Interface, secret *corev1.Secret) (*corev1.Secret, error)
- func CreateServiceAccount(client kubeclient.Interface, saObj *corev1.ServiceAccount) (*corev1.ServiceAccount, error)
- func DeleteClusterRole(client kubeclient.Interface, name string) error
- func DeleteClusterRoleBinding(client kubeclient.Interface, name string) error
- func DeleteNamespace(client kubeclient.Interface, namespace string) error
- func DeleteSecret(client kubeclient.Interface, namespace, name string) error
- func DeleteServiceAccount(client kubeclient.Interface, namespace, name string) error
- func GetBindingClusterNames(binding *workv1alpha1.ResourceBinding) []string
- func GetCluster(hostClient client.Client, clusterName string) (*v1alpha1.Cluster, error)
- func GetLabelValue(labels map[string]string, labelKey string) string
- func GetSumOfReplicas(clusters []workv1alpha1.TargetCluster) int32
- func GetTargetSecret(client kubeclient.Interface, secretReferences []corev1.ObjectReference, ...) (*corev1.Secret, error)
- func IsBindingReplicasChanged(bindingSpec *workv1alpha1.ResourceBindingSpec, ...) bool
- func IsClusterReady(clusterStatus *v1alpha1.ClusterStatus) bool
- func IsClusterRoleBindingExist(client kubeclient.Interface, name string) (bool, error)
- func IsClusterRoleExist(client kubeclient.Interface, name string) (bool, error)
- func IsNamespaceExist(client kubeclient.Interface, namespace string) (bool, error)
- func IsServiceAccountExist(client kubeclient.Interface, namespace string, name string) (bool, error)
- func MergeAnnotation(obj *unstructured.Unstructured, annotationKey string, annotationValue string)
- func MergeAnnotations(dst *unstructured.Unstructured, src *unstructured.Unstructured)
- func MergeLabel(obj *unstructured.Unstructured, labelKey string, labelValue string)
- func PatchSecret(client kubeclient.Interface, namespace, name string, pt types.PatchType, ...) error
- func ResourceMatchSelectors(resource *unstructured.Unstructured, selectors ...v1alpha1.ResourceSelector) bool
- func ResourceMatches(resource *unstructured.Unstructured, rs v1alpha1.ResourceSelector) bool
- func SetLeaseOwnerFunc(c client.Client, clusterName string) func(lease *coordinationv1.Lease) error
- type AsyncWorker
- type ClientOption
- type ClusterClient
- type DynamicClusterClient
- type KeyFunc
- type QueueKey
- type ReconcileFunc
- type Resource
- func (r *Resource) Add(rl corev1.ResourceList)
- func (r *Resource) AddPodRequest(pod *corev1.Pod)
- func (r *Resource) AddScalar(name corev1.ResourceName, quantity int64)
- func (r *Resource) ResourceList() corev1.ResourceList
- func (r *Resource) SetMaxResource(rl corev1.ResourceList)
- func (r *Resource) SetScalar(name corev1.ResourceName, quantity int64)
- type SkippedResourceConfig
- func (r *SkippedResourceConfig) DisableGroup(g string)
- func (r *SkippedResourceConfig) GroupDisabled(g string) bool
- func (r *SkippedResourceConfig) GroupVersionDisabled(gv schema.GroupVersion) bool
- func (r *SkippedResourceConfig) GroupVersionKindDisabled(gvk schema.GroupVersionKind) bool
- func (r *SkippedResourceConfig) Parse(c string) error
- type SpreadGroup
Constants ¶
const ( // ServiceNamespaceLabel is added to work object, which is report by member cluster, to specify service namespace associated with EndpointSlice. ServiceNamespaceLabel = "endpointslice.karmada.io/namespace" // ServiceNameLabel is added to work object, which is report by member cluster, to specify service name associated with EndpointSlice. ServiceNameLabel = "endpointslice.karmada.io/name" // PropagationInstruction is used to mark a resource(like Work) propagation instruction. // Valid values includes: // - suppressed: indicates that the resource should not be propagated. // // Note: This instruction is intended to set on Work objects to indicate the Work should be ignored by // execution controller. The instruction maybe deprecated once we extend the Work API and no other scenario want this. PropagationInstruction = "propagation.karmada.io/instruction" )
const ( // PolicyPlacementAnnotation is the annotation of a policy's placement. // It is intended to set on ResourceBinding or ClusterResourceBinding objects to record applied placement declaration. // The placement could be either PropagationPolicy's or ClusterPropagationPolicy's. PolicyPlacementAnnotation = "policy.karmada.io/applied-placement" // AppliedOverrides is the annotation which used to record override items an object applied. // It is intended to set on Work objects to record applied overrides. // The overrides items should be sorted alphabetically in ascending order by OverridePolicy's name. AppliedOverrides = "policy.karmada.io/applied-overrides" // AppliedClusterOverrides is the annotation which used to record override items an object applied. // It is intended to set on Work objects to record applied overrides. // The overrides items should be sorted alphabetically in ascending order by ClusterOverridePolicy's name. AppliedClusterOverrides = "policy.karmada.io/applied-cluster-overrides" )
Define annotations used by karmada system.
const ( // ClusterControllerFinalizer is added to Cluster to ensure Work as well as the // execution space (namespace) is deleted before itself is deleted. ClusterControllerFinalizer = "karmada.io/cluster-controller" // ExecutionControllerFinalizer is added to Work to ensure manifests propagated to member cluster // is deleted before Work itself is deleted. ExecutionControllerFinalizer = "karmada.io/execution-controller" )
Define finalizers used by karmada system.
const ( // ProviderField indicates the 'provider' field of a cluster ProviderField = "provider" // RegionField indicates the 'region' field of a cluster RegionField = "region" // ZoneField indicates the 'zone' field of a cluster ZoneField = "zone" )
const ( // DeploymentKind indicates the target resource is a deployment DeploymentKind = "Deployment" // ServiceKind indicates the target resource is a service ServiceKind = "Service" // IngressKind indicates the target resource is a ingress IngressKind = "Ingress" // JobKind indicates the target resource is a job JobKind = "Job" // PodKind indicates the target resource is a pod PodKind = "Pod" // ServiceAccountKind indicates the target resource is a serviceaccount ServiceAccountKind = "ServiceAccount" // ReplicaSetKind indicates the target resource is a replicaset ReplicaSetKind = "ReplicaSet" // StatefulSetKind indicates the target resource is a statefulset StatefulSetKind = "StatefulSet" // DaemonSetKind indicates the target resource is a daemonset DaemonSetKind = "DaemonSet" // EndpointSliceKind indicates the target resource is a endpointslice EndpointSliceKind = "EndpointSlice" // PersistentVolumeClaimKind indicated the target resource is a persistentvolumeclaim PersistentVolumeClaimKind = "PersistentVolumeClaim" // ServiceExportKind indicates the target resource is a serviceexport crd ServiceExportKind = "ServiceExport" // ServiceImportKind indicates the target resource is a serviceimport crd ServiceImportKind = "ServiceImport" // CRDKind indicated the target resource is a CustomResourceDefinition CRDKind = "CustomResourceDefinition" )
Define resource kind.
const ( // SpecField indicates the 'spec' field of a resource SpecField = "spec" // ReplicasField indicates the 'replicas' field of a resource ReplicasField = "replicas" // TemplateField indicates the 'template' field of a resource TemplateField = "template" )
Define resource filed
const (
// NamespaceClusterLease is the namespace which cluster lease are stored.
NamespaceClusterLease = "karmada-cluster"
)
const (
// NamespaceKarmadaSystem is the karmada system namespace.
NamespaceKarmadaSystem = "karmada-system"
)
const (
// PropagationInstructionSuppressed indicates that the resource should not be propagated.
PropagationInstructionSuppressed = "suppressed"
)
Variables ¶
This section is empty.
Functions ¶
func ClusterMatches ¶ added in v0.3.0
func ClusterMatches(cluster *clusterv1alpha1.Cluster, affinity v1alpha1.ClusterAffinity) bool
ClusterMatches tells if specific cluster matches the affinity.
func ClusterNamesMatches ¶ added in v0.3.0
func ClusterNamesMatches(cluster *clusterv1alpha1.Cluster, clusterNames []string) bool
ClusterNamesMatches tells if specific cluster matches the clusterNames affinity.
func ContextForChannel ¶ added in v0.8.0
func ContextForChannel(parentCh <-chan struct{}) (context.Context, context.CancelFunc)
ContextForChannel derives a child context from a parent channel.
The derived context's Done channel is closed when the returned cancel function is called or when the parent channel is closed, whichever happens first.
Note the caller must *always* call the CancelFunc, otherwise resources may be leaked.
func ConvertToClusterNames ¶ added in v0.8.0
func ConvertToClusterNames(clusters []workv1alpha1.TargetCluster) sets.String
ConvertToClusterNames will convert a cluster slice to clusterName's sets.String
func CreateClusterIfNotExist ¶ added in v0.8.0
CreateClusterIfNotExist try to create the cluster if it does not exist.
func CreateClusterRole ¶
func CreateClusterRole(client kubeclient.Interface, clusterRoleObj *rbacv1.ClusterRole) (*rbacv1.ClusterRole, error)
CreateClusterRole just try to create the ClusterRole.
func CreateClusterRoleBinding ¶
func CreateClusterRoleBinding(client kubeclient.Interface, clusterRoleBindingObj *rbacv1.ClusterRoleBinding) (*rbacv1.ClusterRoleBinding, error)
CreateClusterRoleBinding just try to create the ClusterRoleBinding.
func CreateNamespace ¶
func CreateNamespace(client kubeclient.Interface, namespaceObj *corev1.Namespace) (*corev1.Namespace, error)
CreateNamespace just try to create the namespace.
func CreateNamespaceIfNotExist ¶ added in v0.8.0
CreateNamespaceIfNotExist try to create the namespace if it does not exist.
func CreateSecret ¶
CreateSecret just try to create the secret.
func CreateServiceAccount ¶
func CreateServiceAccount(client kubeclient.Interface, saObj *corev1.ServiceAccount) (*corev1.ServiceAccount, error)
CreateServiceAccount just try to create the ServiceAccount.
func DeleteClusterRole ¶
func DeleteClusterRole(client kubeclient.Interface, name string) error
DeleteClusterRole just try to delete the ClusterRole.
func DeleteClusterRoleBinding ¶
func DeleteClusterRoleBinding(client kubeclient.Interface, name string) error
DeleteClusterRoleBinding just try to delete the ClusterRoleBinding.
func DeleteNamespace ¶
func DeleteNamespace(client kubeclient.Interface, namespace string) error
DeleteNamespace just try to delete the namespace.
func DeleteSecret ¶
func DeleteSecret(client kubeclient.Interface, namespace, name string) error
DeleteSecret just try to delete the secret.
func DeleteServiceAccount ¶
func DeleteServiceAccount(client kubeclient.Interface, namespace, name string) error
DeleteServiceAccount just try to delete the ServiceAccount.
func GetBindingClusterNames ¶ added in v0.3.0
func GetBindingClusterNames(binding *workv1alpha1.ResourceBinding) []string
GetBindingClusterNames will get clusterName list from bind clusters field
func GetCluster ¶ added in v0.3.0
GetCluster returns the given Cluster resource
func GetLabelValue ¶
GetLabelValue retrieves the value via 'labelKey' if exist, otherwise returns an empty string.
func GetSumOfReplicas ¶ added in v0.8.0
func GetSumOfReplicas(clusters []workv1alpha1.TargetCluster) int32
GetSumOfReplicas will get the sum of replicas in target clusters
func GetTargetSecret ¶
func GetTargetSecret(client kubeclient.Interface, secretReferences []corev1.ObjectReference, targetType corev1.SecretType, targetNamespace string) (*corev1.Secret, error)
GetTargetSecret will get secrets(type=targetType, namespace=targetNamespace) from a list of secret references.
func IsBindingReplicasChanged ¶ added in v0.8.0
func IsBindingReplicasChanged(bindingSpec *workv1alpha1.ResourceBindingSpec, strategy *policyv1alpha1.ReplicaSchedulingStrategy) bool
IsBindingReplicasChanged will check if the sum of replicas is different from the replicas of object
func IsClusterReady ¶ added in v0.3.0
func IsClusterReady(clusterStatus *v1alpha1.ClusterStatus) bool
IsClusterReady tells whether the cluster status in 'Ready' condition.
func IsClusterRoleBindingExist ¶
func IsClusterRoleBindingExist(client kubeclient.Interface, name string) (bool, error)
IsClusterRoleBindingExist tells if specific ClusterRole already exists.
func IsClusterRoleExist ¶
func IsClusterRoleExist(client kubeclient.Interface, name string) (bool, error)
IsClusterRoleExist tells if specific ClusterRole already exists.
func IsNamespaceExist ¶
func IsNamespaceExist(client kubeclient.Interface, namespace string) (bool, error)
IsNamespaceExist tells if specific already exists.
func IsServiceAccountExist ¶
func IsServiceAccountExist(client kubeclient.Interface, namespace string, name string) (bool, error)
IsServiceAccountExist tells if specific service account already exists.
func MergeAnnotation ¶ added in v0.3.0
func MergeAnnotation(obj *unstructured.Unstructured, annotationKey string, annotationValue string)
MergeAnnotation adds annotation for the given object.
func MergeAnnotations ¶ added in v0.8.0
func MergeAnnotations(dst *unstructured.Unstructured, src *unstructured.Unstructured)
MergeAnnotations merges the annotations from 'src' to 'dst'.
func MergeLabel ¶
func MergeLabel(obj *unstructured.Unstructured, labelKey string, labelValue string)
MergeLabel adds label for the given object.
func PatchSecret ¶
func PatchSecret(client kubeclient.Interface, namespace, name string, pt types.PatchType, patchSecretBody *corev1.Secret) error
PatchSecret just try to patch the secret.
func ResourceMatchSelectors ¶ added in v0.5.0
func ResourceMatchSelectors(resource *unstructured.Unstructured, selectors ...v1alpha1.ResourceSelector) bool
ResourceMatchSelectors tells if the specific resource matches the selectors.
func ResourceMatches ¶ added in v0.3.0
func ResourceMatches(resource *unstructured.Unstructured, rs v1alpha1.ResourceSelector) bool
ResourceMatches tells if the specific resource matches the selector.
func SetLeaseOwnerFunc ¶ added in v0.7.0
SetLeaseOwnerFunc helps construct a newLeasePostProcessFunc which sets a cluster OwnerReference to the given lease object.
Types ¶
type AsyncWorker ¶
type AsyncWorker interface { // AddRateLimited adds item to queue. AddRateLimited(item interface{}) // EnqueueRateLimited generates the key for objects then adds the key as an item to queue. EnqueueRateLimited(obj runtime.Object) Run(workerNumber int, stopChan <-chan struct{}) }
AsyncWorker is a worker to process resources periodic with a rateLimitingQueue.
func NewAsyncWorker ¶
func NewAsyncWorker(name string, interval time.Duration, keyFunc KeyFunc, reconcileFunc ReconcileFunc) AsyncWorker
NewAsyncWorker returns a asyncWorker which can process resource periodic.
type ClientOption ¶ added in v0.8.0
type ClientOption struct { // QPS indicates the maximum QPS to the master from this client. // If it's zero, the created RESTClient will use DefaultQPS: 5 QPS float32 // Burst indicates the maximum burst for throttle. // If it's zero, the created RESTClient will use DefaultBurst: 10. Burst int }
ClientOption holds the attributes that should be injected to a Kubernetes client.
type ClusterClient ¶
type ClusterClient struct { KubeClient *kubeclientset.Clientset ClusterName string }
ClusterClient stands for a cluster Clientset for the given member cluster
func NewClusterClientSet ¶
func NewClusterClientSet(c *v1alpha1.Cluster, client client.Client, clientOption *ClientOption) (*ClusterClient, error)
NewClusterClientSet returns a ClusterClient for the given member cluster.
func NewClusterClientSetForAgent ¶ added in v0.5.0
func NewClusterClientSetForAgent(c *v1alpha1.Cluster, client client.Client, clientOption *ClientOption) (*ClusterClient, error)
NewClusterClientSetForAgent returns a ClusterClient for the given member cluster which will be used in karmada agent.
type DynamicClusterClient ¶
DynamicClusterClient stands for a dynamic client for the given member cluster
func NewClusterDynamicClientSet ¶
func NewClusterDynamicClientSet(c *v1alpha1.Cluster, client client.Client) (*DynamicClusterClient, error)
NewClusterDynamicClientSet returns a dynamic client for the given member cluster.
func NewClusterDynamicClientSetForAgent ¶ added in v0.5.0
func NewClusterDynamicClientSetForAgent(c *v1alpha1.Cluster, client client.Client) (*DynamicClusterClient, error)
NewClusterDynamicClientSetForAgent returns a dynamic client for the given member cluster which will be used in karmada agent.
type KeyFunc ¶ added in v0.4.0
KeyFunc knows how to make a key from an object. Implementations should be deterministic.
type QueueKey ¶ added in v0.4.0
type QueueKey interface{}
QueueKey is the item key that stores in queue. The key could be arbitrary types.
In some cases, people would like store different resources in a same queue, the traditional full-qualified key, such as '<namespace>/<name>', can't distinguish which resource the key belongs to, the key might carry more information of a resource, such as GVK(Group Version Kind), in that cases people need to use self-defined key, e.g. a struct.
func GenerateKey ¶
GenerateKey generates a key from obj, the key contains cluster, GVK, namespace and name. TODO(RainbowMango): Move this function out of this file, to it's user.
type ReconcileFunc ¶ added in v0.4.0
ReconcileFunc knows how to consume items(key) from the queue.
type Resource ¶ added in v0.7.0
type Resource struct { MilliCPU int64 Memory int64 // ScalarResources ScalarResources map[corev1.ResourceName]int64 }
Resource is a collection of compute resource.
func EmptyResource ¶ added in v0.7.0
func EmptyResource() *Resource
EmptyResource creates a empty resource object and returns.
func (*Resource) Add ¶ added in v0.7.0
func (r *Resource) Add(rl corev1.ResourceList)
Add is used to add two resources.
func (*Resource) AddPodRequest ¶ added in v0.7.0
AddPodRequest add the effective request resource of a pod to the origin resource. The Pod's effective request is the higher of: - the sum of all app containers(spec.Containers) request for a resource. - the effective init containers(spec.InitContainers) request for a resource. The effective init containers request is the highest request on all init containers.
func (*Resource) AddScalar ¶ added in v0.7.0
func (r *Resource) AddScalar(name corev1.ResourceName, quantity int64)
AddScalar adds a resource by a scalar value of this resource.
func (*Resource) ResourceList ¶ added in v0.7.0
func (r *Resource) ResourceList() corev1.ResourceList
ResourceList returns a resource list of this resource.
func (*Resource) SetMaxResource ¶ added in v0.7.0
func (r *Resource) SetMaxResource(rl corev1.ResourceList)
SetMaxResource compares with ResourceList and takes max value for each Resource.
type SkippedResourceConfig ¶ added in v0.7.0
type SkippedResourceConfig struct { // Groups holds a collection of API group, all resources under this group will be skipped. Groups map[string]struct{} // GroupVersions holds a collection of API GroupVersion, all resource under this GroupVersion will be skipped. GroupVersions map[schema.GroupVersion]struct{} // GroupVersionKinds holds a collection of resource that should be skipped. GroupVersionKinds map[schema.GroupVersionKind]struct{} }
SkippedResourceConfig represents the configuration that identifies the API resources should be skipped from propagating.
func NewSkippedResourceConfig ¶ added in v0.7.0
func NewSkippedResourceConfig() *SkippedResourceConfig
NewSkippedResourceConfig to create SkippedResourceConfig
func (*SkippedResourceConfig) DisableGroup ¶ added in v0.7.0
func (r *SkippedResourceConfig) DisableGroup(g string)
DisableGroup to disable group.
func (*SkippedResourceConfig) GroupDisabled ¶ added in v0.7.0
func (r *SkippedResourceConfig) GroupDisabled(g string) bool
GroupDisabled returns whether Group is disabled.
func (*SkippedResourceConfig) GroupVersionDisabled ¶ added in v0.7.0
func (r *SkippedResourceConfig) GroupVersionDisabled(gv schema.GroupVersion) bool
GroupVersionDisabled returns whether GroupVersion is disabled.
func (*SkippedResourceConfig) GroupVersionKindDisabled ¶ added in v0.7.0
func (r *SkippedResourceConfig) GroupVersionKindDisabled(gvk schema.GroupVersionKind) bool
GroupVersionKindDisabled returns whether GroupVersionKind is disabled.
func (*SkippedResourceConfig) Parse ¶ added in v0.7.0
func (r *SkippedResourceConfig) Parse(c string) error
Parse parses the --skipped-propagating-apis input.
type SpreadGroup ¶ added in v0.3.0
type SpreadGroup struct { // The outer map's keys are SpreadConstraint. The values (inner map) of the outer map are maps with string // keys and []string values. The inner map's key should specify the cluster group name. GroupRecord map[policyv1alpha1.SpreadConstraint]map[string][]*clusterv1alpha1.Cluster sync.RWMutex }
SpreadGroup stores the cluster group info for given spread constraints
func NewSpreadGroup ¶ added in v0.3.0
func NewSpreadGroup() *SpreadGroup
NewSpreadGroup initializes a SpreadGroup
func (*SpreadGroup) InitialGroupRecord ¶ added in v0.3.0
func (ss *SpreadGroup) InitialGroupRecord(constraint policyv1alpha1.SpreadConstraint)
InitialGroupRecord initials a spread state record