utils

package
v4.68.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrgLabelName = "appuio.io/organization"

	// Namespace related quotas
	DefaultMaxNamespaces    = 25
	OverrideCMDataFieldName = "namespaceQuota"
	NsOverrideCMPrefix      = "override-"
	NsOverrideCMNamespace   = "appuio-cloud"
)

Variables

View Source
var (
	// Now all the permutations for the annotations
	CpuRequestAnnotation       = fmt.Sprintf("%s%s.%s", quotaAnnotationPrefix, resourceQuotaNameCompute, quotaResourceCPURequests)
	CpuLimitAnnotation         = fmt.Sprintf("%s%s.%s", quotaAnnotationPrefix, resourceQuotaNameCompute, quotaResourceCPULimits)
	MemoryRequestAnnotation    = fmt.Sprintf("%s%s.%s", quotaAnnotationPrefix, resourceQuotaNameCompute, quotaResourceMemoryRequests)
	MemoryLimitAnnotation      = fmt.Sprintf("%s%s.%s", quotaAnnotationPrefix, resourceQuotaNameCompute, quotaResourceMemoryLimits)
	DiskAnnotation             = fmt.Sprintf("%s%s.%s", quotaAnnotationPrefix, resourceQuotaNameObjects, quotaResourceDisk)
	CpuRequestTerminationQuota = fmt.Sprintf("%s%s.%s", quotaAnnotationPrefix, resourceQuotaNameCompute+"-terminating", quotaResourceCPURequests)

	ErrNSLimitReached = fmt.Errorf("creating a new instance will violate the namespace quota." +
		"Please contact VSHN support to increase the amounts of namespaces you can create.")

	// defaultCPURequests 2* standard-8 will request 4 CPUs. This default has 500m as spare for jobs
	DefaultCPURequests = resource.NewMilliQuantity(4500, resource.DecimalSI)
	// defaultCPULimit by default same as DefaultCPURequests
	DefaultCPULimits = DefaultCPURequests
	// defaultMemoryRequests 2* standard-8 will request 16Gb. This default has 500mb as spare for jobs
	DefaultMemoryRequests = resource.NewQuantity(17301504000, resource.BinarySI)
	// defaultMemoryLimits same as DefaultMemoryRequests
	DefaultMemoryLimits = DefaultMemoryRequests
	// defaultDiskRequests should be plenty for a large amount of replicas for any service
	DefaultDiskRequests = resource.NewQuantity(1099511627776, resource.DecimalSI)
)

Functions

func FetchNodeSelectorFromConfig added in v4.48.0

func FetchNodeSelectorFromConfig(ctx context.Context, svc *runtime.ServiceRuntime, plan string, nodeSelector map[string]string) (map[string]string, error)

Types

type Plans

type Plans map[string]plan

type Resources

type Resources struct {
	CPURequests        resource.Quantity
	CPURequestsPath    *field.Path
	CPULimits          resource.Quantity
	CPULimitsPath      *field.Path
	MemoryRequests     resource.Quantity
	MemoryRequestsPath *field.Path
	MemoryLimits       resource.Quantity
	MemoryLimitsPath   *field.Path
	Disk               resource.Quantity
	DiskPath           *field.Path
}

Resources contains the Resources that the given instance will use. If the service has more than 1 replica then the values need to be adjusted.

func FetchPlansFromCluster

func FetchPlansFromCluster(ctx context.Context, c client.Client, name, plan string) (Resources, error)

FetchPlansFromCluster will fetch the plans from the current PLANS_NAMESPACE namespace and parse them into Resources. By default PLANS_NAMESPACE should be the same namespace where the controller pod is running.

func FetchPlansFromConfig

func FetchPlansFromConfig(ctx context.Context, svc *runtime.ServiceRuntime, plan string) (Resources, error)

func FetchSidecarFromCluster added in v4.33.0

func FetchSidecarFromCluster(ctx context.Context, c client.Client, name, sidecar string) (Resources, error)

FetchSidecarFromCluster will fetch the specified sidecar from the current PLANS_NAMESPACE namespace and parse it into Resources. By default PLANS_NAMESPACE should be the same namespace where the controller pod is running.

func GetAllSideCarsResources added in v4.33.0

func GetAllSideCarsResources(s *Sidecars) (Resources, error)

func GetDefaultResources added in v4.33.0

func GetDefaultResources(kind string, s *Sidecars) *Resources

GetDefaultResources returns a new Resources struct with the default values.

func (*Resources) AddPsqlSidecarResources added in v4.33.0

func (r *Resources) AddPsqlSidecarResources(s *Sidecars, instances int64)

AddPsqlSidecarResources adds the resource overhead for the PostgreSQL sidecar to the given resource.

func (*Resources) AddResources added in v4.33.0

func (r *Resources) AddResources(resource Resources)

func (*Resources) CheckResourcesAgainstQuotas

func (r *Resources) CheckResourcesAgainstQuotas(ctx context.Context, c client.Client, claimName, instanceNamespace string, gk schema.GroupKind, instances int64) *apierrors.StatusError

CheckResourcesAgainstQuotas will check the given resources either against: The resources in the instanceNamespace, if it's found Or against the default quotas, if not found The second case is usually triggered if a new instance is created, as we don't have a namespace to check against. Once the namespace exists, the composition should ensure that the annotations are set.

func (*Resources) MultiplyBy

func (r *Resources) MultiplyBy(i int64)

MultiplyBy multiplies the resources by given integer. if given integer is less or equal to 0 it will not do any operation.

type Sidecars added in v4.33.0

type Sidecars map[string]sidecar

func FetchSidecarsFromCluster added in v4.33.0

func FetchSidecarsFromCluster(ctx context.Context, c client.Client, name string) (*Sidecars, error)

func FetchSidecarsFromConfig added in v4.33.0

func FetchSidecarsFromConfig(ctx context.Context, svc *runtime.ServiceRuntime) (*Sidecars, error)

Jump to

Keyboard shortcuts

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