helper

package
v1.9.0-preview1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceUnitZero             int64 = 0
	ResourceUnitCPU              int64 = 1000
	ResourceUnitMem              int64 = 1024 * 1024 * 1024
	ResourceUnitPod              int64 = 1
	ResourceUnitEphemeralStorage int64 = 1024 * 1024 * 1024
	ResourceUnitGPU              int64 = 1
)

These are different resource units.

Variables

This section is empty.

Functions

func DoRequest added in v1.2.0

func DoRequest(urlPath string, token string) (int, error)

DoRequest use bearer token to call karmada-apiserver.

func GetTokenFromServiceAccount added in v1.2.0

func GetTokenFromServiceAccount(client kubernetes.Interface, saNamespace, saName string) (string, error)

GetTokenFromServiceAccount get token from serviceAccount's related secret.

func IsExclude added in v1.2.0

func IsExclude(srcCluster string, targetClusters []string) bool

IsExclude indicate if the target clusters exclude the srcCluster

func IsScheduleResultEqual added in v0.10.0

func IsScheduleResultEqual(tc1, tc2 []workv1alpha2.TargetCluster) bool

IsScheduleResultEqual will check whether two schedule results are equal.

func MakeNodeWithLabels added in v0.9.0

func MakeNodeWithLabels(node string, milliCPU, memory, pods, ephemeralStorage int64, labels map[string]string) *corev1.Node

MakeNodeWithLabels will build a ready node with resource and labels.

func MakeNodeWithTaints added in v0.9.0

func MakeNodeWithTaints(node string, milliCPU, memory, pods, ephemeralStorage int64, taints []corev1.Taint) *corev1.Node

MakeNodeWithTaints will build a ready node with resource and taints.

func MakeNodesAndPods added in v1.2.0

func MakeNodesAndPods(allNodesNum, allPodsNum int, nodeTemplate *corev1.Node, podTemplate *corev1.Pod) ([]*corev1.Node, []*corev1.Pod)

MakeNodesAndPods will make batch of nodes and pods based on template.

func NewCluster added in v0.10.0

func NewCluster(name string) *clusterv1alpha1.Cluster

NewCluster will build a Cluster.

func NewClusterOverridePolicyByOverrideRules added in v1.1.6

func NewClusterOverridePolicyByOverrideRules(policyName string, rsSelectors []policyv1alpha1.ResourceSelector, overrideRules []policyv1alpha1.RuleWithCluster) *policyv1alpha1.ClusterOverridePolicy

NewClusterOverridePolicyByOverrideRules will build a ClusterOverridePolicy object by OverrideRules

func NewClusterPropagationPolicy added in v0.7.0

func NewClusterPropagationPolicy(policyName string, rsSelectors []policyv1alpha1.ResourceSelector, placement policyv1alpha1.Placement) *policyv1alpha1.ClusterPropagationPolicy

NewClusterPropagationPolicy will build a ClusterPropagationPolicy object.

func NewClusterRole added in v1.2.0

func NewClusterRole(name string, rules []rbacv1.PolicyRule) *rbacv1.ClusterRole

NewClusterRole will build a new clusterRole object.

func NewClusterRoleBinding added in v1.2.0

func NewClusterRoleBinding(name, roleRefName string, subject []rbacv1.Subject) *rbacv1.ClusterRoleBinding

NewClusterRoleBinding will build a new clusterRoleBinding object.

func NewClusterWithResource added in v0.10.0

func NewClusterWithResource(name string, allocatable, allocating, allocated corev1.ResourceList) *clusterv1alpha1.Cluster

NewClusterWithResource will build a Cluster with resource.

func NewConfigMap added in v1.2.0

func NewConfigMap(namespace string, name string, data map[string]string) *corev1.ConfigMap

NewConfigMap will build a configmap object.

func NewCronFederatedHPARule added in v1.7.0

func NewCronFederatedHPARule(name, cron string, suspend bool, targetReplicas, targetMinReplicas, targetMaxReplicas *int32) autoscalingv1alpha1.CronFederatedHPARule

NewCronFederatedHPARule will build a CronFederatedHPARule object.

func NewCronFederatedHPAWithScalingDeployment added in v1.7.0

func NewCronFederatedHPAWithScalingDeployment(namespace, name, deploymentName string,
	rule autoscalingv1alpha1.CronFederatedHPARule) *autoscalingv1alpha1.CronFederatedHPA

NewCronFederatedHPAWithScalingDeployment will build a CronFederatedHPA object with scaling deployment.

func NewCronFederatedHPAWithScalingFHPA added in v1.7.0

func NewCronFederatedHPAWithScalingFHPA(namespace, name, fhpaName string,
	rule autoscalingv1alpha1.CronFederatedHPARule) *autoscalingv1alpha1.CronFederatedHPA

NewCronFederatedHPAWithScalingFHPA will build a CronFederatedHPA object with scaling FederatedHPA.

func NewCrossClusterMultiClusterService added in v1.8.0

func NewCrossClusterMultiClusterService(namespace, name string, provisionClusters, consumptionClusters []string) *networkingv1alpha1.MultiClusterService

func NewCustomResource added in v0.5.0

func NewCustomResource(apiVersion, kind, namespace, name string) *unstructured.Unstructured

NewCustomResource will build a CR object with CRD Foo.

func NewCustomResourceDefinition added in v0.5.0

NewCustomResourceDefinition will build a CRD object.

func NewDaemonSet added in v1.2.0

func NewDaemonSet(namespace string, name string) *appsv1.DaemonSet

NewDaemonSet will build a daemonSet object.

func NewDeployment

func NewDeployment(namespace string, name string) *appsv1.Deployment

NewDeployment will build a deployment object.

func NewDeploymentWithServiceAccount added in v1.3.5

func NewDeploymentWithServiceAccount(namespace, deploymentName string, serviceAccountName string) *appsv1.Deployment

NewDeploymentWithServiceAccount will build a deployment object that with serviceAccount.

func NewDeploymentWithVolumes added in v1.2.0

func NewDeploymentWithVolumes(namespace, deploymentName string, volumes []corev1.Volume) *appsv1.Deployment

NewDeploymentWithVolumes will build a deployment object that with reference volumes.

func NewExplicitPriorityClusterPropagationPolicy added in v1.4.0

func NewExplicitPriorityClusterPropagationPolicy(policyName string, rsSelectors []policyv1alpha1.ResourceSelector,
	placement policyv1alpha1.Placement, priority int32) *policyv1alpha1.ClusterPropagationPolicy

NewExplicitPriorityClusterPropagationPolicy will build a ClusterPropagationPolicy object with explicit priority.

func NewExplicitPriorityPropagationPolicy added in v1.4.0

func NewExplicitPriorityPropagationPolicy(ns, name string, rsSelectors []policyv1alpha1.ResourceSelector,
	placement policyv1alpha1.Placement, priority int32) *policyv1alpha1.PropagationPolicy

NewExplicitPriorityPropagationPolicy will build a PropagationPolicy object with explicit priority.

func NewFederatedHPA added in v1.7.0

func NewFederatedHPA(namespace, name, scaleTargetDeployment string) *autoscalingv1alpha1.FederatedHPA

NewFederatedHPA will build a FederatedHPA object.

func NewFederatedResourceQuota added in v1.2.0

func NewFederatedResourceQuota(ns, name string) *policyv1alpha1.FederatedResourceQuota

NewFederatedResourceQuota will build a demo FederatedResourceQuota object.

func NewGroupRESTMapper added in v1.6.0

func NewGroupRESTMapper(kind string, scope meta.RESTScope) meta.RESTMapper

NewGroupRESTMapper make a fake RESTMapper in GroupVersion, by kind and scope.

func NewHPA added in v1.8.0

func NewHPA(namespace, name, scaleDeployment string) *autoscalingv2.HorizontalPodAutoscaler

NewHPA will build a HorizontalPodAutoscaler object.

func NewIngress added in v1.2.0

func NewIngress(namespace, name string) *networkingv1.Ingress

NewIngress will build a new ingress object.

func NewJob added in v0.8.0

func NewJob(namespace string, name string) *batchv1.Job

NewJob will build a job object.

func NewNamespace

func NewNamespace(namespace string) *corev1.Namespace

NewNamespace will build a Namespace object.

func NewNode added in v0.9.0

func NewNode(node string, milliCPU, memory, pods, ephemeralStorage int64) *corev1.Node

NewNode will build a ready node with resource.

func NewOverridePolicy added in v0.7.0

func NewOverridePolicy(namespace, policyName string, rsSelectors []policyv1alpha1.ResourceSelector, clusterAffinity policyv1alpha1.ClusterAffinity, overriders policyv1alpha1.Overriders) *policyv1alpha1.OverridePolicy

NewOverridePolicy will build a OverridePolicy object.

func NewOverridePolicyByOverrideRules added in v1.0.0

func NewOverridePolicyByOverrideRules(namespace, policyName string, rsSelectors []policyv1alpha1.ResourceSelector, overrideRules []policyv1alpha1.RuleWithCluster) *policyv1alpha1.OverridePolicy

NewOverridePolicyByOverrideRules will build a OverridePolicy object by OverrideRules

func NewPVC added in v1.3.0

func NewPVC(namespace, name string, resources corev1.ResourceRequirements, accessModes ...corev1.PersistentVolumeAccessMode) *corev1.PersistentVolumeClaim

NewPVC will build a new PersistentVolumeClaim.

func NewPod added in v0.4.0

func NewPod(namespace string, name string) *corev1.Pod

NewPod will build a service object.

func NewPodDisruptionBudget added in v1.5.0

func NewPodDisruptionBudget(namespace, name string, maxUnAvailable intstr.IntOrString) *policyv1.PodDisruptionBudget

NewPodDisruptionBudget will build a new PodDisruptionBudget object.

func NewPodWithRequest added in v0.9.0

func NewPodWithRequest(pod, node string, milliCPU, memory, ephemeralStorage int64) *corev1.Pod

NewPodWithRequest will build a Pod with resource request.

func NewPropagationPolicy added in v0.7.0

func NewPropagationPolicy(ns, name string, rsSelectors []policyv1alpha1.ResourceSelector, placement policyv1alpha1.Placement) *policyv1alpha1.PropagationPolicy

NewPropagationPolicy will build a PropagationPolicy object.

func NewResourceInterpreterCustomization added in v1.4.0

NewResourceInterpreterCustomization will build a ResourceInterpreterCustomization object.

func NewResourceList added in v0.9.0

func NewResourceList(milliCPU, memory, ephemeralStorage int64) corev1.ResourceList

NewResourceList will build a ResourceList.

func NewRole added in v1.4.0

func NewRole(namespace, name string, rules []rbacv1.PolicyRule) *rbacv1.Role

NewRole will build a new role object.

func NewRoleBinding added in v1.4.0

func NewRoleBinding(namespace, name, roleRefName string, subject []rbacv1.Subject) *rbacv1.RoleBinding

NewRoleBinding will build a new roleBinding object.

func NewSecret added in v1.2.0

func NewSecret(namespace string, name string, data map[string][]byte) *corev1.Secret

NewSecret will build a secret object.

func NewService added in v0.4.0

func NewService(namespace string, name string, svcType corev1.ServiceType) *corev1.Service

NewService will build a service object.

func NewServiceaccount added in v1.2.0

func NewServiceaccount(namespace, name string) *corev1.ServiceAccount

NewServiceaccount will build a new serviceaccount.

func NewStatefulSet added in v1.2.0

func NewStatefulSet(namespace string, name string) *appsv1.StatefulSet

NewStatefulSet will build a statefulSet object.

func NewWork added in v1.7.0

func NewWork(workName, workNs, workUID string, raw []byte) *workv1alpha1.Work

NewWork will build a new Work object.

func NewWorkload added in v1.0.0

func NewWorkload(namespace, name string) *workloadv1alpha1.Workload

NewWorkload will build a workload object.

Types

This section is empty.

Jump to

Keyboard shortcuts

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