Documentation ¶
Index ¶
Constants ¶
const ( OrgLabelName = "appuio.io/organization" // Namespace related quotas DefaultMaxNamespaces = 25 OverrideCMDataFieldName = "namespaceQuota" NsOverrideCMPrefix = "override-" NsOverrideCMNamespace = "appuio-cloud" )
Variables ¶
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) 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 DefaultCPULimit = 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 ¶
This section is empty.
Types ¶
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 (*Resources) CheckResourcesAgainstQuotas ¶
func (r *Resources) CheckResourcesAgainstQuotas(ctx context.Context, c client.Client, claimName, instanceNamespace string, gk schema.GroupKind) *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 ¶
MultiplyBy multiplies the resources by given integer. if given integer is less or equal to 0 it will not do any operation.