Documentation
¶
Index ¶
- Constants
- Variables
- func BuildClusterConfig(clusterName string, ...) (*rest.Config, error)
- func BuildClusterRoleReference(roleName string) rbacv1.RoleRef
- func BuildRoleBindingSubjects(serviceAccountName, serviceAccountNamespace string) []rbacv1.Subject
- func ClusterAccessCredentialChanged(newSpec, oldSpec clusterv1alpha1.ClusterSpec) bool
- func ClusterMatches(cluster *clusterv1alpha1.Cluster, affinity policyv1alpha1.ClusterAffinity) bool
- func ClusterNamesMatches(cluster *clusterv1alpha1.Cluster, clusterNames []string) bool
- func ConvertToClusterNames(clusters []workv1alpha2.TargetCluster) sets.Set[string]
- func CreateClusterObject(controlPlaneClient karmadaclientset.Interface, ...) (*clusterv1alpha1.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 CreateOrUpdateClusterObject(controlPlaneClient karmadaclientset.Interface, ...) (*clusterv1alpha1.Cluster, error)
- func CreateRole(client kubeclient.Interface, roleObj *rbacv1.Role) (*rbacv1.Role, error)
- func CreateRoleBinding(client kubeclient.Interface, roleBindingObj *rbacv1.RoleBinding) (*rbacv1.RoleBinding, error)
- func CreateSecret(client kubeclient.Interface, secret *corev1.Secret) (*corev1.Secret, error)
- func CreateServiceAccount(client kubeclient.Interface, saObj *corev1.ServiceAccount) (*corev1.ServiceAccount, error)
- func DedupeAndMergeAnnotations(existAnnotation, newAnnotation map[string]string) map[string]string
- func DedupeAndMergeFinalizers(existFinalizers, newFinalizers []string) []string
- func DedupeAndMergeLabels(existLabel, newLabel map[string]string) map[string]string
- 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 DeleteRole(client kubeclient.Interface, namespace, name string) error
- func DeleteRoleBinding(client kubeclient.Interface, namespace, name string) error
- func DeleteSecret(client kubeclient.Interface, namespace, name string) error
- func DeleteServiceAccount(client kubeclient.Interface, namespace, name string) error
- func DiffKey[K comparable, V1, V2 any](previous map[K]V1, current map[K]V2) (added, removed []K)
- func EnsureClusterRoleBindingExist(client kubeclient.Interface, clusterRoleBinding *rbacv1.ClusterRoleBinding, ...) (*rbacv1.ClusterRoleBinding, error)
- func EnsureClusterRoleExist(client kubeclient.Interface, clusterRole *rbacv1.ClusterRole, dryRun bool) (*rbacv1.ClusterRole, error)
- func EnsureNamespaceExist(client kubeclient.Interface, namespace string, dryRun bool) (*corev1.Namespace, error)
- func EnsureNamespaceExistWithLabels(client kubeclient.Interface, namespace string, dryRun bool, ...) (*corev1.Namespace, error)
- func EnsureServiceAccountExist(client kubeclient.Interface, serviceAccountObj *corev1.ServiceAccount, ...) (*corev1.ServiceAccount, error)
- func GenEventRef(resource *unstructured.Unstructured) (*corev1.ObjectReference, error)
- func GenerateImpersonationRules(subjects []rbacv1.Subject) []rbacv1.PolicyRule
- func GetAnnotationValue(annotations map[string]string, annotationKey string) string
- func GetBindingClusterNames(spec *workv1alpha2.ResourceBindingSpec) []string
- func GetCluster(hostClient client.Client, clusterName string) (*clusterv1alpha1.Cluster, error)
- func GetClusterSet(hostClient client.Client) (sets.Set[string], error)
- func GetClusterWithKarmadaClient(client karmadaclientset.Interface, name string) (*clusterv1alpha1.Cluster, bool, error)
- func GetLabelValue(labels map[string]string, labelKey string) string
- func GetSecret(client kubeclient.Interface, namespace, name string) (*corev1.Secret, error)
- func GetSumOfReplicas(clusters []workv1alpha2.TargetCluster) int32
- func GetWorkSuspendDispatching(spec *workv1alpha1.WorkSpec) []string
- func IsBindingReplicasChanged(bindingSpec *workv1alpha2.ResourceBindingSpec, ...) bool
- func IsClusterReady(clusterStatus *clusterv1alpha1.ClusterStatus) bool
- func IsClusterRoleBindingExist(client kubeclient.Interface, name string) (bool, error)
- func IsClusterRoleExist(client kubeclient.Interface, name string) (bool, error)
- func IsConditionsEqual(newCondition, oldCondition metav1.Condition) bool
- func IsLazyActivationEnabled(activationPreference policyv1alpha1.ActivationPreference) bool
- func IsNamespaceExist(client kubeclient.Interface, namespace string) (bool, error)
- func IsServiceAccountExist(client kubeclient.Interface, namespace string, name string) (bool, error)
- func IsWorkContains(manifests []workv1alpha1.Manifest, targetResource schema.GroupVersionKind) bool
- func IsWorkSuspendDispatching(work *workv1alpha1.Work) bool
- func Keys[K comparable, V any](m map[K]V) []K
- func MaxInt64(a, b int64) int64
- func MergeAnnotation(obj *unstructured.Unstructured, annotationKey string, annotationValue string)
- func MergeLabel(obj metav1.Object, labelKey string, labelValue string)
- func MergeTargetClusters(oldCluster, newCluster []workv1alpha2.TargetCluster) []workv1alpha2.TargetCluster
- func MinInt64(a, b int64) int64
- func NewCondition(conditionType, reason, message string, status metav1.ConditionStatus) metav1.Condition
- func NewProxyHeaderRoundTripperWrapperConstructor(wt transport.WrapperFunc, headers map[string]string) transport.WrapperFunc
- func ObtainClusterID(clusterKubeClient kubernetes.Interface) (string, error)
- func ObtainCredentialsFromMemberCluster(clusterKubeClient kubeclient.Interface, opts ClusterRegisterOption) (*corev1.Secret, *corev1.Secret, error)
- func PatchSecret(client kubeclient.Interface, namespace, name string, pt types.PatchType, ...) error
- func PolicyRuleAPIGroupMatches(rule *rbacv1.PolicyRule, requestedGroup string) bool
- func PolicyRuleResourceMatches(rule *rbacv1.PolicyRule, requestedResource string) bool
- func PolicyRuleResourceNameMatches(rule *rbacv1.PolicyRule, requestedName string) bool
- func RecordManagedAnnotations(object *unstructured.Unstructured)
- func RecordManagedLabels(object *unstructured.Unstructured)
- func RegisterClusterInControllerPlane(opts ClusterRegisterOption, controlPlaneKubeClient kubeclient.Interface, ...) error
- func RemoveAnnotations(obj metav1.Object, keys ...string)
- func RemoveLabels(obj metav1.Object, labelKeys ...string)
- func RescheduleRequired(rescheduleTriggeredAt, lastScheduledTime *metav1.Time) bool
- func ResourceMatchSelectors(resource *unstructured.Unstructured, ...) bool
- func ResourceMatches(resource *unstructured.Unstructured, rs policyv1alpha1.ResourceSelector) bool
- func RetainAnnotations(desired *unstructured.Unstructured, observed *unstructured.Unstructured)
- func RetainLabels(desired *unstructured.Unstructured, observed *unstructured.Unstructured)
- func SetLabelsAndAnnotationsForWorkload(workload *unstructured.Unstructured, work *workv1alpha1.Work)
- func SetLeaseOwnerFunc(c client.Client, clusterName string) func(lease *coordinationv1.Lease) error
- func StringerJoin[T fmt.Stringer](st []T, sep string) string
- func WaitForServiceAccountSecretCreation(client kubeclient.Interface, asObj *corev1.ServiceAccount) (*corev1.Secret, error)
- type AsyncWorker
- type ClientOption
- type ClusterClient
- type ClusterRateLimiterGetter
- type ClusterRegisterOption
- type ClusterScaleClient
- type ContextKey
- type DynamicClusterClient
- type ImplicitPriority
- type KeyFunc
- type NewClusterClientSetFunc
- type NewClusterDynamicClientSetFunc
- type Options
- type QueueKey
- type ReconcileFunc
- type Resource
- func (r *Resource) Add(rl corev1.ResourceList)
- func (r *Resource) AddPodRequest(podSpec *corev1.PodSpec) *Resource
- func (r *Resource) AddPodTemplateRequest(podSpec *corev1.PodSpec) *Resource
- func (r *Resource) AddResourcePods(pods int64)
- func (r *Resource) AddScalar(name corev1.ResourceName, quantity int64)
- func (r *Resource) Clone() *Resource
- func (r *Resource) MaxDivided(rl corev1.ResourceList) int64
- func (r *Resource) ResourceList() corev1.ResourceList
- func (r *Resource) SetMaxResource(rl corev1.ResourceList)
- func (r *Resource) SetScalar(name corev1.ResourceName, quantity int64)
- func (r *Resource) SubResource(rr *Resource) *Resource
- type SkippedResourceConfig
- func (r *SkippedResourceConfig) DisableGroup(g string)
- func (r *SkippedResourceConfig) DisableGroupVersion(gv schema.GroupVersion)
- func (r *SkippedResourceConfig) DisableGroupVersionKind(gvk schema.GroupVersionKind)
- 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
Constants ¶
const ( // NamespaceClusterLease is the namespace which cluster lease are stored. NamespaceClusterLease = "karmada-cluster" // KubeCredentials is the secret that contains mandatory credentials whether reported when registering cluster KubeCredentials = "KubeCredentials" // KubeImpersonator is the secret that contains the token of impersonator whether reported when registering cluster KubeImpersonator = "KubeImpersonator" // None is means don't report any secrets. None = "None" )
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" // MultiClusterServiceNamespaceLabel is added to work object, represents the work is managed by the corresponding MultiClusterService // This label indicates the namespace. MultiClusterServiceNamespaceLabel = "multiclusterservice.karmada.io/namespace" // MultiClusterServiceNameLabel is added to work object, represents the work is managed by the corresponding MultiClusterService // This label indicates the name. MultiClusterServiceNameLabel = "multiclusterservice.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. // // Deprecated: This label has been deprecated since v1.14, and will be replaced by the filed .spec.suspendDispatching of // Work API. This label should only be used internally by Karmada, but for compatibility, the deletion will be postponed // to release 1.15. PropagationInstruction = "propagation.karmada.io/instruction" // FederatedResourceQuotaNamespaceLabel is added to Work to specify associated FederatedResourceQuota's namespace. FederatedResourceQuotaNamespaceLabel = "federatedresourcequota.karmada.io/namespace" // FederatedResourceQuotaNameLabel is added to Work to specify associated FederatedResourceQuota's name. FederatedResourceQuotaNameLabel = "federatedresourcequota.karmada.io/name" // ManagedByKarmadaLabel is a reserved karmada label to indicate whether resources are member cluster resources // synchronized by karmada controllers. ManagedByKarmadaLabel = "karmada.io/managed" // KarmadaSystemLabel is a reserved karmada label to indicate whether resources are system level resources // managed by karmada controllers. KarmadaSystemLabel = "karmada.io/system" // EndpointSliceDispatchControllerLabelValue indicates the endpointSlice are controlled by Karmada EndpointSliceDispatchControllerLabelValue = "endpointslice-dispatch-controller.karmada.io" // RetainReplicasLabel is a reserved label to indicate whether the replicas should be retained. e.g: // resourcetemplate.karmada.io/retain-replicas: true // with value `true` indicates retain // resourcetemplate.karmada.io/retain-replicas: false // with value `false` and others, indicates not retain RetainReplicasLabel = "resourcetemplate.karmada.io/retain-replicas" // ResourceTemplateClaimedByLabel is added to the ResourceTemplate, indicating which resource is in charge of propagating the ResourceTemplate. ResourceTemplateClaimedByLabel = "resourcetemplate.karmada.io/claimed-by" // EndpointSliceWorkManagedByLabel is added to the EndpointSlice work collected from member clusters, represents which manage the endpointslice work EndpointSliceWorkManagedByLabel = "endpointslice.karmada.io/managed-by" )
Define labels used by karmada system.
const ( // ManagedByKarmadaLabelValue indicates that these are workloads in member cluster synchronized by karmada controllers. ManagedByKarmadaLabelValue = "true" // KarmadaSystemLabelValue indicates that resources are system level resources managed by karmada controllers. KarmadaSystemLabelValue = "true" // RetainReplicasValue is an optional value of RetainReplicasLabel, indicating retain RetainReplicasValue = "true" // PropagationInstructionSuppressed indicates that the resource should not be propagated. PropagationInstructionSuppressed = "suppressed" )
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" // EndpointSliceProvisionClusterAnnotation is added to work of the dispatch EndpointSlice in consumption clusters' namespace. EndpointSliceProvisionClusterAnnotation = "endpointslice.karmada.io/provision-cluster" )
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" // BindingControllerFinalizer is added to ResourceBinding to ensure related Works are deleted // before ResourceBinding itself is deleted. BindingControllerFinalizer = "karmada.io/binding-controller" // EndpointSliceControllerFinalizer is added to Work, which holds EndpointSlice collected from member clusters, // to ensure related EndpointSlices are deleted before Work itself is deleted. EndpointSliceControllerFinalizer = "karmada.io/endpointslice-controller" // MCSEndpointSliceCollectControllerFinalizer is added to mcs to ensure related Works in provider clusters are deleted MCSEndpointSliceCollectControllerFinalizer = "karmada.io/mcs-endpointslice-collect-controller" // MCSEndpointSliceDispatchControllerFinalizer is added to mcs to ensure related Works in consumption clusters are deleted MCSEndpointSliceDispatchControllerFinalizer = "karmada.io/mcs-endpointslice-dispatch-controller" // ClusterResourceBindingControllerFinalizer is added to ClusterResourceBinding to ensure related Works are deleted // before ClusterResourceBinding itself is deleted. ClusterResourceBindingControllerFinalizer = "karmada.io/cluster-resource-binding-controller" // MCSControllerFinalizer is added to MultiClusterService to ensure service work is deleted before itself is deleted. MCSControllerFinalizer = "karmada.io/multiclusterservice-controller" // PropagationPolicyControllerFinalizer is added to PropagationPolicy to ensure the related resources have been unbound before itself is deleted. PropagationPolicyControllerFinalizer = "karmada.io/propagation-policy-controller" // ClusterPropagationPolicyControllerFinalizer is added to ClusterPropagationPolicy to ensure the related resources have been unbound before itself is deleted. ClusterPropagationPolicyControllerFinalizer = "karmada.io/cluster-propagation-policy-controller" // BindingDependenciesDistributorFinalizer is added to independent binding to ensure // the attached binding have been removed or cleaned up before itself is deleted. BindingDependenciesDistributorFinalizer = "karmada.io/binding-dependencies-distributor" )
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" // CronJobKind indicates the target resource is a cronjob CronJobKind = "CronJob" // 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 indicates the target resource is a persistentvolumeclaim PersistentVolumeClaimKind = "PersistentVolumeClaim" // PersistentVolumeKind indicates the target resource is a persistentvolume PersistentVolumeKind = "PersistentVolume" // HorizontalPodAutoscalerKind indicates the target resource is a horizontalpodautoscaler HorizontalPodAutoscalerKind = "HorizontalPodAutoscaler" // PodDisruptionBudgetKind indicates the target resource is a poddisruptionbudget PodDisruptionBudgetKind = "PodDisruptionBudget" // ClusterRoleKind indicates the target resource is a clusterrole ClusterRoleKind = "ClusterRole" // ClusterRoleBindingKind indicates the target resource is a clusterrolebinding ClusterRoleBindingKind = "ClusterRoleBinding" // CRDKind indicates the target resource is a CustomResourceDefinition CRDKind = "CustomResourceDefinition" // SecretKind indicates the target resource is a Secret SecretKind = "Secret" // ServiceExportKind indicates the target resource is a serviceexport crd ServiceExportKind = "ServiceExport" // ServiceImportKind indicates the target resource is a serviceimport crd ServiceImportKind = "ServiceImport" // MultiClusterServiceKind indicates the target resource is a MultiClusterService MultiClusterServiceKind = "MultiClusterService" )
Define resource kind.
const ( // SpecField indicates the 'spec' field of a resource SpecField = "spec" // ReplicasField indicates the 'replicas' field of a resource ReplicasField = "replicas" // ReadyReplicasField indicates the 'readyReplicas' field of a resource status ReadyReplicasField = "readyReplicas" // ParallelismField indicates the 'parallelism' field of a job ParallelismField = "parallelism" // CompletionsField indicates the 'completions' field of a job CompletionsField = "completions" )
Define resource filed
const ( // CacheSyncTimeout refers to the time limit set on waiting for cache to sync CacheSyncTimeout = 2 * time.Minute )
const (
// DefaultFilePerm default file perm
DefaultFilePerm = 0640
)
Variables ¶
var ( // ManagedResourceLabels is the list of labels that are applied to // resources in member clusters. ManagedResourceLabels = []string{ workv1alpha2.ResourceBindingPermanentIDLabel, workv1alpha2.WorkPermanentIDLabel, ManagedByKarmadaLabel, } // ManagedResourceAnnotations is the list of annotations that are applied to // resources in member clusters. ManagedResourceAnnotations = []string{ workv1alpha2.ManagedAnnotation, workv1alpha2.ManagedLabels, workv1alpha2.ResourceBindingNamespaceAnnotationKey, workv1alpha2.ResourceBindingNameAnnotationKey, workv1alpha2.ResourceTemplateUIDAnnotation, workv1alpha2.ResourceTemplateGenerationAnnotationKey, workv1alpha2.WorkNameAnnotation, workv1alpha2.WorkNamespaceAnnotation, } )
var ( // ClusterPolicyRules represents cluster policy rules ClusterPolicyRules = []rbacv1.PolicyRule{ namespacedPolicyRules[0], { NonResourceURLs: []string{rbacv1.NonResourceAll}, Verbs: []string{"get"}, }, } )
var ( // EndpointSliceGVK is the GroupVersionKind of K8s native EndpointSlice. EndpointSliceGVK = discoveryv1.SchemeGroupVersion.WithKind("EndpointSlice") )
Functions ¶
func BuildClusterConfig ¶ added in v1.4.0
func BuildClusterConfig(clusterName string, clusterGetter func(string) (*clusterv1alpha1.Cluster, error), secretGetter func(string, string) (*corev1.Secret, error)) (*rest.Config, error)
BuildClusterConfig return rest config for member cluster.
func BuildClusterRoleReference ¶ added in v1.3.0
BuildClusterRoleReference will generate a ClusterRole reference.
func BuildRoleBindingSubjects ¶ added in v1.3.0
BuildRoleBindingSubjects will generate a subject as per service account. The subject used by RoleBinding or ClusterRoleBinding.
func ClusterAccessCredentialChanged ¶ added in v1.6.0
func ClusterAccessCredentialChanged(newSpec, oldSpec clusterv1alpha1.ClusterSpec) bool
ClusterAccessCredentialChanged checks whether the cluster access credential changed
func ClusterMatches ¶ added in v0.3.0
func ClusterMatches(cluster *clusterv1alpha1.Cluster, affinity policyv1alpha1.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 ConvertToClusterNames ¶ added in v0.8.0
func ConvertToClusterNames(clusters []workv1alpha2.TargetCluster) sets.Set[string]
ConvertToClusterNames will convert a cluster slice to clusterName's sets.String
func CreateClusterObject ¶ added in v1.0.0
func CreateClusterObject(controlPlaneClient karmadaclientset.Interface, clusterObj *clusterv1alpha1.Cluster) (*clusterv1alpha1.Cluster, error)
CreateClusterObject create cluster object in karmada control plane
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 CreateOrUpdateClusterObject ¶ added in v1.0.0
func CreateOrUpdateClusterObject(controlPlaneClient karmadaclientset.Interface, clusterObj *clusterv1alpha1.Cluster, mutate func(*clusterv1alpha1.Cluster)) (*clusterv1alpha1.Cluster, error)
CreateOrUpdateClusterObject create cluster object in karmada control plane, if cluster object has been existed and different from input clusterObj, update it.
func CreateRole ¶ added in v1.12.0
CreateRole just try to create the Role.
func CreateRoleBinding ¶ added in v1.12.0
func CreateRoleBinding(client kubeclient.Interface, roleBindingObj *rbacv1.RoleBinding) (*rbacv1.RoleBinding, error)
CreateRoleBinding just try to create the RoleBinding.
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 DedupeAndMergeAnnotations ¶ added in v1.7.0
DedupeAndMergeAnnotations merges the new annotations into exist annotations.
func DedupeAndMergeFinalizers ¶ added in v1.10.11
DedupeAndMergeFinalizers merges the new finalizers into exist finalizers.
func DedupeAndMergeLabels ¶ added in v1.1.0
DedupeAndMergeLabels merges the new labels into exist labels.
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 DeleteRole ¶ added in v1.12.0
func DeleteRole(client kubeclient.Interface, namespace, name string) error
DeleteRole just try to delete the Role.
func DeleteRoleBinding ¶ added in v1.12.0
func DeleteRoleBinding(client kubeclient.Interface, namespace, name string) error
DeleteRoleBinding just try to delete the RoleBinding.
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 DiffKey ¶ added in v1.7.0
func DiffKey[K comparable, V1, V2 any](previous map[K]V1, current map[K]V2) (added, removed []K)
DiffKey compares keys of two map with same key type, as the name of return values told, it will find out added keys and removed keys.
func EnsureClusterRoleBindingExist ¶ added in v1.3.0
func EnsureClusterRoleBindingExist(client kubeclient.Interface, clusterRoleBinding *rbacv1.ClusterRoleBinding, dryRun bool) (*rbacv1.ClusterRoleBinding, error)
EnsureClusterRoleBindingExist makes sure that the specific ClusterRoleBinding exist in cluster. If ClusterRoleBinding not exit, just create it.
func EnsureClusterRoleExist ¶ added in v1.3.0
func EnsureClusterRoleExist(client kubeclient.Interface, clusterRole *rbacv1.ClusterRole, dryRun bool) (*rbacv1.ClusterRole, error)
EnsureClusterRoleExist makes sure that the specific cluster role exist in cluster. If cluster role not exit, just create it.
func EnsureNamespaceExist ¶ added in v1.0.0
func EnsureNamespaceExist(client kubeclient.Interface, namespace string, dryRun bool) (*corev1.Namespace, error)
EnsureNamespaceExist makes sure that the specific namespace exist in cluster. If namespace not exit, just create it.
func EnsureNamespaceExistWithLabels ¶ added in v1.7.0
func EnsureNamespaceExistWithLabels(client kubeclient.Interface, namespace string, dryRun bool, labels map[string]string) (*corev1.Namespace, error)
EnsureNamespaceExistWithLabels makes sure that the specific namespace exist in cluster. If namespace not exit, just create it with specific labels.
func EnsureServiceAccountExist ¶ added in v1.0.0
func EnsureServiceAccountExist(client kubeclient.Interface, serviceAccountObj *corev1.ServiceAccount, dryRun bool) (*corev1.ServiceAccount, error)
EnsureServiceAccountExist makes sure that the specific service account exist in cluster. If service account not exit, just create it.
func GenEventRef ¶ added in v1.14.0
func GenEventRef(resource *unstructured.Unstructured) (*corev1.ObjectReference, error)
GenEventRef returns the event reference. sets the UID(.spec.uid) that might be missing for fire events. Do nothing if the UID already exist, otherwise set the UID from annotation.
func GenerateImpersonationRules ¶ added in v1.0.0
func GenerateImpersonationRules(subjects []rbacv1.Subject) []rbacv1.PolicyRule
GenerateImpersonationRules generate PolicyRules from given subjects for impersonation.
func GetAnnotationValue ¶ added in v1.0.0
GetAnnotationValue retrieves the value via 'annotationKey' (if it exists), otherwise an empty string is returned.
func GetBindingClusterNames ¶ added in v0.3.0
func GetBindingClusterNames(spec *workv1alpha2.ResourceBindingSpec) []string
GetBindingClusterNames will get clusterName list from bind clusters field
func GetCluster ¶ added in v0.3.0
GetCluster returns the given Cluster resource
func GetClusterSet ¶ added in v1.8.0
GetClusterSet returns the given Clusters name set
func GetClusterWithKarmadaClient ¶ added in v1.0.0
func GetClusterWithKarmadaClient(client karmadaclientset.Interface, name string) (*clusterv1alpha1.Cluster, bool, error)
GetClusterWithKarmadaClient tells if a cluster already joined to control plane.
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 []workv1alpha2.TargetCluster) int32
GetSumOfReplicas will get the sum of replicas in target clusters
func GetWorkSuspendDispatching ¶ added in v1.14.0
func GetWorkSuspendDispatching(spec *workv1alpha1.WorkSpec) []string
GetWorkSuspendDispatching will get suspendDispatching field from work spec
func IsBindingReplicasChanged ¶ added in v0.8.0
func IsBindingReplicasChanged(bindingSpec *workv1alpha2.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 *clusterv1alpha1.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 IsConditionsEqual ¶ added in v1.0.0
IsConditionsEqual compares the given condition's Status, Reason and Message.
func IsLazyActivationEnabled ¶ added in v1.9.0
func IsLazyActivationEnabled(activationPreference policyv1alpha1.ActivationPreference) bool
IsLazyActivationEnabled judge whether lazy activation preference is enabled.
func IsNamespaceExist ¶
func IsNamespaceExist(client kubeclient.Interface, namespace string) (bool, error)
IsNamespaceExist tells if the namespace already exists.
func IsServiceAccountExist ¶
func IsServiceAccountExist(client kubeclient.Interface, namespace string, name string) (bool, error)
IsServiceAccountExist tells if specific service account already exists.
func IsWorkContains ¶ added in v1.14.0
func IsWorkContains(manifests []workv1alpha1.Manifest, targetResource schema.GroupVersionKind) bool
IsWorkContains checks if the target resource exists in a work.spec.workload.manifests.
func IsWorkSuspendDispatching ¶ added in v1.14.0
func IsWorkSuspendDispatching(work *workv1alpha1.Work) bool
IsWorkSuspendDispatching checks if the work is suspended from dispatching.
func Keys ¶ added in v1.7.0
func Keys[K comparable, V any](m map[K]V) []K
Keys return slice of keys of the given map
func MergeAnnotation ¶ added in v0.3.0
func MergeAnnotation(obj *unstructured.Unstructured, annotationKey string, annotationValue string)
MergeAnnotation adds annotation for the given object, replace the value if key exist.
func MergeLabel ¶
MergeLabel adds label for the given object, replace the value if key exist.
func MergeTargetClusters ¶ added in v0.10.0
func MergeTargetClusters(oldCluster, newCluster []workv1alpha2.TargetCluster) []workv1alpha2.TargetCluster
MergeTargetClusters will merge the replicas in two TargetCluster
func NewCondition ¶ added in v1.0.0
func NewCondition(conditionType, reason, message string, status metav1.ConditionStatus) metav1.Condition
NewCondition returns a new condition object.
func NewProxyHeaderRoundTripperWrapperConstructor ¶ added in v1.7.0
func NewProxyHeaderRoundTripperWrapperConstructor(wt transport.WrapperFunc, headers map[string]string) transport.WrapperFunc
NewProxyHeaderRoundTripperWrapperConstructor returns a RoundTripper wrapper that's usable within restConfig.WrapTransport.
func ObtainClusterID ¶ added in v1.3.0
func ObtainClusterID(clusterKubeClient kubernetes.Interface) (string, error)
ObtainClusterID returns the cluster ID property with clusterKubeClient
func ObtainCredentialsFromMemberCluster ¶ added in v1.3.0
func ObtainCredentialsFromMemberCluster(clusterKubeClient kubeclient.Interface, opts ClusterRegisterOption) (*corev1.Secret, *corev1.Secret, error)
ObtainCredentialsFromMemberCluster obtain credentials for member cluster
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 PolicyRuleAPIGroupMatches ¶ added in v1.0.0
func PolicyRuleAPIGroupMatches(rule *rbacv1.PolicyRule, requestedGroup string) bool
PolicyRuleAPIGroupMatches determines if the given policy rule is applied for requested group.
func PolicyRuleResourceMatches ¶ added in v1.0.0
func PolicyRuleResourceMatches(rule *rbacv1.PolicyRule, requestedResource string) bool
PolicyRuleResourceMatches determines if the given policy rule is applied for requested resource.
func PolicyRuleResourceNameMatches ¶ added in v1.0.0
func PolicyRuleResourceNameMatches(rule *rbacv1.PolicyRule, requestedName string) bool
PolicyRuleResourceNameMatches determines if the given policy rule is applied for named resource.
func RecordManagedAnnotations ¶ added in v1.5.0
func RecordManagedAnnotations(object *unstructured.Unstructured)
RecordManagedAnnotations sets or updates the annotation(resourcetemplate.karmada.io/managed-annotations) to record the annotation keys.
func RecordManagedLabels ¶ added in v1.5.0
func RecordManagedLabels(object *unstructured.Unstructured)
RecordManagedLabels sets or updates the annotation(resourcetemplate.karmada.io/managed-labels) to record the label keys.
func RegisterClusterInControllerPlane ¶ added in v1.3.0
func RegisterClusterInControllerPlane(opts ClusterRegisterOption, controlPlaneKubeClient kubeclient.Interface, generateClusterInControllerPlane generateClusterInControllerPlaneFunc) error
RegisterClusterInControllerPlane represents register cluster in controller plane
func RemoveAnnotations ¶ added in v1.10.0
RemoveAnnotations removes the annotations from the given object.
func RemoveLabels ¶ added in v1.4.5
RemoveLabels removes the labels from the given object.
func RescheduleRequired ¶ added in v1.10.0
RescheduleRequired judges whether reschedule is required.
func ResourceMatchSelectors ¶ added in v0.5.0
func ResourceMatchSelectors(resource *unstructured.Unstructured, selectors ...policyv1alpha1.ResourceSelector) bool
ResourceMatchSelectors tells if the specific resource matches the selectors.
func ResourceMatches ¶ added in v0.3.0
func ResourceMatches(resource *unstructured.Unstructured, rs policyv1alpha1.ResourceSelector) bool
ResourceMatches tells if the specific resource matches the selector.
func RetainAnnotations ¶ added in v1.5.0
func RetainAnnotations(desired *unstructured.Unstructured, observed *unstructured.Unstructured)
RetainAnnotations merges the annotations that added by controllers running in member cluster to avoid overwriting. Following keys will be ignored if :
- the keys were previous propagated to member clusters(that are tracked by "resourcetemplate.karmada.io/managed-annotations" annotation in observed) but have been removed from Karmada control plane(don't exist in desired anymore).
- the keys that exist in both desired and observed even those been accidentally modified in member clusters.
func RetainLabels ¶ added in v1.5.0
func RetainLabels(desired *unstructured.Unstructured, observed *unstructured.Unstructured)
RetainLabels merges the labels that added by controllers running in member cluster to avoid overwriting. Following keys will be ignored if :
- the keys were previous propagated to member clusters(that are tracked by "resourcetemplate.karmada.io/managed-lables" annotation in observed) but have been removed from Karmada control plane(don't exist in desired anymore).
- the keys that exist in both desired and observed even those been accidentally modified in member clusters.
func SetLabelsAndAnnotationsForWorkload ¶ added in v1.14.0
func SetLabelsAndAnnotationsForWorkload(workload *unstructured.Unstructured, work *workv1alpha1.Work)
SetLabelsAndAnnotationsForWorkload sets the associated work object labels and annotations for workload.
func SetLeaseOwnerFunc ¶ added in v0.7.0
SetLeaseOwnerFunc helps construct a newLeasePostProcessFunc which sets a cluster OwnerReference to the given lease object.
func StringerJoin ¶ added in v1.7.0
StringerJoin acts the same with `strings.Join`, except that it consumes a slice of `fmt.Stringer`. This mainly used for debug purpose, to log some slice of complex object as human-readable string.
func WaitForServiceAccountSecretCreation ¶ added in v1.0.0
func WaitForServiceAccountSecretCreation(client kubeclient.Interface, asObj *corev1.ServiceAccount) (*corev1.Secret, error)
WaitForServiceAccountSecretCreation wait the ServiceAccount's secret has been created.
Types ¶
type AsyncWorker ¶
type AsyncWorker interface {
// Add adds the 'item' to queue immediately(without any delay).
Add(item interface{})
// AddAfter adds an item to the workqueue after the indicated duration has passed
AddAfter(item interface{}, duration time.Duration)
// Enqueue generates the key of 'obj' according to a 'KeyFunc' then adds the key as an item to queue by 'Add'.
Enqueue(obj interface{})
// Run starts a certain number of concurrent workers to reconcile the items and will never stop until context
// is canceled.
Run(ctx context.Context, workerNumber int)
}
AsyncWorker maintains a rate limiting queue and the items in the queue will be reconciled by a "ReconcileFunc". The item will be re-queued if "ReconcileFunc" returns an error, maximum re-queue times defined by "maxRetries" above, after that the item will be discarded from the queue.
func NewAsyncWorker ¶
func NewAsyncWorker(opt Options) AsyncWorker
NewAsyncWorker returns a asyncWorker which can process resource periodic.
type ClientOption ¶ added in v0.8.0
type ClientOption struct {
// RateLimiter is used to limit the QPS to the master from this client.
// We use this instead of QPS/Burst to avoid multiple client initializations causing QPS/Burst to lose its effect.
RateLimiterGetter func(key string) flowcontrol.RateLimiter
}
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(clusterName string, 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(clusterName string, _ client.Client, clientOption *ClientOption) (*ClusterClient, error)
NewClusterClientSetForAgent returns a ClusterClient for the given member cluster which will be used in karmada agent.
type ClusterRateLimiterGetter ¶ added in v1.14.0
type ClusterRateLimiterGetter struct {
// contains filtered or unexported fields
}
ClusterRateLimiterGetter is responsible for retrieving rate limiters for member clusters. It dynamically creates and manages a singleton rate limiter for each member cluster, using the preset default QPS and burst values to ensure consistent rate limiting across all clusters.
func GetClusterRateLimiterGetter ¶ added in v1.14.0
func GetClusterRateLimiterGetter() *ClusterRateLimiterGetter
GetClusterRateLimiterGetter returns a ClusterRateLimiterGetter.
func (*ClusterRateLimiterGetter) GetRateLimiter ¶ added in v1.14.0
func (r *ClusterRateLimiterGetter) GetRateLimiter(key string) flowcontrol.RateLimiter
GetRateLimiter gets rate limiter by key.
func (*ClusterRateLimiterGetter) SetDefaultLimits ¶ added in v1.14.0
func (r *ClusterRateLimiterGetter) SetDefaultLimits(qps float32, burst int) *ClusterRateLimiterGetter
SetDefaultLimits sets the default qps and burst for new rate limiters. Do not call this method after calling GetRateLimiter, otherwise the call will not take effect. If qps and limit are not set when using Getter, it will use 40 and 60 by default (the default qps and burst of '--cluster-api-qps' and '--cluster-api-burst' in karmada-controller-manager).
type ClusterRegisterOption ¶ added in v1.3.0
type ClusterRegisterOption struct {
ClusterNamespace string
ClusterName string
ClusterID string
ReportSecrets []string
ClusterAPIEndpoint string
ProxyServerAddress string
ClusterProvider string
ClusterRegion string
ClusterZones []string
DryRun bool
ControlPlaneConfig *rest.Config
ClusterConfig *rest.Config
Secret corev1.Secret
ImpersonatorSecret corev1.Secret
}
ClusterRegisterOption represents the option for RegistryCluster.
func (*ClusterRegisterOption) IsKubeCredentialsEnabled ¶ added in v1.3.0
func (r *ClusterRegisterOption) IsKubeCredentialsEnabled() bool
IsKubeCredentialsEnabled represents whether report secret
func (*ClusterRegisterOption) IsKubeImpersonatorEnabled ¶ added in v1.3.0
func (r *ClusterRegisterOption) IsKubeImpersonatorEnabled() bool
IsKubeImpersonatorEnabled represents whether report impersonator secret
func (*ClusterRegisterOption) Validate ¶ added in v1.11.9
func (r *ClusterRegisterOption) Validate(karmadaClient karmadaclientset.Interface, isAgent bool) error
Validate validates the cluster register option, including clusterID, cluster name and so on.
type ClusterScaleClient ¶ added in v1.6.0
type ClusterScaleClient struct {
KubeClient *kubeclientset.Clientset
ScaleClient scale.ScalesGetter
ClusterName string
}
ClusterScaleClient stands for a cluster ClientSet with scale client for the given member cluster
func NewClusterScaleClientSet ¶ added in v1.6.0
func NewClusterScaleClientSet(clusterName string, client client.Client) (*ClusterScaleClient, error)
NewClusterScaleClientSet returns a ClusterScaleClient for the given member cluster.
type ContextKey ¶ added in v0.10.0
type ContextKey string
ContextKey is the key of context.
const ( // ContextKeyObject is the context value key of a resource. ContextKeyObject ContextKey = "object" )
type DynamicClusterClient ¶
DynamicClusterClient stands for a dynamic client for the given member cluster
func NewClusterDynamicClientSet ¶
func NewClusterDynamicClientSet(clusterName string, client client.Client, clientOption *ClientOption) (*DynamicClusterClient, error)
NewClusterDynamicClientSet returns a dynamic client for the given member cluster.
func NewClusterDynamicClientSetForAgent ¶ added in v0.5.0
func NewClusterDynamicClientSetForAgent(clusterName string, _ client.Client, clientOption *ClientOption) (*DynamicClusterClient, error)
NewClusterDynamicClientSetForAgent returns a dynamic client for the given member cluster which will be used in karmada agent.
type ImplicitPriority ¶ added in v1.4.0
type ImplicitPriority int
ImplicitPriority describes the extent to which a ResourceSelector or a set of ResourceSelectors match resources.
const ( // PriorityMisMatch means the ResourceSelector does not match the resource. PriorityMisMatch ImplicitPriority = iota // PriorityMatchAll means the ResourceSelector whose Name and LabelSelector is empty // matches the resource. PriorityMatchAll // PriorityMatchLabelSelector means the LabelSelector of ResourceSelector matches the resource. PriorityMatchLabelSelector // PriorityMatchName means the Name of ResourceSelector matches the resource. PriorityMatchName )
func ResourceMatchSelectorsPriority ¶ added in v1.4.0
func ResourceMatchSelectorsPriority(resource *unstructured.Unstructured, selectors ...policyv1alpha1.ResourceSelector) ImplicitPriority
ResourceMatchSelectorsPriority returns the highest priority between specific resource and the selectors.
func ResourceSelectorPriority ¶ added in v1.4.0
func ResourceSelectorPriority(resource *unstructured.Unstructured, rs policyv1alpha1.ResourceSelector) ImplicitPriority
ResourceSelectorPriority tells the priority between the specific resource and the selector.
type KeyFunc ¶ added in v0.4.0
KeyFunc knows how to make a key from an object. Implementations should be deterministic.
type NewClusterClientSetFunc ¶ added in v1.14.0
type NewClusterClientSetFunc = func(clusterName string, client client.Client, clientOption *ClientOption) (*ClusterClient, error)
NewClusterClientSetFunc is a function that returns a ClusterClient for the given member cluster.
type NewClusterDynamicClientSetFunc ¶ added in v1.14.0
type NewClusterDynamicClientSetFunc = func(clusterName string, client client.Client, clientOption *ClientOption) (*DynamicClusterClient, error)
NewClusterDynamicClientSetFunc is a function that returns a dynamic client for the given member cluster.
type Options ¶ added in v1.2.0
type Options struct {
// Name is the queue's name that will be used to emit metrics.
// Defaults to "", which means disable metrics.
Name string
KeyFunc KeyFunc
ReconcileFunc ReconcileFunc
RateLimiterOptions ratelimiterflag.Options
}
Options are the arguments for creating a new AsyncWorker.
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 MetaNamespaceKeyFunc ¶ added in v1.1.0
MetaNamespaceKeyFunc generates a namespaced key for object.
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
EphemeralStorage int64
AllowedPodNumber 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 an empty resource object and returns.
func NewResource ¶ added in v0.9.0
func NewResource(rl corev1.ResourceList) *Resource
NewResource creates a new resource object from resource list.
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) AddPodTemplateRequest ¶ added in v1.1.0
AddPodTemplateRequest add the effective request resource of a pod template to the origin resource. If pod container limits are specified, but requests are not, default requests to limits. The code logic is almost the same as kubernetes. https://github.com/kubernetes/kubernetes/blob/f7cdbe2c96cc12101226686df9e9819b4b007c5c/pkg/apis/core/v1/defaults.go#L147-L181
func (*Resource) AddResourcePods ¶ added in v0.9.0
AddResourcePods adds pod resources into the Resource. Notice that a pod request resource list does not contain a request for pod resources, this function helps to add the pod resources.
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) MaxDivided ¶ added in v0.9.0
func (r *Resource) MaxDivided(rl corev1.ResourceList) int64
MaxDivided returns how many replicas that the resource can be divided.
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.
func (*Resource) SetScalar ¶ added in v0.7.0
func (r *Resource) SetScalar(name corev1.ResourceName, quantity int64)
SetScalar sets a resource by a scalar value of this resource.
func (*Resource) SubResource ¶ added in v1.4.0
SubResource is used to subtract two resources, if r < rr, set r to zero.
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) DisableGroupVersion ¶ added in v1.3.0
func (r *SkippedResourceConfig) DisableGroupVersion(gv schema.GroupVersion)
DisableGroupVersion to disable GroupVersion.
func (*SkippedResourceConfig) DisableGroupVersionKind ¶ added in v0.10.0
func (r *SkippedResourceConfig) DisableGroupVersionKind(gvk schema.GroupVersionKind)
DisableGroupVersionKind to disable GroupVersionKind.
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.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package lifted contains the files lifted from other projects.
|
Package lifted contains the files lifted from other projects. |