Documentation ¶
Index ¶
- Constants
- Variables
- type Plans
- type Resources
- func FetchPlansFromCluster(ctx context.Context, c client.Client, name, plan string) (Resources, error)
- func FetchPlansFromConfig(ctx context.Context, svc *runtime.ServiceRuntime, plan string) (Resources, error)
- func FetchSidecarFromCluster(ctx context.Context, c client.Client, name, sidecar string) (Resources, error)
- func GetAllSideCarsResources(s *Sidecars) (Resources, error)
- func GetDefaultResources(kind string, s *Sidecars) *Resources
- func (r *Resources) AddPsqlSidecarResources(s *Sidecars, instances int64)
- func (r *Resources) AddResources(resource Resources)
- func (r *Resources) CheckResourcesAgainstQuotas(ctx context.Context, c client.Client, claimName, instanceNamespace string, ...) *apierrors.StatusError
- func (r *Resources) MultiplyBy(i int64)
- type Sidecars
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 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 ¶
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 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 GetDefaultResources ¶ added in v4.33.0
GetDefaultResources returns a new Resources struct with the default values.
func (*Resources) AddPsqlSidecarResources ¶ added in v4.33.0
AddPsqlSidecarResources adds the resource overhead for the PostgreSQL sidecar to the given resource.
func (*Resources) AddResources ¶ added in v4.33.0
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 ¶
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