From bf21e851d9f0ea0ac1b1e9753fb2efae1fa04bc4 Mon Sep 17 00:00:00 2001 From: jiangpengcheng Date: Mon, 29 Apr 2024 15:17:28 +0800 Subject: [PATCH 1/5] Support manually update resources based on vpa --- api/compute/v1alpha1/common.go | 14 + api/compute/v1alpha1/zz_generated.deepcopy.go | 22 + ...ompute.functionmesh.io-backendconfigs.yaml | 2 +- ...ompute.functionmesh.io-functionmeshes.yaml | 610 +++++++- ...crd-compute.functionmesh.io-functions.yaml | 220 ++- .../crd-compute.functionmesh.io-sinks.yaml | 197 ++- .../crd-compute.functionmesh.io-sources.yaml | 197 ++- ...ompute.functionmesh.io_backendconfigs.yaml | 3 +- ...ompute.functionmesh.io_functionmeshes.yaml | 611 +++++++- .../compute.functionmesh.io_functions.yaml | 221 ++- .../bases/compute.functionmesh.io_sinks.yaml | 198 ++- .../compute.functionmesh.io_sources.yaml | 198 ++- config/rbac/role.yaml | 1 - config/webhook/manifests.yaml | 2 - controllers/common.go | 83 +- controllers/common_test.go | 365 +++++ controllers/function.go | 15 +- controllers/function_controller.go | 34 +- controllers/sink.go | 15 +- controllers/sink_controller.go | 33 +- controllers/source.go | 15 +- controllers/source_controller.go | 35 +- controllers/spec/common.go | 10 +- controllers/spec/function.go | 14 +- controllers/spec/sink.go | 12 +- controllers/spec/source.go | 12 +- controllers/spec/vpa.go | 60 +- manifests/crd.yaml | 1244 ++++++++++++++++- 28 files changed, 4321 insertions(+), 122 deletions(-) create mode 100644 controllers/common_test.go diff --git a/api/compute/v1alpha1/common.go b/api/compute/v1alpha1/common.go index 3a8d90769..8de9d7504 100644 --- a/api/compute/v1alpha1/common.go +++ b/api/compute/v1alpha1/common.go @@ -22,6 +22,7 @@ import ( "fmt" "strconv" + "k8s.io/apimachinery/pkg/api/resource" vpav1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1" autov2 "k8s.io/api/autoscaling/v2" @@ -558,6 +559,19 @@ type VPASpec struct { // Controls how the autoscaler computes recommended resources. // +optional ResourcePolicy *vpav1.PodResourcePolicy `json:"resourcePolicy,omitempty"` + + // Whether the function or connector has a special resource unit + // if yes, the vpa should not update the pod resources automatically + // +optional + ResourceUnit *ResourceUnit `json:"resourceUnit,omitempty"` +} + +type ResourceUnit struct { + // The CPU request for the pod + Cpu resource.Quantity `json:"cpu,omitempty"` + + // The memory request for the pod + Memory resource.Quantity `json:"memory,omitempty"` } type Liveness struct { diff --git a/api/compute/v1alpha1/zz_generated.deepcopy.go b/api/compute/v1alpha1/zz_generated.deepcopy.go index c8909120f..e9a59184c 100644 --- a/api/compute/v1alpha1/zz_generated.deepcopy.go +++ b/api/compute/v1alpha1/zz_generated.deepcopy.go @@ -1035,6 +1035,23 @@ func (in *ResourceCondition) DeepCopy() *ResourceCondition { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResourceUnit) DeepCopyInto(out *ResourceUnit) { + *out = *in + out.Cpu = in.Cpu.DeepCopy() + out.Memory = in.Memory.DeepCopy() +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceUnit. +func (in *ResourceUnit) DeepCopy() *ResourceUnit { + if in == nil { + return nil + } + out := new(ResourceUnit) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Runtime) DeepCopyInto(out *Runtime) { *out = *in @@ -1461,6 +1478,11 @@ func (in *VPASpec) DeepCopyInto(out *VPASpec) { *out = new(autoscaling_k8s_iov1.PodResourcePolicy) (*in).DeepCopyInto(*out) } + if in.ResourceUnit != nil { + in, out := &in.ResourceUnit, &out.ResourceUnit + *out = new(ResourceUnit) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VPASpec. diff --git a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-backendconfigs.yaml b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-backendconfigs.yaml index 888cdbde4..070b04c5a 100644 --- a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-backendconfigs.yaml +++ b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-backendconfigs.yaml @@ -6,7 +6,7 @@ metadata: {{- if eq .Values.admissionWebhook.certificate.provider "cert-manager" }} {{- include "function-mesh-operator.certManager.annotation" . | nindent 4 -}} {{- end }} - controller-gen.kubebuilder.io/version: v0.9.2 + controller-gen.kubebuilder.io/version: v0.15.0 name: backendconfigs.compute.functionmesh.io spec: conversion: diff --git a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functionmeshes.yaml b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functionmeshes.yaml index 93862ea4d..56d856e88 100644 --- a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functionmeshes.yaml +++ b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functionmeshes.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 + controller-gen.kubebuilder.io/version: v0.15.0 name: functionmeshes.compute.functionmesh.io spec: group: compute.functionmesh.io @@ -484,6 +484,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -552,6 +562,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -618,6 +638,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -686,6 +716,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -1260,6 +1300,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1310,6 +1358,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1506,8 +1562,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -1525,6 +1606,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -1942,6 +2025,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1992,6 +2083,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -2188,8 +2287,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -2207,6 +2331,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -2652,11 +2778,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -2702,6 +2829,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -2890,6 +3019,43 @@ spec: sources: items: properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object configMap: properties: items: @@ -3170,6 +3336,21 @@ spec: type: object type: array type: object + resourceUnit: + properties: + cpu: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + memory: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object updatePolicy: properties: minReplicas: @@ -3336,6 +3517,18 @@ spec: type: integer resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -3456,11 +3649,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -3506,6 +3700,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -3517,6 +3713,11 @@ spec: items: type: string type: array + allocatedResourceStatuses: + additionalProperties: + type: string + type: object + x-kubernetes-map-type: granular allocatedResources: additionalProperties: anyOf: @@ -3555,9 +3756,18 @@ spec: - type type: object type: array - phase: + currentVolumeAttributesClassName: type: string - resizeStatus: + modifyVolumeStatus: + properties: + status: + type: string + targetVolumeAttributesClassName: + type: string + required: + - status + type: object + phase: type: string type: object type: object @@ -3992,6 +4202,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -4060,6 +4280,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -4126,6 +4356,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -4194,6 +4434,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -4768,6 +5018,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -4818,6 +5076,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -5014,8 +5280,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -5033,6 +5324,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -5450,6 +5743,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -5500,6 +5801,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -5696,8 +6005,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -5715,6 +6049,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -6160,11 +6496,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -6210,6 +6547,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -6398,6 +6737,43 @@ spec: sources: items: properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object configMap: properties: items: @@ -6678,6 +7054,21 @@ spec: type: object type: array type: object + resourceUnit: + properties: + cpu: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + memory: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object updatePolicy: properties: minReplicas: @@ -6844,6 +7235,18 @@ spec: type: integer resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -7310,6 +7713,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -7378,6 +7791,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -7444,6 +7867,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -7512,6 +7945,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -8086,6 +8529,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -8136,6 +8587,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -8332,8 +8791,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -8351,6 +8835,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -8768,6 +9254,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -8818,6 +9312,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -9014,8 +9516,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -9033,6 +9560,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -9478,11 +10007,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -9528,6 +10058,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -9716,6 +10248,43 @@ spec: sources: items: properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object configMap: properties: items: @@ -9996,6 +10565,21 @@ spec: type: object type: array type: object + resourceUnit: + properties: + cpu: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + memory: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object updatePolicy: properties: minReplicas: @@ -10162,6 +10746,18 @@ spec: type: integer resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: diff --git a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functions.yaml b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functions.yaml index f8aa5cbcc..a33c17703 100644 --- a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functions.yaml +++ b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functions.yaml @@ -6,7 +6,7 @@ metadata: {{- if eq .Values.admissionWebhook.certificate.provider "cert-manager" }} {{- include "function-mesh-operator.certManager.annotation" . | nindent 4 -}} {{- end }} - controller-gen.kubebuilder.io/version: v0.9.2 + controller-gen.kubebuilder.io/version: v0.15.0 name: functions.compute.functionmesh.io spec: conversion: @@ -503,6 +503,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -571,6 +581,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -637,6 +657,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -705,6 +735,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -1279,6 +1319,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1329,6 +1377,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1525,8 +1581,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -1544,6 +1625,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -1961,6 +2044,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -2011,6 +2102,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -2207,8 +2306,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -2226,6 +2350,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -2671,11 +2797,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -2721,6 +2848,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -2909,6 +3038,43 @@ spec: sources: items: properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object configMap: properties: items: @@ -3189,6 +3355,21 @@ spec: type: object type: array type: object + resourceUnit: + properties: + cpu: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + memory: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object updatePolicy: properties: minReplicas: @@ -3355,6 +3536,18 @@ spec: type: integer resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -3475,11 +3668,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -3525,6 +3719,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -3536,6 +3732,11 @@ spec: items: type: string type: array + allocatedResourceStatuses: + additionalProperties: + type: string + type: object + x-kubernetes-map-type: granular allocatedResources: additionalProperties: anyOf: @@ -3574,9 +3775,18 @@ spec: - type type: object type: array - phase: + currentVolumeAttributesClassName: type: string - resizeStatus: + modifyVolumeStatus: + properties: + status: + type: string + targetVolumeAttributesClassName: + type: string + required: + - status + type: object + phase: type: string type: object type: object diff --git a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sinks.yaml b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sinks.yaml index 21294ce9e..afe2246d3 100644 --- a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sinks.yaml +++ b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sinks.yaml @@ -6,7 +6,7 @@ metadata: {{- if eq .Values.admissionWebhook.certificate.provider "cert-manager" }} {{- include "function-mesh-operator.certManager.annotation" . | nindent 4 -}} {{- end }} - controller-gen.kubebuilder.io/version: v0.9.2 + controller-gen.kubebuilder.io/version: v0.15.0 name: sinks.compute.functionmesh.io spec: conversion: @@ -424,6 +424,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -492,6 +502,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -558,6 +578,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -626,6 +656,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -1200,6 +1240,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1250,6 +1298,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1446,8 +1502,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -1465,6 +1546,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -1882,6 +1965,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1932,6 +2023,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -2128,8 +2227,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -2147,6 +2271,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -2592,11 +2718,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -2642,6 +2769,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -2830,6 +2959,43 @@ spec: sources: items: properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object configMap: properties: items: @@ -3110,6 +3276,21 @@ spec: type: object type: array type: object + resourceUnit: + properties: + cpu: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + memory: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object updatePolicy: properties: minReplicas: @@ -3276,6 +3457,18 @@ spec: type: integer resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: diff --git a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sources.yaml b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sources.yaml index b050a1295..ae285a69a 100644 --- a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sources.yaml +++ b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sources.yaml @@ -6,7 +6,7 @@ metadata: {{- if eq .Values.admissionWebhook.certificate.provider "cert-manager" }} {{- include "function-mesh-operator.certManager.annotation" . | nindent 4 -}} {{- end }} - controller-gen.kubebuilder.io/version: v0.9.2 + controller-gen.kubebuilder.io/version: v0.15.0 name: sources.compute.functionmesh.io spec: conversion: @@ -419,6 +419,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -487,6 +497,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -553,6 +573,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -621,6 +651,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -1195,6 +1235,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1245,6 +1293,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1441,8 +1497,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -1460,6 +1541,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -1877,6 +1960,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1927,6 +2018,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -2123,8 +2222,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -2142,6 +2266,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -2587,11 +2713,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -2637,6 +2764,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -2825,6 +2954,43 @@ spec: sources: items: properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object configMap: properties: items: @@ -3105,6 +3271,21 @@ spec: type: object type: array type: object + resourceUnit: + properties: + cpu: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + memory: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object updatePolicy: properties: minReplicas: @@ -3271,6 +3452,18 @@ spec: type: integer resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: diff --git a/config/crd/bases/compute.functionmesh.io_backendconfigs.yaml b/config/crd/bases/compute.functionmesh.io_backendconfigs.yaml index 68b0d271c..96c16a69e 100644 --- a/config/crd/bases/compute.functionmesh.io_backendconfigs.yaml +++ b/config/crd/bases/compute.functionmesh.io_backendconfigs.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.15.0 name: backendconfigs.compute.functionmesh.io spec: group: compute.functionmesh.io diff --git a/config/crd/bases/compute.functionmesh.io_functionmeshes.yaml b/config/crd/bases/compute.functionmesh.io_functionmeshes.yaml index f8c01e895..b9f855e58 100644 --- a/config/crd/bases/compute.functionmesh.io_functionmeshes.yaml +++ b/config/crd/bases/compute.functionmesh.io_functionmeshes.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.15.0 name: functionmeshes.compute.functionmesh.io spec: group: compute.functionmesh.io @@ -485,6 +484,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -553,6 +562,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -619,6 +638,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -687,6 +716,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -1261,6 +1300,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1311,6 +1358,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1507,8 +1562,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -1526,6 +1606,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -1943,6 +2025,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1993,6 +2083,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -2189,8 +2287,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -2208,6 +2331,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -2653,11 +2778,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -2703,6 +2829,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -2891,6 +3019,43 @@ spec: sources: items: properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object configMap: properties: items: @@ -3171,6 +3336,21 @@ spec: type: object type: array type: object + resourceUnit: + properties: + cpu: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + memory: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object updatePolicy: properties: minReplicas: @@ -3337,6 +3517,18 @@ spec: type: integer resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -3457,11 +3649,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -3507,6 +3700,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -3518,6 +3713,11 @@ spec: items: type: string type: array + allocatedResourceStatuses: + additionalProperties: + type: string + type: object + x-kubernetes-map-type: granular allocatedResources: additionalProperties: anyOf: @@ -3556,9 +3756,18 @@ spec: - type type: object type: array - phase: + currentVolumeAttributesClassName: type: string - resizeStatus: + modifyVolumeStatus: + properties: + status: + type: string + targetVolumeAttributesClassName: + type: string + required: + - status + type: object + phase: type: string type: object type: object @@ -3993,6 +4202,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -4061,6 +4280,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -4127,6 +4356,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -4195,6 +4434,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -4769,6 +5018,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -4819,6 +5076,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -5015,8 +5280,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -5034,6 +5324,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -5451,6 +5743,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -5501,6 +5801,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -5697,8 +6005,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -5716,6 +6049,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -6161,11 +6496,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -6211,6 +6547,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -6399,6 +6737,43 @@ spec: sources: items: properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object configMap: properties: items: @@ -6679,6 +7054,21 @@ spec: type: object type: array type: object + resourceUnit: + properties: + cpu: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + memory: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object updatePolicy: properties: minReplicas: @@ -6845,6 +7235,18 @@ spec: type: integer resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -7311,6 +7713,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -7379,6 +7791,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -7445,6 +7867,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -7513,6 +7945,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -8087,6 +8529,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -8137,6 +8587,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -8333,8 +8791,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -8352,6 +8835,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -8769,6 +9254,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -8819,6 +9312,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -9015,8 +9516,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -9034,6 +9560,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -9479,11 +10007,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -9529,6 +10058,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -9717,6 +10248,43 @@ spec: sources: items: properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object configMap: properties: items: @@ -9997,6 +10565,21 @@ spec: type: object type: array type: object + resourceUnit: + properties: + cpu: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + memory: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object updatePolicy: properties: minReplicas: @@ -10163,6 +10746,18 @@ spec: type: integer resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: diff --git a/config/crd/bases/compute.functionmesh.io_functions.yaml b/config/crd/bases/compute.functionmesh.io_functions.yaml index 07b4ca0fc..f59c7c10f 100644 --- a/config/crd/bases/compute.functionmesh.io_functions.yaml +++ b/config/crd/bases/compute.functionmesh.io_functions.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.15.0 name: functions.compute.functionmesh.io spec: group: compute.functionmesh.io @@ -482,6 +481,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -550,6 +559,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -616,6 +635,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -684,6 +713,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -1258,6 +1297,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1308,6 +1355,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1504,8 +1559,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -1523,6 +1603,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -1940,6 +2022,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1990,6 +2080,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -2186,8 +2284,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -2205,6 +2328,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -2650,11 +2775,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -2700,6 +2826,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -2888,6 +3016,43 @@ spec: sources: items: properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object configMap: properties: items: @@ -3168,6 +3333,21 @@ spec: type: object type: array type: object + resourceUnit: + properties: + cpu: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + memory: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object updatePolicy: properties: minReplicas: @@ -3334,6 +3514,18 @@ spec: type: integer resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -3454,11 +3646,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -3504,6 +3697,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -3515,6 +3710,11 @@ spec: items: type: string type: array + allocatedResourceStatuses: + additionalProperties: + type: string + type: object + x-kubernetes-map-type: granular allocatedResources: additionalProperties: anyOf: @@ -3553,9 +3753,18 @@ spec: - type type: object type: array - phase: + currentVolumeAttributesClassName: type: string - resizeStatus: + modifyVolumeStatus: + properties: + status: + type: string + targetVolumeAttributesClassName: + type: string + required: + - status + type: object + phase: type: string type: object type: object diff --git a/config/crd/bases/compute.functionmesh.io_sinks.yaml b/config/crd/bases/compute.functionmesh.io_sinks.yaml index 984826079..9336d1c8d 100644 --- a/config/crd/bases/compute.functionmesh.io_sinks.yaml +++ b/config/crd/bases/compute.functionmesh.io_sinks.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.15.0 name: sinks.compute.functionmesh.io spec: group: compute.functionmesh.io @@ -403,6 +402,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -471,6 +480,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -537,6 +556,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -605,6 +634,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -1179,6 +1218,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1229,6 +1276,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1425,8 +1480,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -1444,6 +1524,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -1861,6 +1943,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1911,6 +2001,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -2107,8 +2205,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -2126,6 +2249,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -2571,11 +2696,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -2621,6 +2747,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -2809,6 +2937,43 @@ spec: sources: items: properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object configMap: properties: items: @@ -3089,6 +3254,21 @@ spec: type: object type: array type: object + resourceUnit: + properties: + cpu: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + memory: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object updatePolicy: properties: minReplicas: @@ -3255,6 +3435,18 @@ spec: type: integer resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: diff --git a/config/crd/bases/compute.functionmesh.io_sources.yaml b/config/crd/bases/compute.functionmesh.io_sources.yaml index 028ddf78c..1d21b275d 100644 --- a/config/crd/bases/compute.functionmesh.io_sources.yaml +++ b/config/crd/bases/compute.functionmesh.io_sources.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.15.0 name: sources.compute.functionmesh.io spec: group: compute.functionmesh.io @@ -398,6 +397,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -466,6 +475,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -532,6 +551,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -600,6 +629,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -1174,6 +1213,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1224,6 +1271,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1420,8 +1475,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -1439,6 +1519,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -1856,6 +1938,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1906,6 +1996,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -2102,8 +2200,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -2121,6 +2244,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -2566,11 +2691,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -2616,6 +2742,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -2804,6 +2932,43 @@ spec: sources: items: properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object configMap: properties: items: @@ -3084,6 +3249,21 @@ spec: type: object type: array type: object + resourceUnit: + properties: + cpu: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + memory: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object updatePolicy: properties: minReplicas: @@ -3250,6 +3430,18 @@ spec: type: integer resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 7ba2a2733..0f8dd41ef 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -2,7 +2,6 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - creationTimestamp: null name: manager-role rules: - apiGroups: diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml index 79400e6d4..47cbd5b2d 100644 --- a/config/webhook/manifests.yaml +++ b/config/webhook/manifests.yaml @@ -2,7 +2,6 @@ apiVersion: admissionregistration.k8s.io/v1 kind: MutatingWebhookConfiguration metadata: - creationTimestamp: null name: mutating-webhook-configuration webhooks: - admissionReviewVersions: @@ -72,7 +71,6 @@ webhooks: apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration metadata: - creationTimestamp: null name: validating-webhook-configuration webhooks: - admissionReviewVersions: diff --git a/controllers/common.go b/controllers/common.go index eaa41ab51..09f271464 100644 --- a/controllers/common.go +++ b/controllers/common.go @@ -24,6 +24,8 @@ import ( "github.com/streamnative/function-mesh/utils" autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/predicate" @@ -76,7 +78,7 @@ func deleteHPA(ctx context.Context, r client.Client, name types.NamespacedName) } func observeVPA(ctx context.Context, r client.Reader, name types.NamespacedName, vpaSpec *v1alpha1.VPASpec, - conditions map[v1alpha1.Component]v1alpha1.ResourceCondition) error { + conditions map[v1alpha1.Component]v1alpha1.ResourceCondition) (*corev1.ResourceRequirements, error) { _, ok := conditions[v1alpha1.VPA] condition := v1alpha1.ResourceCondition{Condition: v1alpha1.VPAReady} if !ok { @@ -84,10 +86,10 @@ func observeVPA(ctx context.Context, r client.Reader, name types.NamespacedName, condition.Status = metav1.ConditionFalse condition.Action = v1alpha1.Create conditions[v1alpha1.VPA] = condition - return nil + return nil, nil } // VPA is not enabled, skip further action - return nil + return nil, nil } vpa := &vpav1.VerticalPodAutoscaler{} @@ -96,14 +98,14 @@ func observeVPA(ctx context.Context, r client.Reader, name types.NamespacedName, if errors.IsNotFound(err) { if vpaSpec == nil { // VPA is deleted, delete the status delete(conditions, v1alpha1.VPA) - return nil + return nil, nil } condition.Status = metav1.ConditionFalse condition.Action = v1alpha1.Create conditions[v1alpha1.VPA] = condition - return nil + return nil, nil } - return err + return nil, err } // old VPA exists while new Spec removes it, delete the old one @@ -111,22 +113,81 @@ func observeVPA(ctx context.Context, r client.Reader, name types.NamespacedName, condition.Status = metav1.ConditionFalse condition.Action = v1alpha1.Delete conditions[v1alpha1.VPA] = condition - return nil + return nil, nil } // compare exists VPA with new Spec - if !reflect.DeepEqual(vpa.Spec.UpdatePolicy, vpaSpec.UpdatePolicy) || - !reflect.DeepEqual(vpa.Spec.ResourcePolicy, vpaSpec.ResourcePolicy) { + updatePolicy := vpaSpec.UpdatePolicy + spec.UpdateVPAUpdatePolicy(updatePolicy, vpaSpec.ResourceUnit) + resourcePolicy := vpaSpec.ResourcePolicy + containerName := spec.GetVPAContainerName(&vpa.ObjectMeta) + spec.UpdateResourcePolicy(resourcePolicy, containerName) + if !reflect.DeepEqual(updatePolicy, vpa.Spec.UpdatePolicy) || + !reflect.DeepEqual(resourcePolicy, vpa.Spec.ResourcePolicy) { condition.Status = metav1.ConditionFalse condition.Action = v1alpha1.Update conditions[v1alpha1.VPA] = condition - return nil + return nil, nil } condition.Action = v1alpha1.NoAction condition.Status = metav1.ConditionTrue conditions[v1alpha1.VPA] = condition - return nil + + // if object has special resource unit, we need to manually apply the recommendation to it + resources := calculateVPARecommendation(vpa, vpaSpec) + return resources, nil +} + +func calculateVPARecommendation(vpa *vpav1.VerticalPodAutoscaler, vpaSpec *v1alpha1.VPASpec) *corev1.ResourceRequirements { + var multiple int64 = 0 + if vpaSpec.ResourceUnit == nil || vpaSpec.ResourceUnit.Cpu.MilliValue() == 0 && vpaSpec.ResourceUnit.Memory.MilliValue() == 0 { + return nil + } + if vpa.Status.Recommendation != nil && vpa.Status.Recommendation.ContainerRecommendations != nil { + for _, recommend := range vpa.Status.Recommendation.ContainerRecommendations { + // set resource based on CPU + if recommend.Target.Cpu() != nil && recommend.Target.Cpu().Value() != 0 { + multiple = recommend.Target.Cpu().MilliValue() / vpaSpec.ResourceUnit.Cpu.MilliValue() + if recommend.Target.Cpu().MilliValue()%vpaSpec.ResourceUnit.Cpu.MilliValue() != 0 { + multiple += 1 + } + } else if recommend.Target.Memory() != nil { // set resources based on Memory + multiple = recommend.Target.Memory().MilliValue() / vpaSpec.ResourceUnit.Memory.MilliValue() + if recommend.Target.Memory().MilliValue()%vpaSpec.ResourceUnit.Memory.MilliValue() != 0 { + multiple += 1 + } + } + } + } + + if multiple == 0 { + return nil + } + targetCpu := *resource.NewScaledQuantity(multiple*vpaSpec.ResourceUnit.Cpu.MilliValue(), resource.Milli) + targetMemory := *resource.NewScaledQuantity(multiple*vpaSpec.ResourceUnit.Memory.MilliValue(), resource.Milli) + + if vpa.Spec.ResourcePolicy == nil || len(vpa.Spec.ResourcePolicy.ContainerPolicies) == 0 || + vpa.Spec.ResourcePolicy.ContainerPolicies[0].ControlledValues == nil || + *vpa.Spec.ResourcePolicy.ContainerPolicies[0].ControlledValues == vpav1.ContainerControlledValuesRequestsAndLimits { + return &corev1.ResourceRequirements{ + Limits: corev1.ResourceList{ + corev1.ResourceCPU: targetCpu, + corev1.ResourceMemory: targetMemory, + }, + Requests: corev1.ResourceList{ + corev1.ResourceCPU: targetCpu, + corev1.ResourceMemory: targetMemory, + }, + } + } else { + return &corev1.ResourceRequirements{ + Requests: corev1.ResourceList{ + corev1.ResourceCPU: targetCpu, + corev1.ResourceMemory: targetMemory, + }, + } + } } func applyVPA(ctx context.Context, r client.Client, logger logr.Logger, condition v1alpha1.ResourceCondition, diff --git a/controllers/common_test.go b/controllers/common_test.go new file mode 100644 index 000000000..e2f73227e --- /dev/null +++ b/controllers/common_test.go @@ -0,0 +1,365 @@ +/* +Copyright 2017 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package controllers + +import ( + "reflect" + "testing" + + "github.com/streamnative/function-mesh/api/compute/v1alpha1" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" + vpav1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1" +) + +func Test_calculateVPARecommendation(t *testing.T) { + type args struct { + vpa *vpav1.VerticalPodAutoscaler + vpaSpec *v1alpha1.VPASpec + } + requestsOnly := vpav1.ContainerControlledValuesRequestsOnly + tests := []struct { + name string + args args + want *corev1.ResourceRequirements + }{ + { + name: "Use the target cpu when target cpu is equal to the resource unit cpu", + args: args{ + vpa: &vpav1.VerticalPodAutoscaler{ + Status: vpav1.VerticalPodAutoscalerStatus{ + Recommendation: &vpav1.RecommendedPodResources{ + ContainerRecommendations: []vpav1.RecommendedContainerResources{ + { + Target: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("0.2"), + corev1.ResourceMemory: resource.MustParse("1Gi"), + }, + }, + }, + }, + }, + }, + vpaSpec: &v1alpha1.VPASpec{ + ResourceUnit: &v1alpha1.ResourceUnit{ + Cpu: resource.MustParse("200m"), + Memory: resource.MustParse("800Mi"), + }, + }, + }, + want: &corev1.ResourceRequirements{ + Requests: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(200, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(800*1024*1024*1000, resource.Milli), + }, + Limits: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(200, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(800*1024*1024*1000, resource.Milli), + }, + }, + }, + { + name: "Increase to resource unit when target cpu is smaller than the resource unit cpu", + args: args{ + vpa: &vpav1.VerticalPodAutoscaler{ + Status: vpav1.VerticalPodAutoscalerStatus{ + Recommendation: &vpav1.RecommendedPodResources{ + ContainerRecommendations: []vpav1.RecommendedContainerResources{ + { + Target: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("100m"), + corev1.ResourceMemory: resource.MustParse("1Gi"), + }, + }, + }, + }, + }, + }, + vpaSpec: &v1alpha1.VPASpec{ + ResourceUnit: &v1alpha1.ResourceUnit{ + Cpu: resource.MustParse("0.2"), // 200m + Memory: resource.MustParse("838860800"), // 800Mi + }, + }, + }, + want: &corev1.ResourceRequirements{ + Requests: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(200, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(800*1024*1024*1000, resource.Milli), + }, + Limits: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(200, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(800*1024*1024*1000, resource.Milli), + }, + }, + }, + { + name: "Use the target cpu when target cpu can evenly divide by the resource unit cpu", + args: args{ + vpa: &vpav1.VerticalPodAutoscaler{ + Status: vpav1.VerticalPodAutoscalerStatus{ + Recommendation: &vpav1.RecommendedPodResources{ + ContainerRecommendations: []vpav1.RecommendedContainerResources{ + { + Target: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("400m"), + corev1.ResourceMemory: resource.MustParse("1Gi"), + }, + }, + }, + }, + }, + }, + vpaSpec: &v1alpha1.VPASpec{ + ResourceUnit: &v1alpha1.ResourceUnit{ + Cpu: resource.MustParse("0.2"), + Memory: resource.MustParse("838860800"), + }, + }, + }, + want: &corev1.ResourceRequirements{ + Requests: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(400, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(2*800*1024*1024*1000, resource.Milli), + }, + Limits: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(400, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(2*800*1024*1024*1000, resource.Milli), + }, + }, + }, + { + name: "Increase to the smallest multiples of resource unit cpu when target cpu cannot evenly divided by the resource unit cpu", + args: args{ + vpa: &vpav1.VerticalPodAutoscaler{ + Status: vpav1.VerticalPodAutoscalerStatus{ + Recommendation: &vpav1.RecommendedPodResources{ + ContainerRecommendations: []vpav1.RecommendedContainerResources{ + { + Target: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("0.45"), + corev1.ResourceMemory: resource.MustParse("1Gi"), + }, + }, + }, + }, + }, + }, + vpaSpec: &v1alpha1.VPASpec{ + ResourceUnit: &v1alpha1.ResourceUnit{ + Cpu: resource.MustParse("200m"), + Memory: resource.MustParse("800Mi"), + }, + }, + }, + want: &corev1.ResourceRequirements{ + Requests: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(600, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(3*800*1024*1024*1000, resource.Milli), + }, + Limits: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(600, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(3*800*1024*1024*1000, resource.Milli), + }, + }, + }, + { + name: "Use the target memory when target memory is equal to the resource unit memory", + args: args{ + vpa: &vpav1.VerticalPodAutoscaler{ + Status: vpav1.VerticalPodAutoscalerStatus{ + Recommendation: &vpav1.RecommendedPodResources{ + ContainerRecommendations: []vpav1.RecommendedContainerResources{ + { + Target: corev1.ResourceList{ + corev1.ResourceMemory: resource.MustParse("800Mi"), + }, + }, + }, + }, + }, + }, + vpaSpec: &v1alpha1.VPASpec{ + ResourceUnit: &v1alpha1.ResourceUnit{ + Cpu: resource.MustParse("200m"), + Memory: resource.MustParse("838860800"), + }, + }, + }, + want: &corev1.ResourceRequirements{ + Requests: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(200, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(800*1024*1024*1000, resource.Milli), + }, + Limits: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(200, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(800*1024*1024*1000, resource.Milli), + }, + }, + }, + { + name: "Increase to resource unit when target memory is smaller than the resource unit memory", + args: args{ + vpa: &vpav1.VerticalPodAutoscaler{ + Status: vpav1.VerticalPodAutoscalerStatus{ + Recommendation: &vpav1.RecommendedPodResources{ + ContainerRecommendations: []vpav1.RecommendedContainerResources{ + { + Target: corev1.ResourceList{ + corev1.ResourceMemory: resource.MustParse("629145600"), // 600Mi + }, + }, + }, + }, + }, + }, + vpaSpec: &v1alpha1.VPASpec{ + ResourceUnit: &v1alpha1.ResourceUnit{ + Cpu: resource.MustParse("200m"), + Memory: resource.MustParse("800Mi"), + }, + }, + }, + want: &corev1.ResourceRequirements{ + Requests: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(200, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(800*1024*1024*1000, resource.Milli), + }, + Limits: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(200, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(800*1024*1024*1000, resource.Milli), + }, + }, + }, + { + name: "Use the target memory when target memory can evenly divide by the resource unit memory", + args: args{ + vpa: &vpav1.VerticalPodAutoscaler{ + Status: vpav1.VerticalPodAutoscalerStatus{ + Recommendation: &vpav1.RecommendedPodResources{ + ContainerRecommendations: []vpav1.RecommendedContainerResources{ + { + Target: corev1.ResourceList{ + corev1.ResourceMemory: resource.MustParse("1600Mi"), + }, + }, + }, + }, + }, + }, + vpaSpec: &v1alpha1.VPASpec{ + ResourceUnit: &v1alpha1.ResourceUnit{ + Cpu: resource.MustParse("200m"), + Memory: resource.MustParse("800Mi"), + }, + }, + }, + want: &corev1.ResourceRequirements{ + Requests: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(400, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(2*800*1024*1024*1000, resource.Milli), + }, + Limits: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(400, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(2*800*1024*1024*1000, resource.Milli), + }, + }, + }, + { + name: "Increase to the smallest multiples of resource unit memory when target memory cannot evenly divided by the resource unit memory", + args: args{ + vpa: &vpav1.VerticalPodAutoscaler{ + Status: vpav1.VerticalPodAutoscalerStatus{ + Recommendation: &vpav1.RecommendedPodResources{ + ContainerRecommendations: []vpav1.RecommendedContainerResources{ + { + Target: corev1.ResourceList{ + corev1.ResourceMemory: resource.MustParse("1.7Gi"), + }, + }, + }, + }, + }, + }, + vpaSpec: &v1alpha1.VPASpec{ + ResourceUnit: &v1alpha1.ResourceUnit{ + Cpu: resource.MustParse("200m"), + Memory: resource.MustParse("800Mi"), + }, + }, + }, + want: &corev1.ResourceRequirements{ + Requests: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(600, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(3*800*1024*1024*1000, resource.Milli), + }, + Limits: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(600, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(3*800*1024*1024*1000, resource.Milli), + }, + }, + }, + { + name: "Only set request resources when it set requestsOnly", + args: args{ + vpa: &vpav1.VerticalPodAutoscaler{ + Status: vpav1.VerticalPodAutoscalerStatus{ + Recommendation: &vpav1.RecommendedPodResources{ + ContainerRecommendations: []vpav1.RecommendedContainerResources{ + { + Target: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("200m"), + corev1.ResourceMemory: resource.MustParse("1Gi"), + }, + }, + }, + }, + }, + Spec: vpav1.VerticalPodAutoscalerSpec{ + ResourcePolicy: &vpav1.PodResourcePolicy{ + ContainerPolicies: []vpav1.ContainerResourcePolicy{ + { + ContainerName: "pulsar-function", + ControlledValues: &requestsOnly, + }, + }, + }, + }, + }, + vpaSpec: &v1alpha1.VPASpec{ + ResourceUnit: &v1alpha1.ResourceUnit{ + Cpu: resource.MustParse("200m"), + Memory: resource.MustParse("800Mi"), + }, + }, + }, + want: &corev1.ResourceRequirements{ + Requests: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(200, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(800*1024*1024*1000, resource.Milli), + }, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := calculateVPARecommendation(tt.args.vpa, tt.args.vpaSpec); !reflect.DeepEqual(got, tt.want) { + t.Errorf("calculateVPARecommendation() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/controllers/function.go b/controllers/function.go index f84bc594b..e0a15ee75 100644 --- a/controllers/function.go +++ b/controllers/function.go @@ -325,8 +325,21 @@ func (r *FunctionReconciler) ApplyFunctionHPAV2Beta2(ctx context.Context, functi } func (r *FunctionReconciler) ObserveFunctionVPA(ctx context.Context, function *v1alpha1.Function) error { - return observeVPA(ctx, r, types.NamespacedName{Namespace: function.Namespace, + resource, err := observeVPA(ctx, r, types.NamespacedName{Namespace: function.Namespace, Name: spec.MakeFunctionObjectMeta(function).Name}, function.Spec.Pod.VPA, function.Status.Conditions) + if resource != nil { + originalResource := function.Spec.Resources + // the resource may not have limits + if resource.Limits == nil { + resource.Limits = originalResource.Limits + } + function.Spec.Resources = *resource + if err = r.Update(ctx, function); err != nil { + return err + } + function.Spec.Resources = originalResource + } + return err } func (r *FunctionReconciler) ApplyFunctionVPA(ctx context.Context, function *v1alpha1.Function) error { diff --git a/controllers/function_controller.go b/controllers/function_controller.go index 41096ed23..cc234d52d 100644 --- a/controllers/function_controller.go +++ b/controllers/function_controller.go @@ -19,6 +19,7 @@ package controllers import ( "context" + "strings" "time" "github.com/streamnative/function-mesh/pkg/monitoring" @@ -100,6 +101,12 @@ func (r *FunctionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c function.Status.Conditions = make(map[v1alpha1.Component]v1alpha1.ResourceCondition) } + if r.GroupVersionFlags != nil && r.GroupVersionFlags.WatchVPACRDs { + err = r.ObserveFunctionVPA(ctx, function) + if err != nil { + return reconcile.Result{}, err + } + } err = r.ObserveFunctionStatefulSet(ctx, function) if err != nil { return reconcile.Result{}, err @@ -119,12 +126,6 @@ func (r *FunctionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c return reconcile.Result{}, err } } - if r.GroupVersionFlags != nil && r.GroupVersionFlags.WatchVPACRDs { - err = r.ObserveFunctionVPA(ctx, function) - if err != nil { - return reconcile.Result{}, err - } - } err = r.Status().Update(ctx, function) if err != nil { r.Log.Error(err, "failed to update function status after observing resources") @@ -222,6 +223,27 @@ func (r *FunctionReconciler) SetupWithManager(mgr ctrl.Manager) error { }), ) + // Watch for vpa changes if function has special resource unit + if r.GroupVersionFlags != nil && r.GroupVersionFlags.WatchVPACRDs { + manager.Watches(&vpav1.VerticalPodAutoscaler{}, handler.EnqueueRequestsFromMapFunc( + func(ctx context.Context, object client.Object) []reconcile.Request { + if object.GetLabels()[spec.LabelCustomResourceUnit] == "true" && + object.GetLabels()[spec.LabelComponent] == spec.ComponentFunction { + return []reconcile.Request{ + { + NamespacedName: types.NamespacedName{ + Namespace: object.GetNamespace(), + Name: strings.TrimSuffix(object.GetName(), "-function"), + }, + }, + } + + } + return nil + }), + ) + } + if r.GroupVersionFlags != nil && r.GroupVersionFlags.WatchVPACRDs { manager.Owns(&vpav1.VerticalPodAutoscaler{}) } diff --git a/controllers/sink.go b/controllers/sink.go index 235cedab4..5e9e3f663 100644 --- a/controllers/sink.go +++ b/controllers/sink.go @@ -321,8 +321,21 @@ func (r *SinkReconciler) ApplySinkHPAV2Beta2(ctx context.Context, sink *v1alpha1 } func (r *SinkReconciler) ObserveSinkVPA(ctx context.Context, sink *v1alpha1.Sink) error { - return observeVPA(ctx, r, types.NamespacedName{Namespace: sink.Namespace, + resource, err := observeVPA(ctx, r, types.NamespacedName{Namespace: sink.Namespace, Name: spec.MakeSinkObjectMeta(sink).Name}, sink.Spec.Pod.VPA, sink.Status.Conditions) + if resource != nil { + originalResource := sink.Spec.Resources + // the resource may not have limits + if resource.Limits == nil { + resource.Limits = originalResource.Limits + } + sink.Spec.Resources = *resource + if err = r.Update(ctx, sink); err != nil { + return err + } + sink.Spec.Resources = originalResource + } + return err } func (r *SinkReconciler) ApplySinkVPA(ctx context.Context, sink *v1alpha1.Sink) error { diff --git a/controllers/sink_controller.go b/controllers/sink_controller.go index 52f831cbb..15bb8d82d 100644 --- a/controllers/sink_controller.go +++ b/controllers/sink_controller.go @@ -19,6 +19,7 @@ package controllers import ( "context" + "strings" "time" "github.com/streamnative/function-mesh/pkg/monitoring" @@ -99,6 +100,12 @@ func (r *SinkReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl. sink.Status.Conditions = make(map[v1alpha1.Component]v1alpha1.ResourceCondition) } + if r.GroupVersionFlags != nil && r.GroupVersionFlags.WatchVPACRDs { + err = r.ObserveSinkVPA(ctx, sink) + if err != nil { + return reconcile.Result{}, err + } + } err = r.ObserveSinkStatefulSet(ctx, sink) if err != nil { return reconcile.Result{}, err @@ -118,12 +125,6 @@ func (r *SinkReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl. return reconcile.Result{}, err } } - if r.GroupVersionFlags != nil && r.GroupVersionFlags.WatchVPACRDs { - err = r.ObserveSinkVPA(ctx, sink) - if err != nil { - return reconcile.Result{}, err - } - } err = r.Status().Update(ctx, sink) if err != nil { r.Log.Error(err, "failed to update sink status") @@ -227,5 +228,25 @@ func (r *SinkReconciler) SetupWithManager(mgr ctrl.Manager) error { }), ) + // Watch for vpa changes if sink has special resource unit + if r.GroupVersionFlags != nil && r.GroupVersionFlags.WatchVPACRDs { + manager.Watches(&vpav1.VerticalPodAutoscaler{}, handler.EnqueueRequestsFromMapFunc( + func(ctx context.Context, object client.Object) []reconcile.Request { + if object.GetLabels()[spec.LabelCustomResourceUnit] == "true" && + object.GetLabels()[spec.LabelComponent] == spec.ComponentSink { + return []reconcile.Request{ + { + NamespacedName: types.NamespacedName{ + Namespace: object.GetNamespace(), + Name: strings.TrimSuffix(object.GetName(), "-sink"), + }, + }, + } + } + return nil + }), + ) + } + return manager.Complete(r) } diff --git a/controllers/source.go b/controllers/source.go index 08685456e..f38f75622 100644 --- a/controllers/source.go +++ b/controllers/source.go @@ -323,8 +323,21 @@ func (r *SourceReconciler) ApplySourceHPAV2Beta2(ctx context.Context, source *v1 } func (r *SourceReconciler) ObserveSourceVPA(ctx context.Context, source *v1alpha1.Source) error { - return observeVPA(ctx, r, types.NamespacedName{Namespace: source.Namespace, + resource, err := observeVPA(ctx, r, types.NamespacedName{Namespace: source.Namespace, Name: spec.MakeSourceObjectMeta(source).Name}, source.Spec.Pod.VPA, source.Status.Conditions) + if resource != nil { + originalResource := source.Spec.Resources + // the resource may not have limits + if resource.Limits == nil { + resource.Limits = originalResource.Limits + } + source.Spec.Resources = *resource + if err = r.Update(ctx, source); err != nil { + return err + } + source.Spec.Resources = originalResource + } + return err } func (r *SourceReconciler) ApplySourceVPA(ctx context.Context, source *v1alpha1.Source) error { diff --git a/controllers/source_controller.go b/controllers/source_controller.go index 5b1a0b755..cfda4fe49 100644 --- a/controllers/source_controller.go +++ b/controllers/source_controller.go @@ -19,6 +19,7 @@ package controllers import ( "context" + "strings" "time" "github.com/go-logr/logr" @@ -99,6 +100,12 @@ func (r *SourceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr source.Status.Conditions = make(map[v1alpha1.Component]v1alpha1.ResourceCondition) } + if r.GroupVersionFlags != nil && r.GroupVersionFlags.WatchVPACRDs { + err = r.ObserveSourceVPA(ctx, source) + if err != nil { + return reconcile.Result{}, err + } + } err = r.ObserveSourceStatefulSet(ctx, source) if err != nil { return reconcile.Result{}, err @@ -118,12 +125,6 @@ func (r *SourceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr return reconcile.Result{}, err } } - if r.GroupVersionFlags != nil && r.GroupVersionFlags.WatchVPACRDs { - err = r.ObserveSourceVPA(ctx, source) - if err != nil { - return reconcile.Result{}, err - } - } err = r.Status().Update(ctx, source) if err != nil { r.Log.Error(err, "failed to update source status") @@ -223,5 +224,27 @@ func (r *SourceReconciler) SetupWithManager(mgr ctrl.Manager) error { } }), ) + + // Watch for vpa changes if source has special resource unit + if r.GroupVersionFlags != nil && r.GroupVersionFlags.WatchVPACRDs { + manager.Watches(&vpav1.VerticalPodAutoscaler{}, handler.EnqueueRequestsFromMapFunc( + func(ctx context.Context, object client.Object) []reconcile.Request { + if object.GetLabels()[spec.LabelCustomResourceUnit] == "true" && + object.GetLabels()[spec.LabelComponent] == spec.ComponentSource { + return []reconcile.Request{ + { + NamespacedName: types.NamespacedName{ + Namespace: object.GetNamespace(), + Name: strings.TrimSuffix(object.GetName(), "-source"), + }, + }, + } + + } + return nil + }), + ) + } + return manager.Complete(r) } diff --git a/controllers/spec/common.go b/controllers/spec/common.go index d4ea8c5dc..87ae2dd28 100644 --- a/controllers/spec/common.go +++ b/controllers/spec/common.go @@ -20,7 +20,6 @@ package spec import ( "bytes" "context" - // used for template _ "embed" "encoding/json" @@ -128,6 +127,15 @@ const ( DefaultFilebeatImage = "streamnative/filebeat:v0.6.0-rc7" EnvGoFunctionLogLevel = "LOGGING_LEVEL" + + LabelComponent = "compute.functionmesh.io/component" + LabelName = "compute.functionmesh.io/name" + LabelNamespace = "compute.functionmesh.io/namespace" + LabelCustomResourceUnit = "streamnative.io/custom-resource-unit" + + FunctionContainerName = "pulsar-function" + SinkContainerName = "pulsar-sink" + SourceContainerName = "pulsar-source" ) //go:embed template/java-runtime-log4j.xml.tmpl diff --git a/controllers/spec/function.go b/controllers/spec/function.go index 65bfded84..9837ef3f2 100644 --- a/controllers/spec/function.go +++ b/controllers/spec/function.go @@ -179,7 +179,7 @@ func makeFunctionContainer(function *v1alpha1.Function) *corev1.Container { } return &corev1.Container{ // TODO new container to pull user code image and upload jars into bookkeeper - Name: "pulsar-function", + Name: FunctionContainerName, Image: getFunctionRunnerImage(&function.Spec), Command: makeFunctionCommand(function), Ports: []corev1.ContainerPort{GRPCPort, MetricsPort}, @@ -202,12 +202,12 @@ func makeFunctionContainer(function *v1alpha1.Function) *corev1.Container { func makeFunctionLabels(function *v1alpha1.Function) map[string]string { jobName := makeJobName(function.Name, v1alpha1.FunctionComponent) labels := map[string]string{ - "app.kubernetes.io/name": jobName, - "app.kubernetes.io/instance": jobName, - "compute.functionmesh.io/app": AppFunctionMesh, - "compute.functionmesh.io/component": ComponentFunction, - "compute.functionmesh.io/name": function.Name, - "compute.functionmesh.io/namespace": function.Namespace, + "app.kubernetes.io/name": jobName, + "app.kubernetes.io/instance": jobName, + "compute.functionmesh.io/app": AppFunctionMesh, + LabelComponent: ComponentFunction, + LabelName: function.Name, + LabelNamespace: function.Namespace, // The following will be deprecated after two releases "app": AppFunctionMesh, "component": ComponentFunction, diff --git a/controllers/spec/sink.go b/controllers/spec/sink.go index 321f9ecd1..a77a1a034 100644 --- a/controllers/spec/sink.go +++ b/controllers/spec/sink.go @@ -107,7 +107,7 @@ func makeSinkContainer(sink *v1alpha1.Sink) *corev1.Container { } return &corev1.Container{ // TODO new container to pull user code image and upload jars into bookkeeper - Name: "pulsar-sink", + Name: SinkContainerName, Image: getSinkRunnerImage(&sink.Spec), Command: MakeSinkCommand(sink), Ports: []corev1.ContainerPort{GRPCPort, MetricsPort}, @@ -130,11 +130,11 @@ func makeSinkContainer(sink *v1alpha1.Sink) *corev1.Container { func makeSinkLabels(sink *v1alpha1.Sink) map[string]string { jobName := makeJobName(sink.Name, v1alpha1.SinkComponent) labels := map[string]string{ - "app.kubernetes.io/name": jobName, - "app.kubernetes.io/instance": jobName, - "compute.functionmesh.io/component": ComponentSink, - "compute.functionmesh.io/name": sink.Name, - "compute.functionmesh.io/namespace": sink.Namespace, + "app.kubernetes.io/name": jobName, + "app.kubernetes.io/instance": jobName, + LabelComponent: ComponentSink, + LabelName: sink.Name, + LabelNamespace: sink.Namespace, // The following will be deprecated after two releases "component": ComponentSink, "name": sink.Name, diff --git a/controllers/spec/source.go b/controllers/spec/source.go index d077cb2aa..75333ab91 100644 --- a/controllers/spec/source.go +++ b/controllers/spec/source.go @@ -103,7 +103,7 @@ func makeSourceContainer(source *v1alpha1.Source) *corev1.Container { } return &corev1.Container{ // TODO new container to pull user code image and upload jars into bookkeeper - Name: "pulsar-source", + Name: SourceContainerName, Image: getSourceRunnerImage(&source.Spec), Command: makeSourceCommand(source), Ports: []corev1.ContainerPort{GRPCPort, MetricsPort}, @@ -126,11 +126,11 @@ func makeSourceContainer(source *v1alpha1.Source) *corev1.Container { func makeSourceLabels(source *v1alpha1.Source) map[string]string { jobName := makeJobName(source.Name, v1alpha1.SourceComponent) labels := map[string]string{ - "app.kubernetes.io/name": jobName, - "app.kubernetes.io/instance": jobName, - "compute.functionmesh.io/component": ComponentSource, - "compute.functionmesh.io/name": source.Name, - "compute.functionmesh.io/namespace": source.Namespace, + "app.kubernetes.io/name": jobName, + "app.kubernetes.io/instance": jobName, + LabelComponent: ComponentSource, + LabelName: source.Name, + LabelNamespace: source.Namespace, // The following will be deprecated after two releases "component": ComponentSource, "name": source.Name, diff --git a/controllers/spec/vpa.go b/controllers/spec/vpa.go index b982c0475..51c79e5b5 100644 --- a/controllers/spec/vpa.go +++ b/controllers/spec/vpa.go @@ -27,6 +27,14 @@ import ( ) func MakeVPA(objectMeta *metav1.ObjectMeta, targetRef *autov2.CrossVersionObjectReference, vpa *v1alpha1.VPASpec) *vpav1.VerticalPodAutoscaler { + containerName := GetVPAContainerName(objectMeta) + updatePolicy := vpa.UpdatePolicy + UpdateVPAUpdatePolicy(updatePolicy, vpa.ResourceUnit) + if vpa.ResourceUnit != nil { + objectMeta.Labels[LabelCustomResourceUnit] = "true" + } + resourcePolicy := vpa.ResourcePolicy + UpdateResourcePolicy(resourcePolicy, containerName) return &vpav1.VerticalPodAutoscaler{ TypeMeta: metav1.TypeMeta{ @@ -40,8 +48,56 @@ func MakeVPA(objectMeta *metav1.ObjectMeta, targetRef *autov2.CrossVersionObject Name: targetRef.Name, APIVersion: targetRef.APIVersion, }, - UpdatePolicy: vpa.UpdatePolicy, - ResourcePolicy: vpa.ResourcePolicy, + UpdatePolicy: updatePolicy, + ResourcePolicy: resourcePolicy, }, } } + +func GetVPAContainerName(objectMeta *metav1.ObjectMeta) string { + containerName := "*" + label := objectMeta.GetLabels()[LabelComponent] + if label == ComponentFunction { + containerName = FunctionContainerName + } else if label == ComponentSink { + containerName = SinkContainerName + } else if label == ComponentSource { + containerName = SourceContainerName + } + return containerName +} + +func UpdateVPAUpdatePolicy(updatePolicy *vpav1.PodUpdatePolicy, resourceUnit *v1alpha1.ResourceUnit) { + if updatePolicy != nil && resourceUnit != nil { + off := vpav1.UpdateModeOff + updatePolicy.UpdateMode = &off + } +} + +func UpdateResourcePolicy(resourcePolicy *vpav1.PodResourcePolicy, containerName string) { + var containerPolicies []vpav1.ContainerResourcePolicy + containerScalingMode := vpav1.ContainerScalingModeAuto + if resourcePolicy != nil { + if resourcePolicy.ContainerPolicies == nil { + resourcePolicy.ContainerPolicies = []vpav1.ContainerResourcePolicy{} + } + for _, policy := range resourcePolicy.ContainerPolicies { + if policy.ContainerName == containerName { + policy.Mode = &containerScalingMode + containerPolicies = []vpav1.ContainerResourcePolicy{policy} + break + } + } + } + + // if resource policy is not set, set the default policy, so the vpa policy won't be applied to other containers + if len(containerPolicies) == 0 { + containerPolicies = []vpav1.ContainerResourcePolicy{ + { + ContainerName: containerName, + Mode: &containerScalingMode, + }, + } + } + resourcePolicy.ContainerPolicies = containerPolicies +} diff --git a/manifests/crd.yaml b/manifests/crd.yaml index a19fa60bd..2db01022f 100644 --- a/manifests/crd.yaml +++ b/manifests/crd.yaml @@ -3,7 +3,7 @@ kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) - controller-gen.kubebuilder.io/version: v0.9.2 + controller-gen.kubebuilder.io/version: v0.15.0 name: backendconfigs.compute.functionmesh.io spec: conversion: @@ -63,7 +63,7 @@ kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) - controller-gen.kubebuilder.io/version: v0.9.2 + controller-gen.kubebuilder.io/version: v0.15.0 name: functionmeshes.compute.functionmesh.io spec: conversion: @@ -556,6 +556,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -624,6 +634,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -690,6 +710,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -758,6 +788,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -1332,6 +1372,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1382,6 +1430,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -1578,8 +1634,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -1597,6 +1678,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -2014,6 +2097,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -2064,6 +2155,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -2260,8 +2359,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -2279,6 +2403,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -2724,11 +2850,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -2774,6 +2901,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -2962,6 +3091,43 @@ spec: sources: items: properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object configMap: properties: items: @@ -3242,6 +3408,21 @@ spec: type: object type: array type: object + resourceUnit: + properties: + cpu: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + memory: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object updatePolicy: properties: minReplicas: @@ -3408,6 +3589,18 @@ spec: type: integer resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -3528,11 +3721,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -3578,6 +3772,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -3589,6 +3785,11 @@ spec: items: type: string type: array + allocatedResourceStatuses: + additionalProperties: + type: string + type: object + x-kubernetes-map-type: granular allocatedResources: additionalProperties: anyOf: @@ -3627,9 +3828,18 @@ spec: - type type: object type: array - phase: + currentVolumeAttributesClassName: type: string - resizeStatus: + modifyVolumeStatus: + properties: + status: + type: string + targetVolumeAttributesClassName: + type: string + required: + - status + type: object + phase: type: string type: object type: object @@ -4064,6 +4274,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -4132,6 +4352,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -4198,6 +4428,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -4266,6 +4506,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -4840,6 +5090,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -4890,6 +5148,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -5086,8 +5352,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -5105,6 +5396,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -5522,6 +5815,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -5572,6 +5873,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -5768,8 +6077,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -5787,6 +6121,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -6232,11 +6568,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -6282,6 +6619,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -6470,6 +6809,43 @@ spec: sources: items: properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object configMap: properties: items: @@ -6750,6 +7126,21 @@ spec: type: object type: array type: object + resourceUnit: + properties: + cpu: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + memory: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object updatePolicy: properties: minReplicas: @@ -6916,6 +7307,18 @@ spec: type: integer resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -7382,11 +7785,21 @@ spec: type: object type: object x-kubernetes-map-type: atomic - namespaceSelector: - properties: - matchExpressions: - items: - properties: + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + namespaceSelector: + properties: + matchExpressions: + items: + properties: key: type: string operator: @@ -7450,6 +7863,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -7516,6 +7939,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -7584,6 +8017,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -8158,6 +8601,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -8208,6 +8659,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -8404,8 +8863,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -8423,6 +8907,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -8840,6 +9326,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -8890,6 +9384,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -9086,8 +9588,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -9105,6 +9632,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -9550,11 +10079,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -9600,6 +10130,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -9788,6 +10320,43 @@ spec: sources: items: properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object configMap: properties: items: @@ -10068,6 +10637,21 @@ spec: type: object type: array type: object + resourceUnit: + properties: + cpu: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + memory: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object updatePolicy: properties: minReplicas: @@ -10234,6 +10818,18 @@ spec: type: integer resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -10372,7 +10968,7 @@ kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) - controller-gen.kubebuilder.io/version: v0.9.2 + controller-gen.kubebuilder.io/version: v0.15.0 name: functions.compute.functionmesh.io spec: conversion: @@ -10862,6 +11458,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -10930,6 +11536,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -10996,6 +11612,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -11064,6 +11690,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -11638,6 +12274,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -11688,6 +12332,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -11884,8 +12536,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -11903,6 +12580,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -12320,6 +12999,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -12370,6 +13057,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -12566,8 +13261,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -12585,6 +13305,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -13030,11 +13752,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -13080,6 +13803,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -13268,6 +13993,43 @@ spec: sources: items: properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object configMap: properties: items: @@ -13548,6 +14310,21 @@ spec: type: object type: array type: object + resourceUnit: + properties: + cpu: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + memory: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object updatePolicy: properties: minReplicas: @@ -13714,10 +14491,22 @@ spec: type: integer resources: properties: - limits: - additionalProperties: - anyOf: - - type: integer + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer - type: string pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true @@ -13834,11 +14623,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -13884,6 +14674,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -13895,6 +14687,11 @@ spec: items: type: string type: array + allocatedResourceStatuses: + additionalProperties: + type: string + type: object + x-kubernetes-map-type: granular allocatedResources: additionalProperties: anyOf: @@ -13933,9 +14730,18 @@ spec: - type type: object type: array - phase: + currentVolumeAttributesClassName: type: string - resizeStatus: + modifyVolumeStatus: + properties: + status: + type: string + targetVolumeAttributesClassName: + type: string + required: + - status + type: object + phase: type: string type: object type: object @@ -14036,7 +14842,7 @@ kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) - controller-gen.kubebuilder.io/version: v0.9.2 + controller-gen.kubebuilder.io/version: v0.15.0 name: sinks.compute.functionmesh.io spec: conversion: @@ -14447,6 +15253,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -14515,6 +15331,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -14581,6 +15407,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -14649,6 +15485,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -15223,6 +16069,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -15273,6 +16127,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -15469,8 +16331,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -15488,6 +16375,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -15905,6 +16794,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -15955,6 +16852,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -16151,8 +17056,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -16170,6 +17100,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -16615,11 +17547,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -16665,6 +17598,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -16853,6 +17788,43 @@ spec: sources: items: properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object configMap: properties: items: @@ -17133,6 +18105,21 @@ spec: type: object type: array type: object + resourceUnit: + properties: + cpu: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + memory: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object updatePolicy: properties: minReplicas: @@ -17299,6 +18286,18 @@ spec: type: integer resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -17436,7 +18435,7 @@ kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) - controller-gen.kubebuilder.io/version: v0.9.2 + controller-gen.kubebuilder.io/version: v0.15.0 name: sources.compute.functionmesh.io spec: conversion: @@ -17842,6 +18841,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -17910,6 +18919,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -17976,6 +18995,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -18044,6 +19073,16 @@ spec: type: object type: object x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + mismatchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic namespaceSelector: properties: matchExpressions: @@ -18618,6 +19657,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -18668,6 +19715,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -18864,8 +19919,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -18883,6 +19963,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -19300,6 +20382,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -19350,6 +20440,14 @@ spec: required: - port type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object tcpSocket: properties: host: @@ -19546,8 +20644,33 @@ spec: format: int32 type: integer type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -19565,6 +20688,8 @@ spec: x-kubernetes-int-or-string: true type: object type: object + restartPolicy: + type: string securityContext: properties: allowPrivilegeEscalation: @@ -20010,11 +21135,12 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: limits: @@ -20060,6 +21186,8 @@ spec: x-kubernetes-map-type: atomic storageClassName: type: string + volumeAttributesClassName: + type: string volumeMode: type: string volumeName: @@ -20248,6 +21376,43 @@ spec: sources: items: properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object configMap: properties: items: @@ -20528,6 +21693,21 @@ spec: type: object type: array type: object + resourceUnit: + properties: + cpu: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + memory: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object updatePolicy: properties: minReplicas: @@ -20694,6 +21874,18 @@ spec: type: integer resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: From 9b5c5231549a3dcdc6db2e6136d9ff4459b186c5 Mon Sep 17 00:00:00 2001 From: jiangpengcheng Date: Mon, 6 May 2024 10:15:36 +0800 Subject: [PATCH 2/5] Add integration tests --- .ci/helm.sh | 56 ++++- .../cases/mongodb-source/manifests.yaml | 2 +- .../cases/mongodb-source/mongodb-dbz.yaml | 4 +- .../cases/mongodb-source/verify.sh | 2 +- .../manifests.yaml | 57 +++++ .../vpa-with-resource-unit-sink/verify.sh | 50 +++++ .../manifests.yaml | 60 ++++++ .../vpa-with-resource-unit-source/verify.sh | 50 +++++ .../vpa-with-resource-unit/manifests.yaml | 92 ++++++++ .../cases/vpa-with-resource-unit/verify.sh | 50 +++++ .ci/tests/integration/e2e_with_tls.yaml | 24 ++- api/compute/v1alpha1/common.go | 2 +- api/compute/v1alpha1/zz_generated.deepcopy.go | 3 +- controllers/common.go | 39 ++-- controllers/common_test.go | 59 ++--- controllers/function_controller_test.go | 4 +- controllers/spec/common.go | 1 + controllers/spec/vpa.go | 28 ++- controllers/spec/vpa_test.go | 201 +++++++++++++++++- 19 files changed, 707 insertions(+), 77 deletions(-) create mode 100644 .ci/tests/integration/cases/vpa-with-resource-unit-sink/manifests.yaml create mode 100644 .ci/tests/integration/cases/vpa-with-resource-unit-sink/verify.sh create mode 100644 .ci/tests/integration/cases/vpa-with-resource-unit-source/manifests.yaml create mode 100644 .ci/tests/integration/cases/vpa-with-resource-unit-source/verify.sh create mode 100644 .ci/tests/integration/cases/vpa-with-resource-unit/manifests.yaml create mode 100644 .ci/tests/integration/cases/vpa-with-resource-unit/verify.sh diff --git a/.ci/helm.sh b/.ci/helm.sh index 56dde3d3d..3dce7655c 100644 --- a/.ci/helm.sh +++ b/.ci/helm.sh @@ -239,7 +239,7 @@ function ci::verify_download_java_function_generic_auth() { } function ci::verify_vpa_java_function() { - kubectl wait -l name=function-sample-vpa-function --for=condition=RecommendationProvided --timeout=2m vpa && true + kubectl wait -l name=function-sample-vpa --for=condition=RecommendationProvided --timeout=2m vpa cpu=`kubectl get vpa function-sample-vpa-function -o jsonpath='{.status.recommendation.containerRecommendations[0].target.cpu}'` memory=`kubectl get vpa function-sample-vpa-function -o jsonpath='{.status.recommendation.containerRecommendations[0].target.memory}'` resources='{"limits":{"cpu":"'$cpu'","memory":"'$memory'"},"requests":{"cpu":"'$cpu'","memory":"'$memory'"}}' @@ -269,6 +269,39 @@ function ci::verify_vpa_java_function() { ci::verify_exclamation_function "persistent://public/default/input-vpa-java-topic" "persistent://public/default/output-vpa-java-topic" "test-message" "test-message!" 10 } +function ci::verify_vpa_with_resource_unit() { + name=$1 + kind=$2 + baseCpu=200 # cpu value of the resource unit + baseMemory=`echo $((800*1024*1024))` # memory value of the resource unit + vpaName="$1-$2" + kubectl wait -l name=$name --for=condition=RecommendationProvided --timeout=2m vpa + cpu=`kubectl get vpa $vpaName -o jsonpath='{.status.recommendation.containerRecommendations[0].target.cpu}'` + cpu_value=${cpu%m} + + quotient=$(($cpu_value / $baseCpu)) + remainder=$(($cpu_value % $baseCpu)) + + # If there's any remainder, we need to round up + if [ $remainder -ne 0 ]; then + multiple=$(($quotient + 1)) + else + multiple=$quotient + fi + targetCpu=`echo $(($baseCpu* $multiple ))m` + targetMemory=`echo $(($baseMemory * $multiple ))` + + resources='{"limits":{"cpu":"'$targetCpu'","memory":"'$targetMemory'"},"requests":{"cpu":"'$targetCpu'","memory":"'$targetMemory'"}}' + + realResource=`kubectl get $kind $name -o jsonpath='{.spec.resources}'` + if [[ "$resources" != "$realResource" ]]; then + echo "vpa tests failed for $kind" + echo "recommend resource is: ${resources}, actual resource is ${realResource}" + exit 1 + fi + echo "vpa tests passed" +} + function ci::verify_python_function() { ci::verify_exclamation_function "persistent://public/default/input-python-topic" "persistent://public/default/output-python-topic" "test-message" "test-message!" 10 } @@ -349,7 +382,8 @@ function ci::verify_exclamation_function() { timesleep=$5 kubectl exec -n ${NAMESPACE} ${CLUSTER}-pulsar-broker-0 -- bin/pulsar-client produce -m "${inputmessage}" -n 1 "${inputtopic}" sleep "$timesleep" - MESSAGE=$(kubectl exec -n ${NAMESPACE} ${CLUSTER}-pulsar-broker-0 -- bin/pulsar-client consume -n 1 -s "sub" --subscription-position Earliest "${outputtopic}") + sub=`cat /dev/urandom | tr -dc 'a-z' | head -c 8` + MESSAGE=$(kubectl exec -n ${NAMESPACE} ${CLUSTER}-pulsar-broker-0 -- bin/pulsar-client consume -n 1 -s "${sub}" --subscription-position Earliest "${outputtopic}") echo "$MESSAGE" if [[ "$MESSAGE" == *"$outputmessage"* ]]; then return 0 @@ -366,7 +400,8 @@ function ci::verify_exclamation_function_with_auth() { command="kubectl exec -n ${NAMESPACE} ${CLUSTER}-pulsar-broker-0 -- sh -c 'bin/pulsar-client --auth-plugin \$brokerClientAuthenticationPlugin --auth-params \$brokerClientAuthenticationParameters produce -m \"${inputmessage}\" -n 1 \"${inputtopic}\"'" sh -c "$command" sleep "$timesleep" - consumeCommand="kubectl exec -n ${NAMESPACE} ${CLUSTER}-pulsar-broker-0 -- sh -c 'bin/pulsar-client --auth-plugin \$brokerClientAuthenticationPlugin --auth-params \$brokerClientAuthenticationParameters consume -n 1 -s "sub" --subscription-position Earliest \"${outputtopic}\"'" + sub=`cat /dev/urandom | tr -dc 'a-z' | head -c 8` + consumeCommand="kubectl exec -n ${NAMESPACE} ${CLUSTER}-pulsar-broker-0 -- sh -c 'bin/pulsar-client --auth-plugin \$brokerClientAuthenticationPlugin --auth-params \$brokerClientAuthenticationParameters consume -n 1 -s \"${sub}\" --subscription-position Earliest \"${outputtopic}\"'" MESSAGE=$(sh -c "$consumeCommand") echo "$MESSAGE" if [[ "$MESSAGE" == *"$outputmessage"* ]]; then @@ -383,7 +418,8 @@ function ci::verify_wordcount_function() { timesleep=$5 kubectl exec -n ${NAMESPACE} ${CLUSTER}-pulsar-broker-0 -- bin/pulsar-client produce -m "${inputmessage}" -n 1 "${inputtopic}" sleep "$timesleep" - MESSAGE=$(kubectl exec -n ${NAMESPACE} ${CLUSTER}-pulsar-broker-0 -- bin/pulsar-client consume -n 3 -s "sub" --subscription-position Earliest "${outputtopic}") + sub=`cat /dev/urandom | tr -dc 'a-z' | head -c 8` + MESSAGE=$(kubectl exec -n ${NAMESPACE} ${CLUSTER}-pulsar-broker-0 -- bin/pulsar-client consume -n 3 -s "${sub}" --subscription-position Earliest "${outputtopic}") echo "$MESSAGE" if [[ "$MESSAGE" == *"$outputmessage"* ]]; then return 0 @@ -453,12 +489,13 @@ function ci::verify_elasticsearch_sink() { function ci::verify_mongodb_source() { timesleep=$1 - kubectl exec mongo-dbz-0 -c mongo -- mongo -u debezium -p dbz --authenticationDatabase admin localhost:27017/inventory --eval 'db.products.update({"_id":NumberLong(104)},{$set:{weight:1.25}})' + kubectl exec mongo-dbz-0 -c mongo -- mongosh -u debezium -p dbz --authenticationDatabase admin localhost:27017/inventory --eval 'db.products.update({"_id":NumberLong(104)},{$set:{weight:1.25}})' sleep "$timesleep" kubectl logs --tail=-1 -l compute.functionmesh.io/name=source-sample | grep "records sent" if [ $? -eq 0 ]; then return 0 fi + kubectl logs --tail=-1 -l compute.functionmesh.io/name=source-sample return 1 } @@ -484,7 +521,8 @@ function ci::verify_function_with_encryption() { kubectl exec -n ${NAMESPACE} ${CLUSTER}-pulsar-broker-0 -- bin/pulsar-client produce -ekn "myapp1" -ekv "data:application/x-pem-file;base64,${correct_pubkey}" -m "${inputmessage}" -n 1 "${inputtopic}" sleep "$timesleep" - MESSAGE=$(kubectl exec -n ${NAMESPACE} ${CLUSTER}-pulsar-broker-0 -- bin/pulsar-client consume -n 1 -s "sub" --subscription-position Earliest "${outputtopic}") + sub=`cat /dev/urandom | tr -dc 'a-z' | head -c 8` + MESSAGE=$(kubectl exec -n ${NAMESPACE} ${CLUSTER}-pulsar-broker-0 -- bin/pulsar-client consume -n 1 -s "${sub}" --subscription-position Earliest "${outputtopic}") echo "$MESSAGE" if [[ "$MESSAGE" == *"$outputmessage"* ]]; then return 0 @@ -573,7 +611,8 @@ function ci::verify_log_topic() { timesleep=$3 sleep "$timesleep" - MESSAGE=$(kubectl exec -n ${NAMESPACE} ${CLUSTER}-pulsar-broker-0 -- bin/pulsar-client consume -n 1 -s "sub" --subscription-position Earliest "${logTopic}") + sub=`cat /dev/urandom | tr -dc 'a-z' | head -c 8` + MESSAGE=$(kubectl exec -n ${NAMESPACE} ${CLUSTER}-pulsar-broker-0 -- bin/pulsar-client consume -n 1 -s "${sub}" --subscription-position Earliest "${logTopic}") echo "$MESSAGE" if [[ "$MESSAGE" == *"$message"* ]]; then return 0 @@ -588,7 +627,8 @@ function ci::verify_log_topic_with_auth() { timesleep=$3 sleep "$timesleep" - consumeCommand="kubectl exec -n ${NAMESPACE} ${CLUSTER}-pulsar-broker-0 -- sh -c 'bin/pulsar-client --auth-plugin \$brokerClientAuthenticationPlugin --auth-params \$brokerClientAuthenticationParameters consume -n 1 -s "sub" --subscription-position Earliest \"${logTopic}\"'" + sub=`cat /dev/urandom | tr -dc 'a-z' | head -c 8` + consumeCommand="kubectl exec -n ${NAMESPACE} ${CLUSTER}-pulsar-broker-0 -- sh -c 'bin/pulsar-client --auth-plugin \$brokerClientAuthenticationPlugin --auth-params \$brokerClientAuthenticationParameters consume -n 1 -s \"${sub}\" --subscription-position Earliest \"${logTopic}\"'" MESSAGE=$(sh -c "$consumeCommand") echo "$MESSAGE" if [[ "$MESSAGE" == *"$message"* ]]; then diff --git a/.ci/tests/integration/cases/mongodb-source/manifests.yaml b/.ci/tests/integration/cases/mongodb-source/manifests.yaml index 954b936ca..188a1d1f2 100644 --- a/.ci/tests/integration/cases/mongodb-source/manifests.yaml +++ b/.ci/tests/integration/cases/mongodb-source/manifests.yaml @@ -23,7 +23,7 @@ spec: cpu: "0.1" memory: 1G sourceConfig: - mongodb.hosts: rs0/mongo-dbz-0.mongo.default.svc.cluster.local:27017,rs0/mongo-dbz-1.mongo.default.svc.cluster.local:27017,rs0/mongo-dbz-2.mongo.default.svc.cluster.local:27017 + mongodb.hosts: rs0/mongo-dbz-0.mongo.default.svc.cluster.local:27017 mongodb.name: dbserver1 mongodb.user: debezium mongodb.password: dbz diff --git a/.ci/tests/integration/cases/mongodb-source/mongodb-dbz.yaml b/.ci/tests/integration/cases/mongodb-source/mongodb-dbz.yaml index 60c64d6e4..7c1f32384 100644 --- a/.ci/tests/integration/cases/mongodb-source/mongodb-dbz.yaml +++ b/.ci/tests/integration/cases/mongodb-source/mongodb-dbz.yaml @@ -35,7 +35,7 @@ spec: matchLabels: role: mongo serviceName: "mongo" - replicas: 3 + replicas: 1 template: metadata: labels: @@ -44,7 +44,7 @@ spec: terminationGracePeriodSeconds: 10 containers: - name: mongo - image: debezium/example-mongodb:0.10 + image: debezium/example-mongodb:2.6 env: - name: MONGODB_USER value: "debezium" diff --git a/.ci/tests/integration/cases/mongodb-source/verify.sh b/.ci/tests/integration/cases/mongodb-source/verify.sh index 2d9c0b382..6065d8029 100644 --- a/.ci/tests/integration/cases/mongodb-source/verify.sh +++ b/.ci/tests/integration/cases/mongodb-source/verify.sh @@ -45,7 +45,7 @@ function install_mongodb_server() { # install mongodb server kubectl apply -f "${mongodb_file}" num=0 - while [[ ${num} -lt 3 ]]; do + while [[ ${num} -lt 1 ]]; do sleep 5 kubectl get pods num=$(kubectl get pods -l role=mongo | wc -l) diff --git a/.ci/tests/integration/cases/vpa-with-resource-unit-sink/manifests.yaml b/.ci/tests/integration/cases/vpa-with-resource-unit-sink/manifests.yaml new file mode 100644 index 000000000..23fb53988 --- /dev/null +++ b/.ci/tests/integration/cases/vpa-with-resource-unit-sink/manifests.yaml @@ -0,0 +1,57 @@ +apiVersion: compute.functionmesh.io/v1alpha1 +kind: Sink +metadata: + name: vpa-sink-sample +spec: + className: org.apache.pulsar.io.datagenerator.DataGeneratorPrintSink + replicas: 1 + sinkConfig: + test: test + input: + topics: + - persistent://public/default/input-vpa-sink-topic + typeClassName: org.apache.pulsar.io.datagenerator.Person + forwardSourceMessageProperty: true + resources: + limits: + cpu: "0.2" + memory: 1.1G + requests: + cpu: "0.1" + memory: 1G + pod: + vpa: + resourceUnit: + cpu: 200m + memory: 800Mi + updatePolicy: + updateMode: "Auto" + resourcePolicy: + containerPolicies: + - containerName: "*" + minAllowed: + cpu: 200m + memory: 100Mi + maxAllowed: + cpu: 1 + memory: 1000Mi + pulsar: + pulsarConfig: "test-sink" + tlsConfig: + enabled: false + allowInsecure: false + hostnameVerification: true + certSecretName: sn-platform-tls-broker + certSecretKey: "" + image: streamnative/pulsar-io-data-generator:3.2.2.1 + java: + jar: connectors/pulsar-io-data-generator-3.2.2.1.nar + clusterName: test-pulsar +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: test-sink +data: + webServiceURL: http://sn-platform-pulsar-broker.default.svc.cluster.local:8080 + brokerServiceURL: pulsar://sn-platform-pulsar-broker.default.svc.cluster.local:6650 diff --git a/.ci/tests/integration/cases/vpa-with-resource-unit-sink/verify.sh b/.ci/tests/integration/cases/vpa-with-resource-unit-sink/verify.sh new file mode 100644 index 000000000..ddc6bd7d6 --- /dev/null +++ b/.ci/tests/integration/cases/vpa-with-resource-unit-sink/verify.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +set -e + +E2E_DIR=$(dirname "$0") +BASE_DIR=$(cd "${E2E_DIR}"/../../../../..;pwd) +PULSAR_NAMESPACE=${PULSAR_NAMESPACE:-"default"} +PULSAR_RELEASE_NAME=${PULSAR_RELEASE_NAME:-"sn-platform"} +E2E_KUBECONFIG=${E2E_KUBECONFIG:-"/tmp/e2e-k8s.config"} + +source "${BASE_DIR}"/.ci/helm.sh + +if [ ! "$KUBECONFIG" ]; then + export KUBECONFIG=${E2E_KUBECONFIG} +fi + +kubectl apply -f "${BASE_DIR}"/.ci/tests/integration/cases/vpa-with-resource-unit-sink/manifests.yaml > /dev/null 2>&1 + +verify_fm_result=$(ci::verify_function_mesh vpa-sink-sample 2>&1) +if [ $? -ne 0 ]; then + echo "$verify_fm_result" + kubectl delete -f "${BASE_DIR}"/.ci/tests/integration/cases/vpa-with-resource-unit-sink/manifests.yaml > /dev/null 2>&1 || true + exit 1 +fi + +verify_java_result=$(NAMESPACE=${PULSAR_NAMESPACE} CLUSTER=${PULSAR_RELEASE_NAME} ci::verify_vpa_with_resource_unit vpa-sink-sample sink 2>&1) +if [ $? -eq 0 ]; then + echo "e2e-test: ok" | yq eval - +else + echo "$verify_java_result" +fi +kubectl delete -f "${BASE_DIR}"/.ci/tests/integration/cases/vpa-with-resource-unit-sink/manifests.yaml > /dev/null 2>&1 || true diff --git a/.ci/tests/integration/cases/vpa-with-resource-unit-source/manifests.yaml b/.ci/tests/integration/cases/vpa-with-resource-unit-source/manifests.yaml new file mode 100644 index 000000000..4c17df6bf --- /dev/null +++ b/.ci/tests/integration/cases/vpa-with-resource-unit-source/manifests.yaml @@ -0,0 +1,60 @@ +apiVersion: compute.functionmesh.io/v1alpha1 +kind: Source +metadata: + name: vpa-source-sample +spec: + className: org.apache.pulsar.io.datagenerator.DataGeneratorSource + replicas: 1 + output: + producerConf: + maxPendingMessages: 1000 + maxPendingMessagesAcrossPartitions: 50000 + useThreadLocalProducers: true + topic: persistent://public/default/output-vpa-source-topic + typeClassName: org.apache.pulsar.io.datagenerator.Person + forwardSourceMessageProperty: true + sourceConfig: + test: test + resources: + limits: + cpu: "0.2" + memory: 1.1G + requests: + cpu: "0.1" + memory: 1G + pod: + vpa: + resourceUnit: + cpu: 200m + memory: 800Mi + updatePolicy: + updateMode: "Auto" + resourcePolicy: + containerPolicies: + - containerName: "*" + minAllowed: + cpu: 200m + memory: 100Mi + maxAllowed: + cpu: 1 + memory: 1000Mi + pulsar: + pulsarConfig: "test-source" + tlsConfig: + enabled: false + allowInsecure: false + hostnameVerification: true + certSecretName: sn-platform-tls-broker + certSecretKey: "" + image: streamnative/pulsar-io-data-generator:3.2.2.1 + java: + jar: connectors/pulsar-io-data-generator-3.2.2.1.nar + clusterName: test-pulsar +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: test-source +data: + webServiceURL: http://sn-platform-pulsar-broker.default.svc.cluster.local:8080 + brokerServiceURL: pulsar://sn-platform-pulsar-broker.default.svc.cluster.local:6650 diff --git a/.ci/tests/integration/cases/vpa-with-resource-unit-source/verify.sh b/.ci/tests/integration/cases/vpa-with-resource-unit-source/verify.sh new file mode 100644 index 000000000..ff2561da7 --- /dev/null +++ b/.ci/tests/integration/cases/vpa-with-resource-unit-source/verify.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +set -e + +E2E_DIR=$(dirname "$0") +BASE_DIR=$(cd "${E2E_DIR}"/../../../../..;pwd) +PULSAR_NAMESPACE=${PULSAR_NAMESPACE:-"default"} +PULSAR_RELEASE_NAME=${PULSAR_RELEASE_NAME:-"sn-platform"} +E2E_KUBECONFIG=${E2E_KUBECONFIG:-"/tmp/e2e-k8s.config"} + +source "${BASE_DIR}"/.ci/helm.sh + +if [ ! "$KUBECONFIG" ]; then + export KUBECONFIG=${E2E_KUBECONFIG} +fi + +kubectl apply -f "${BASE_DIR}"/.ci/tests/integration/cases/vpa-with-resource-unit-source/manifests.yaml > /dev/null 2>&1 + +verify_fm_result=$(ci::verify_function_mesh vpa-source-sample 2>&1) +if [ $? -ne 0 ]; then + echo "$verify_fm_result" + kubectl delete -f "${BASE_DIR}"/.ci/tests/integration/cases/vpa-with-resource-unit-source/manifests.yaml > /dev/null 2>&1 || true + exit 1 +fi + +verify_java_result=$(NAMESPACE=${PULSAR_NAMESPACE} CLUSTER=${PULSAR_RELEASE_NAME} ci::verify_vpa_with_resource_unit vpa-source-sample source 2>&1) +if [ $? -eq 0 ]; then + echo "e2e-test: ok" | yq eval - +else + echo "$verify_java_result" +fi +kubectl delete -f "${BASE_DIR}"/.ci/tests/integration/cases/vpa-with-resource-unit-source/manifests.yaml > /dev/null 2>&1 || true diff --git a/.ci/tests/integration/cases/vpa-with-resource-unit/manifests.yaml b/.ci/tests/integration/cases/vpa-with-resource-unit/manifests.yaml new file mode 100644 index 000000000..1bea27f3a --- /dev/null +++ b/.ci/tests/integration/cases/vpa-with-resource-unit/manifests.yaml @@ -0,0 +1,92 @@ +apiVersion: compute.functionmesh.io/v1alpha1 +kind: Function +metadata: + name: vpa-with-resource-unit + namespace: default +spec: + image: streamnative/pulsar-functions-java-sample:3.2.2.1 + className: org.apache.pulsar.functions.api.examples.ExclamationFunction + forwardSourceMessageProperty: true + maxPendingAsyncRequests: 1000 + replicas: 2 + pod: + vpa: + resourceUnit: + cpu: 200m + memory: 800Mi + updatePolicy: + updateMode: "Auto" + resourcePolicy: + containerPolicies: + - containerName: "*" + minAllowed: + cpu: 200m + memory: 100Mi + maxAllowed: + cpu: 1 + memory: 1000Mi + input: + topics: + - persistent://public/default/input-vpa-java-topic + typeClassName: java.lang.String + output: + topic: persistent://public/default/output-vpa-java-topic + typeClassName: java.lang.String + resources: + requests: + cpu: 200m + memory: 1G + limits: + cpu: 200m + memory: 1G + # each secret will be loaded ad an env variable from the `path` secret with the `key` in that secret in the name of `name` + secretsMap: + "name": + path: "test-secret" + key: "username" + "pwd": + path: "test-secret" + key: "password" + pulsar: + pulsarConfig: "test-pulsar" + tlsConfig: + enabled: false + allowInsecure: false + hostnameVerification: true + certSecretName: sn-platform-tls-broker + certSecretKey: "" + #authConfig: "test-auth" + java: + jar: /pulsar/examples/api-examples.jar + # to be delete & use admission hook + clusterName: test + autoAck: true +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: test-pulsar +data: + webServiceURL: http://sn-platform-pulsar-broker.default.svc.cluster.local:8080 + brokerServiceURL: pulsar://sn-platform-pulsar-broker.default.svc.cluster.local:6650 +#--- +#apiVersion: v1 +#kind: ConfigMap +#metadata: +# name: test-auth +#data: +# clientAuthenticationPlugin: "abc" +# clientAuthenticationParameters: "xyz" +# tlsTrustCertsFilePath: "uvw" +# useTls: "true" +# tlsAllowInsecureConnection: "false" +# tlsHostnameVerificationEnable: "true" +--- +apiVersion: v1 +data: + username: YWRtaW4= + password: MWYyZDFlMmU2N2Rm +kind: Secret +metadata: + name: test-secret +type: Opaque diff --git a/.ci/tests/integration/cases/vpa-with-resource-unit/verify.sh b/.ci/tests/integration/cases/vpa-with-resource-unit/verify.sh new file mode 100644 index 000000000..fbf068893 --- /dev/null +++ b/.ci/tests/integration/cases/vpa-with-resource-unit/verify.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +set -e + +E2E_DIR=$(dirname "$0") +BASE_DIR=$(cd "${E2E_DIR}"/../../../../..;pwd) +PULSAR_NAMESPACE=${PULSAR_NAMESPACE:-"default"} +PULSAR_RELEASE_NAME=${PULSAR_RELEASE_NAME:-"sn-platform"} +E2E_KUBECONFIG=${E2E_KUBECONFIG:-"/tmp/e2e-k8s.config"} + +source "${BASE_DIR}"/.ci/helm.sh + +if [ ! "$KUBECONFIG" ]; then + export KUBECONFIG=${E2E_KUBECONFIG} +fi + +kubectl apply -f "${BASE_DIR}"/.ci/tests/integration/cases/vpa-with-resource-unit/manifests.yaml > /dev/null 2>&1 + +verify_fm_result=$(ci::verify_function_mesh vpa-with-resource-unit 2>&1) +if [ $? -ne 0 ]; then + echo "$verify_fm_result" + kubectl delete -f "${BASE_DIR}"/.ci/tests/integration/cases/vpa-with-resource-unit/manifests.yaml > /dev/null 2>&1 || true + exit 1 +fi + +verify_java_result=$(NAMESPACE=${PULSAR_NAMESPACE} CLUSTER=${PULSAR_RELEASE_NAME} ci::verify_vpa_with_resource_unit vpa-with-resource-unit function 2>&1) +if [ $? -eq 0 ]; then + echo "e2e-test: ok" | yq eval - +else + echo "$verify_java_result" +fi +kubectl delete -f "${BASE_DIR}"/.ci/tests/integration/cases/vpa-with-resource-unit/manifests.yaml > /dev/null 2>&1 || true diff --git a/.ci/tests/integration/e2e_with_tls.yaml b/.ci/tests/integration/e2e_with_tls.yaml index e1844caf3..88a90971a 100644 --- a/.ci/tests/integration/e2e_with_tls.yaml +++ b/.ci/tests/integration/e2e_with_tls.yaml @@ -24,6 +24,17 @@ setup: label-selector: app=cert-manager for: condition=Ready + - name: setup vpa + command: | + helm repo add cowboysysop https://cowboysysop.github.io/charts/ + helm repo update + helm install vpa cowboysysop/vertical-pod-autoscaler + wait: + - namespace: default + resource: pod + label-selector: app.kubernetes.io/name=vertical-pod-autoscaler + for: condition=Ready + - name: install pulsar cluster command: | helm repo add streamnative https://charts.streamnative.io @@ -37,6 +48,11 @@ setup: helm dependency update charts/pulsar helm install ${PULSAR_RELEASE_NAME} --set initialize=true --values ../.ci/clusters/values_skywalking_e2e_cluster_with_tls.yaml charts/pulsar + - name: install metrics service + command: | + kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml + kubectl patch -n kube-system deployment metrics-server --type=json -p '[{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--kubelet-insecure-tls"}]' + - name: wait for pulsar cluster ready command: | echo "wait until pulsar init job is completed" @@ -129,5 +145,11 @@ verify: expected: expected.data.yaml - query: bash .ci/tests/integration/cases/crypto-function/verify.sh expected: expected.data.yaml - - query: timeout 5m bash .ci/tests/integration/cases/global-and-namespaced-config/verify.sh + - query: bash .ci/tests/integration/cases/global-and-namespaced-config/verify.sh + expected: expected.data.yaml + - query: bash .ci/tests/integration/cases/vpa-with-resource-unit/verify.sh + expected: expected.data.yaml + - query: bash .ci/tests/integration/cases/vpa-with-resource-unit-sink/verify.sh + expected: expected.data.yaml + - query: bash .ci/tests/integration/cases/vpa-with-resource-unit-source/verify.sh expected: expected.data.yaml diff --git a/api/compute/v1alpha1/common.go b/api/compute/v1alpha1/common.go index 8de9d7504..49183b265 100644 --- a/api/compute/v1alpha1/common.go +++ b/api/compute/v1alpha1/common.go @@ -568,7 +568,7 @@ type VPASpec struct { type ResourceUnit struct { // The CPU request for the pod - Cpu resource.Quantity `json:"cpu,omitempty"` + CPU resource.Quantity `json:"cpu,omitempty"` // The memory request for the pod Memory resource.Quantity `json:"memory,omitempty"` diff --git a/api/compute/v1alpha1/zz_generated.deepcopy.go b/api/compute/v1alpha1/zz_generated.deepcopy.go index e9a59184c..f2757baaf 100644 --- a/api/compute/v1alpha1/zz_generated.deepcopy.go +++ b/api/compute/v1alpha1/zz_generated.deepcopy.go @@ -1,5 +1,4 @@ //go:build !ignore_autogenerated -// +build !ignore_autogenerated // Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file @@ -1038,7 +1037,7 @@ func (in *ResourceCondition) DeepCopy() *ResourceCondition { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceUnit) DeepCopyInto(out *ResourceUnit) { *out = *in - out.Cpu = in.Cpu.DeepCopy() + out.CPU = in.CPU.DeepCopy() out.Memory = in.Memory.DeepCopy() } diff --git a/controllers/common.go b/controllers/common.go index 09f271464..3a80311d3 100644 --- a/controllers/common.go +++ b/controllers/common.go @@ -117,11 +117,9 @@ func observeVPA(ctx context.Context, r client.Reader, name types.NamespacedName, } // compare exists VPA with new Spec - updatePolicy := vpaSpec.UpdatePolicy - spec.UpdateVPAUpdatePolicy(updatePolicy, vpaSpec.ResourceUnit) - resourcePolicy := vpaSpec.ResourcePolicy + updatePolicy := spec.UpdateVPAUpdatePolicy(vpaSpec.UpdatePolicy, vpaSpec.ResourceUnit) containerName := spec.GetVPAContainerName(&vpa.ObjectMeta) - spec.UpdateResourcePolicy(resourcePolicy, containerName) + resourcePolicy := spec.UpdateResourcePolicy(vpaSpec.ResourcePolicy, containerName) if !reflect.DeepEqual(updatePolicy, vpa.Spec.UpdatePolicy) || !reflect.DeepEqual(resourcePolicy, vpa.Spec.ResourcePolicy) { condition.Status = metav1.ConditionFalse @@ -141,21 +139,24 @@ func observeVPA(ctx context.Context, r client.Reader, name types.NamespacedName, func calculateVPARecommendation(vpa *vpav1.VerticalPodAutoscaler, vpaSpec *v1alpha1.VPASpec) *corev1.ResourceRequirements { var multiple int64 = 0 - if vpaSpec.ResourceUnit == nil || vpaSpec.ResourceUnit.Cpu.MilliValue() == 0 && vpaSpec.ResourceUnit.Memory.MilliValue() == 0 { + if vpaSpec.ResourceUnit == nil || vpaSpec.ResourceUnit.CPU.MilliValue() == 0 && vpaSpec.ResourceUnit.Memory.MilliValue() == 0 { return nil } + containerName := spec.GetVPAContainerName(&vpa.ObjectMeta) if vpa.Status.Recommendation != nil && vpa.Status.Recommendation.ContainerRecommendations != nil { for _, recommend := range vpa.Status.Recommendation.ContainerRecommendations { - // set resource based on CPU - if recommend.Target.Cpu() != nil && recommend.Target.Cpu().Value() != 0 { - multiple = recommend.Target.Cpu().MilliValue() / vpaSpec.ResourceUnit.Cpu.MilliValue() - if recommend.Target.Cpu().MilliValue()%vpaSpec.ResourceUnit.Cpu.MilliValue() != 0 { - multiple += 1 - } - } else if recommend.Target.Memory() != nil { // set resources based on Memory - multiple = recommend.Target.Memory().MilliValue() / vpaSpec.ResourceUnit.Memory.MilliValue() - if recommend.Target.Memory().MilliValue()%vpaSpec.ResourceUnit.Memory.MilliValue() != 0 { - multiple += 1 + if containerName == recommend.ContainerName { + // set resource based on CPU + if recommend.Target.Cpu() != nil && recommend.Target.Cpu().Value() != 0 { + multiple = recommend.Target.Cpu().MilliValue() / vpaSpec.ResourceUnit.CPU.MilliValue() + if recommend.Target.Cpu().MilliValue()%vpaSpec.ResourceUnit.CPU.MilliValue() != 0 { + multiple += 1 + } + } else if recommend.Target.Memory() != nil { // set resources based on Memory + multiple = recommend.Target.Memory().MilliValue() / vpaSpec.ResourceUnit.Memory.MilliValue() + if recommend.Target.Memory().MilliValue()%vpaSpec.ResourceUnit.Memory.MilliValue() != 0 { + multiple += 1 + } } } } @@ -164,7 +165,7 @@ func calculateVPARecommendation(vpa *vpav1.VerticalPodAutoscaler, vpaSpec *v1alp if multiple == 0 { return nil } - targetCpu := *resource.NewScaledQuantity(multiple*vpaSpec.ResourceUnit.Cpu.MilliValue(), resource.Milli) + targetCPU := *resource.NewScaledQuantity(multiple*vpaSpec.ResourceUnit.CPU.MilliValue(), resource.Milli) targetMemory := *resource.NewScaledQuantity(multiple*vpaSpec.ResourceUnit.Memory.MilliValue(), resource.Milli) if vpa.Spec.ResourcePolicy == nil || len(vpa.Spec.ResourcePolicy.ContainerPolicies) == 0 || @@ -172,18 +173,18 @@ func calculateVPARecommendation(vpa *vpav1.VerticalPodAutoscaler, vpaSpec *v1alp *vpa.Spec.ResourcePolicy.ContainerPolicies[0].ControlledValues == vpav1.ContainerControlledValuesRequestsAndLimits { return &corev1.ResourceRequirements{ Limits: corev1.ResourceList{ - corev1.ResourceCPU: targetCpu, + corev1.ResourceCPU: targetCPU, corev1.ResourceMemory: targetMemory, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: targetCpu, + corev1.ResourceCPU: targetCPU, corev1.ResourceMemory: targetMemory, }, } } else { return &corev1.ResourceRequirements{ Requests: corev1.ResourceList{ - corev1.ResourceCPU: targetCpu, + corev1.ResourceCPU: targetCPU, corev1.ResourceMemory: targetMemory, }, } diff --git a/controllers/common_test.go b/controllers/common_test.go index e2f73227e..89578dfae 100644 --- a/controllers/common_test.go +++ b/controllers/common_test.go @@ -1,19 +1,21 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// Package controllers define k8s operator controllers package controllers import ( @@ -45,6 +47,7 @@ func Test_calculateVPARecommendation(t *testing.T) { Recommendation: &vpav1.RecommendedPodResources{ ContainerRecommendations: []vpav1.RecommendedContainerResources{ { + ContainerName: "*", Target: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("0.2"), corev1.ResourceMemory: resource.MustParse("1Gi"), @@ -56,7 +59,7 @@ func Test_calculateVPARecommendation(t *testing.T) { }, vpaSpec: &v1alpha1.VPASpec{ ResourceUnit: &v1alpha1.ResourceUnit{ - Cpu: resource.MustParse("200m"), + CPU: resource.MustParse("200m"), Memory: resource.MustParse("800Mi"), }, }, @@ -80,6 +83,7 @@ func Test_calculateVPARecommendation(t *testing.T) { Recommendation: &vpav1.RecommendedPodResources{ ContainerRecommendations: []vpav1.RecommendedContainerResources{ { + ContainerName: "*", Target: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("100m"), corev1.ResourceMemory: resource.MustParse("1Gi"), @@ -91,7 +95,7 @@ func Test_calculateVPARecommendation(t *testing.T) { }, vpaSpec: &v1alpha1.VPASpec{ ResourceUnit: &v1alpha1.ResourceUnit{ - Cpu: resource.MustParse("0.2"), // 200m + CPU: resource.MustParse("0.2"), // 200m Memory: resource.MustParse("838860800"), // 800Mi }, }, @@ -115,6 +119,7 @@ func Test_calculateVPARecommendation(t *testing.T) { Recommendation: &vpav1.RecommendedPodResources{ ContainerRecommendations: []vpav1.RecommendedContainerResources{ { + ContainerName: "*", Target: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("400m"), corev1.ResourceMemory: resource.MustParse("1Gi"), @@ -126,7 +131,7 @@ func Test_calculateVPARecommendation(t *testing.T) { }, vpaSpec: &v1alpha1.VPASpec{ ResourceUnit: &v1alpha1.ResourceUnit{ - Cpu: resource.MustParse("0.2"), + CPU: resource.MustParse("0.2"), Memory: resource.MustParse("838860800"), }, }, @@ -150,6 +155,7 @@ func Test_calculateVPARecommendation(t *testing.T) { Recommendation: &vpav1.RecommendedPodResources{ ContainerRecommendations: []vpav1.RecommendedContainerResources{ { + ContainerName: "*", Target: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("0.45"), corev1.ResourceMemory: resource.MustParse("1Gi"), @@ -161,7 +167,7 @@ func Test_calculateVPARecommendation(t *testing.T) { }, vpaSpec: &v1alpha1.VPASpec{ ResourceUnit: &v1alpha1.ResourceUnit{ - Cpu: resource.MustParse("200m"), + CPU: resource.MustParse("200m"), Memory: resource.MustParse("800Mi"), }, }, @@ -185,6 +191,7 @@ func Test_calculateVPARecommendation(t *testing.T) { Recommendation: &vpav1.RecommendedPodResources{ ContainerRecommendations: []vpav1.RecommendedContainerResources{ { + ContainerName: "*", Target: corev1.ResourceList{ corev1.ResourceMemory: resource.MustParse("800Mi"), }, @@ -195,7 +202,7 @@ func Test_calculateVPARecommendation(t *testing.T) { }, vpaSpec: &v1alpha1.VPASpec{ ResourceUnit: &v1alpha1.ResourceUnit{ - Cpu: resource.MustParse("200m"), + CPU: resource.MustParse("200m"), Memory: resource.MustParse("838860800"), }, }, @@ -219,6 +226,7 @@ func Test_calculateVPARecommendation(t *testing.T) { Recommendation: &vpav1.RecommendedPodResources{ ContainerRecommendations: []vpav1.RecommendedContainerResources{ { + ContainerName: "*", Target: corev1.ResourceList{ corev1.ResourceMemory: resource.MustParse("629145600"), // 600Mi }, @@ -229,7 +237,7 @@ func Test_calculateVPARecommendation(t *testing.T) { }, vpaSpec: &v1alpha1.VPASpec{ ResourceUnit: &v1alpha1.ResourceUnit{ - Cpu: resource.MustParse("200m"), + CPU: resource.MustParse("200m"), Memory: resource.MustParse("800Mi"), }, }, @@ -253,6 +261,7 @@ func Test_calculateVPARecommendation(t *testing.T) { Recommendation: &vpav1.RecommendedPodResources{ ContainerRecommendations: []vpav1.RecommendedContainerResources{ { + ContainerName: "*", Target: corev1.ResourceList{ corev1.ResourceMemory: resource.MustParse("1600Mi"), }, @@ -263,7 +272,7 @@ func Test_calculateVPARecommendation(t *testing.T) { }, vpaSpec: &v1alpha1.VPASpec{ ResourceUnit: &v1alpha1.ResourceUnit{ - Cpu: resource.MustParse("200m"), + CPU: resource.MustParse("200m"), Memory: resource.MustParse("800Mi"), }, }, @@ -287,6 +296,7 @@ func Test_calculateVPARecommendation(t *testing.T) { Recommendation: &vpav1.RecommendedPodResources{ ContainerRecommendations: []vpav1.RecommendedContainerResources{ { + ContainerName: "*", Target: corev1.ResourceList{ corev1.ResourceMemory: resource.MustParse("1.7Gi"), }, @@ -297,7 +307,7 @@ func Test_calculateVPARecommendation(t *testing.T) { }, vpaSpec: &v1alpha1.VPASpec{ ResourceUnit: &v1alpha1.ResourceUnit{ - Cpu: resource.MustParse("200m"), + CPU: resource.MustParse("200m"), Memory: resource.MustParse("800Mi"), }, }, @@ -321,6 +331,7 @@ func Test_calculateVPARecommendation(t *testing.T) { Recommendation: &vpav1.RecommendedPodResources{ ContainerRecommendations: []vpav1.RecommendedContainerResources{ { + ContainerName: "*", Target: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("200m"), corev1.ResourceMemory: resource.MustParse("1Gi"), @@ -342,7 +353,7 @@ func Test_calculateVPARecommendation(t *testing.T) { }, vpaSpec: &v1alpha1.VPASpec{ ResourceUnit: &v1alpha1.ResourceUnit{ - Cpu: resource.MustParse("200m"), + CPU: resource.MustParse("200m"), Memory: resource.MustParse("800Mi"), }, }, diff --git a/controllers/function_controller_test.go b/controllers/function_controller_test.go index 3ba460a3c..a1f5f62dc 100644 --- a/controllers/function_controller_test.go +++ b/controllers/function_controller_test.go @@ -174,6 +174,7 @@ var _ = Describe("Function Controller (builtin HPA)", func() { var _ = Describe("Function Controller (VPA)", func() { Context("Simple Function Item with VPA", func() { mode := vpav1.UpdateModeAuto + containerMode := vpav1.ContainerScalingModeAuto controlledValues := vpav1.ContainerControlledValuesRequestsAndLimits function := makeFunctionSample(TestFunctionVPAName) function.Spec.Pod.VPA = &v1alpha1.VPASpec{ @@ -183,7 +184,7 @@ var _ = Describe("Function Controller (VPA)", func() { ResourcePolicy: &vpav1.PodResourcePolicy{ ContainerPolicies: []vpav1.ContainerResourcePolicy{ { - ContainerName: "*", + ContainerName: "pulsar-function", MinAllowed: v1.ResourceList{ v1.ResourceCPU: resource.MustParse("100m"), v1.ResourceMemory: resource.MustParse("100Mi"), @@ -196,6 +197,7 @@ var _ = Describe("Function Controller (VPA)", func() { v1.ResourceCPU, v1.ResourceMemory, }, ControlledValues: &controlledValues, + Mode: &containerMode, }, }, }, diff --git a/controllers/spec/common.go b/controllers/spec/common.go index 87ae2dd28..852079f6e 100644 --- a/controllers/spec/common.go +++ b/controllers/spec/common.go @@ -20,6 +20,7 @@ package spec import ( "bytes" "context" + // used for template _ "embed" "encoding/json" diff --git a/controllers/spec/vpa.go b/controllers/spec/vpa.go index 51c79e5b5..da27175b0 100644 --- a/controllers/spec/vpa.go +++ b/controllers/spec/vpa.go @@ -28,13 +28,11 @@ import ( func MakeVPA(objectMeta *metav1.ObjectMeta, targetRef *autov2.CrossVersionObjectReference, vpa *v1alpha1.VPASpec) *vpav1.VerticalPodAutoscaler { containerName := GetVPAContainerName(objectMeta) - updatePolicy := vpa.UpdatePolicy - UpdateVPAUpdatePolicy(updatePolicy, vpa.ResourceUnit) + updatePolicy := UpdateVPAUpdatePolicy(vpa.UpdatePolicy, vpa.ResourceUnit) if vpa.ResourceUnit != nil { objectMeta.Labels[LabelCustomResourceUnit] = "true" } - resourcePolicy := vpa.ResourcePolicy - UpdateResourcePolicy(resourcePolicy, containerName) + resourcePolicy := UpdateResourcePolicy(vpa.ResourcePolicy, containerName) return &vpav1.VerticalPodAutoscaler{ TypeMeta: metav1.TypeMeta{ @@ -67,19 +65,24 @@ func GetVPAContainerName(objectMeta *metav1.ObjectMeta) string { return containerName } -func UpdateVPAUpdatePolicy(updatePolicy *vpav1.PodUpdatePolicy, resourceUnit *v1alpha1.ResourceUnit) { - if updatePolicy != nil && resourceUnit != nil { +func UpdateVPAUpdatePolicy(updatePolicy *vpav1.PodUpdatePolicy, resourceUnit *v1alpha1.ResourceUnit) *vpav1.PodUpdatePolicy { + resultUpdatePolicy := updatePolicy + if resourceUnit != nil { + if resultUpdatePolicy == nil { + resultUpdatePolicy = &vpav1.PodUpdatePolicy{} + } off := vpav1.UpdateModeOff - updatePolicy.UpdateMode = &off + resultUpdatePolicy.UpdateMode = &off } + return resultUpdatePolicy } -func UpdateResourcePolicy(resourcePolicy *vpav1.PodResourcePolicy, containerName string) { +func UpdateResourcePolicy(resourcePolicy *vpav1.PodResourcePolicy, containerName string) *vpav1.PodResourcePolicy { var containerPolicies []vpav1.ContainerResourcePolicy containerScalingMode := vpav1.ContainerScalingModeAuto if resourcePolicy != nil { if resourcePolicy.ContainerPolicies == nil { - resourcePolicy.ContainerPolicies = []vpav1.ContainerResourcePolicy{} + containerPolicies = []vpav1.ContainerResourcePolicy{} } for _, policy := range resourcePolicy.ContainerPolicies { if policy.ContainerName == containerName { @@ -99,5 +102,10 @@ func UpdateResourcePolicy(resourcePolicy *vpav1.PodResourcePolicy, containerName }, } } - resourcePolicy.ContainerPolicies = containerPolicies + resultResourcePolicy := resourcePolicy + if resultResourcePolicy == nil { + resultResourcePolicy = &vpav1.PodResourcePolicy{} + } + resultResourcePolicy.ContainerPolicies = containerPolicies + return resultResourcePolicy } diff --git a/controllers/spec/vpa_test.go b/controllers/spec/vpa_test.go index cf8ec3aab..51d5de78b 100644 --- a/controllers/spec/vpa_test.go +++ b/controllers/spec/vpa_test.go @@ -32,7 +32,11 @@ import ( func TestMakeVPA(t *testing.T) { mode := vpav1.UpdateModeAuto + off := vpav1.UpdateModeOff + containerMode := vpav1.ContainerScalingModeAuto + containerOffMode := vpav1.ContainerScalingModeOff controlledValues := vpav1.ContainerControlledValuesRequestsAndLimits + var minReplicas int32 = 3 type args struct { objectMeta *metav1.ObjectMeta targetRef *autov2.CrossVersionObjectReference @@ -48,6 +52,9 @@ func TestMakeVPA(t *testing.T) { args: args{ objectMeta: &metav1.ObjectMeta{ Name: "test-vpa", + Labels: map[string]string{ + LabelComponent: "function", + }, }, targetRef: &autov2.CrossVersionObjectReference{ APIVersion: "apps/v1", @@ -60,7 +67,7 @@ func TestMakeVPA(t *testing.T) { }, ResourcePolicy: &vpav1.PodResourcePolicy{ ContainerPolicies: []vpav1.ContainerResourcePolicy{{ - ContainerName: "test-container", + ContainerName: "pulsar-function", MinAllowed: v1.ResourceList{ v1.ResourceCPU: resource.MustParse("100m"), v1.ResourceMemory: resource.MustParse("100Mi"), @@ -80,6 +87,9 @@ func TestMakeVPA(t *testing.T) { want: &vpav1.VerticalPodAutoscaler{ ObjectMeta: metav1.ObjectMeta{ Name: "test-vpa", + Labels: map[string]string{ + LabelComponent: "function", + }, }, TypeMeta: metav1.TypeMeta{ APIVersion: "autoscaling.k8s.io/v1", @@ -97,7 +107,7 @@ func TestMakeVPA(t *testing.T) { ResourcePolicy: &vpav1.PodResourcePolicy{ ContainerPolicies: []vpav1.ContainerResourcePolicy{ { - ContainerName: "test-container", + ContainerName: "pulsar-function", MinAllowed: v1.ResourceList{ v1.ResourceCPU: resource.MustParse("100m"), v1.ResourceMemory: resource.MustParse("100Mi"), @@ -110,6 +120,7 @@ func TestMakeVPA(t *testing.T) { v1.ResourceCPU, v1.ResourceMemory, }, ControlledValues: &controlledValues, + Mode: &containerMode, }, }, }, @@ -121,6 +132,9 @@ func TestMakeVPA(t *testing.T) { args: args{ objectMeta: &metav1.ObjectMeta{ Name: "test-vpa", + Labels: map[string]string{ + LabelComponent: "function", + }, }, targetRef: &autov2.CrossVersionObjectReference{ APIVersion: "apps/v1", @@ -136,6 +150,9 @@ func TestMakeVPA(t *testing.T) { want: &vpav1.VerticalPodAutoscaler{ ObjectMeta: metav1.ObjectMeta{ Name: "test-vpa", + Labels: map[string]string{ + LabelComponent: "function", + }, }, TypeMeta: metav1.TypeMeta{ APIVersion: "autoscaling.k8s.io/v1", @@ -150,7 +167,14 @@ func TestMakeVPA(t *testing.T) { UpdatePolicy: &vpav1.PodUpdatePolicy{ UpdateMode: &mode, }, - ResourcePolicy: nil, + ResourcePolicy: &vpav1.PodResourcePolicy{ + ContainerPolicies: []vpav1.ContainerResourcePolicy{ + { + ContainerName: "pulsar-function", + Mode: &containerMode, + }, + }, + }, }, }, }, @@ -159,6 +183,9 @@ func TestMakeVPA(t *testing.T) { args: args{ objectMeta: &metav1.ObjectMeta{ Name: "test-vpa", + Labels: map[string]string{ + LabelComponent: "sink", + }, }, targetRef: &autov2.CrossVersionObjectReference{ APIVersion: "apps/v1", @@ -168,7 +195,7 @@ func TestMakeVPA(t *testing.T) { vpa: &v1alpha1.VPASpec{ ResourcePolicy: &vpav1.PodResourcePolicy{ ContainerPolicies: []vpav1.ContainerResourcePolicy{{ - ContainerName: "test-container", + ContainerName: "pulsar-sink", MinAllowed: v1.ResourceList{ v1.ResourceCPU: resource.MustParse("100m"), v1.ResourceMemory: resource.MustParse("100Mi"), @@ -189,6 +216,9 @@ func TestMakeVPA(t *testing.T) { want: &vpav1.VerticalPodAutoscaler{ ObjectMeta: metav1.ObjectMeta{ Name: "test-vpa", + Labels: map[string]string{ + LabelComponent: "sink", + }, }, TypeMeta: metav1.TypeMeta{ APIVersion: "autoscaling.k8s.io/v1", @@ -204,7 +234,7 @@ func TestMakeVPA(t *testing.T) { ResourcePolicy: &vpav1.PodResourcePolicy{ ContainerPolicies: []vpav1.ContainerResourcePolicy{ { - ContainerName: "test-container", + ContainerName: "pulsar-sink", MinAllowed: v1.ResourceList{ v1.ResourceCPU: resource.MustParse("100m"), v1.ResourceMemory: resource.MustParse("100Mi"), @@ -217,6 +247,7 @@ func TestMakeVPA(t *testing.T) { v1.ResourceCPU, v1.ResourceMemory, }, ControlledValues: &controlledValues, + Mode: &containerMode, }, }, }, @@ -228,6 +259,9 @@ func TestMakeVPA(t *testing.T) { args: args{ objectMeta: &metav1.ObjectMeta{ Name: "test-vpa", + Labels: map[string]string{ + LabelComponent: "source", + }, }, targetRef: &autov2.CrossVersionObjectReference{ APIVersion: "apps/v1", @@ -239,6 +273,9 @@ func TestMakeVPA(t *testing.T) { want: &vpav1.VerticalPodAutoscaler{ ObjectMeta: metav1.ObjectMeta{ Name: "test-vpa", + Labels: map[string]string{ + LabelComponent: "source", + }, }, TypeMeta: metav1.TypeMeta{ APIVersion: "autoscaling.k8s.io/v1", @@ -250,8 +287,158 @@ func TestMakeVPA(t *testing.T) { Kind: "Deployment", Name: "test-deployment", }, - UpdatePolicy: nil, - ResourcePolicy: nil, + UpdatePolicy: nil, + ResourcePolicy: &vpav1.PodResourcePolicy{ + ContainerPolicies: []vpav1.ContainerResourcePolicy{ + { + ContainerName: "pulsar-source", + Mode: &containerMode, + }, + }, + }, + }, + }, + }, + { + name: "Generate VPA with resource unit successfully", + args: args{ + objectMeta: &metav1.ObjectMeta{ + Name: "test-vpa", + Labels: map[string]string{ + LabelComponent: "source", + }, + }, + targetRef: &autov2.CrossVersionObjectReference{ + APIVersion: "apps/v1", + Kind: "Deployment", + Name: "test-deployment", + }, + vpa: &v1alpha1.VPASpec{ + ResourceUnit: &v1alpha1.ResourceUnit{ + CPU: resource.MustParse("200m"), + Memory: resource.MustParse("800Mi"), + }, + }, + }, + want: &vpav1.VerticalPodAutoscaler{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-vpa", + Labels: map[string]string{ + LabelComponent: "source", + LabelCustomResourceUnit: "true", + }, + }, + TypeMeta: metav1.TypeMeta{ + APIVersion: "autoscaling.k8s.io/v1", + Kind: "VerticalPodAutoscaler", + }, + Spec: vpav1.VerticalPodAutoscalerSpec{ + TargetRef: &autoscaling.CrossVersionObjectReference{ + APIVersion: "apps/v1", + Kind: "Deployment", + Name: "test-deployment", + }, + UpdatePolicy: &vpav1.PodUpdatePolicy{ + UpdateMode: &off, + }, + ResourcePolicy: &vpav1.PodResourcePolicy{ + ContainerPolicies: []vpav1.ContainerResourcePolicy{ + { + ContainerName: "pulsar-source", + Mode: &containerMode, + }, + }, + }, + }, + }, + }, + { + name: "Generate VPA with resource unit and resource policy successfully", + args: args{ + objectMeta: &metav1.ObjectMeta{ + Name: "test-vpa", + Labels: map[string]string{ + LabelComponent: "source", + }, + }, + targetRef: &autov2.CrossVersionObjectReference{ + APIVersion: "apps/v1", + Kind: "Deployment", + Name: "test-deployment", + }, + vpa: &v1alpha1.VPASpec{ + ResourceUnit: &v1alpha1.ResourceUnit{ + CPU: resource.MustParse("200m"), + Memory: resource.MustParse("800Mi"), + }, + UpdatePolicy: &vpav1.PodUpdatePolicy{ + UpdateMode: &mode, // should be set to 'Off' + MinReplicas: &minReplicas, + }, + ResourcePolicy: &vpav1.PodResourcePolicy{ + ContainerPolicies: []vpav1.ContainerResourcePolicy{ + { + ContainerName: "pulsar-source", + MinAllowed: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("100m"), + v1.ResourceMemory: resource.MustParse("100Mi"), + }, + MaxAllowed: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("1000m"), + v1.ResourceMemory: resource.MustParse("1000Mi"), + }, + Mode: &containerOffMode, // should be converted to 'Auto' + ControlledValues: &controlledValues, + ControlledResources: &[]v1.ResourceName{v1.ResourceCPU}, + }, + { + ContainerName: "istio", // should be ignored + Mode: &containerMode, + }, + }, + }, + }, + }, + want: &vpav1.VerticalPodAutoscaler{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-vpa", + Labels: map[string]string{ + LabelComponent: "source", + LabelCustomResourceUnit: "true", + }, + }, + TypeMeta: metav1.TypeMeta{ + APIVersion: "autoscaling.k8s.io/v1", + Kind: "VerticalPodAutoscaler", + }, + Spec: vpav1.VerticalPodAutoscalerSpec{ + TargetRef: &autoscaling.CrossVersionObjectReference{ + APIVersion: "apps/v1", + Kind: "Deployment", + Name: "test-deployment", + }, + UpdatePolicy: &vpav1.PodUpdatePolicy{ + UpdateMode: &off, + MinReplicas: &minReplicas, + }, + ResourcePolicy: &vpav1.PodResourcePolicy{ + ContainerPolicies: []vpav1.ContainerResourcePolicy{ + { + ContainerName: "pulsar-source", + Mode: &containerMode, + MinAllowed: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("100m"), + v1.ResourceMemory: resource.MustParse("100Mi"), + }, + MaxAllowed: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("1000m"), + v1.ResourceMemory: resource.MustParse("1000Mi"), + }, + ControlledValues: &controlledValues, + ControlledResources: &[]v1.ResourceName{v1.ResourceCPU}, + }, + }, + }, }, }, }, From 44140dc7499ac0aa351599271c4da21d3df63c4d Mon Sep 17 00:00:00 2001 From: jiangpengcheng Date: Wed, 8 May 2024 15:41:28 +0800 Subject: [PATCH 3/5] Update label --- controllers/spec/common.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/controllers/spec/common.go b/controllers/spec/common.go index 852079f6e..e02543857 100644 --- a/controllers/spec/common.go +++ b/controllers/spec/common.go @@ -20,7 +20,6 @@ package spec import ( "bytes" "context" - // used for template _ "embed" "encoding/json" @@ -132,7 +131,7 @@ const ( LabelComponent = "compute.functionmesh.io/component" LabelName = "compute.functionmesh.io/name" LabelNamespace = "compute.functionmesh.io/namespace" - LabelCustomResourceUnit = "streamnative.io/custom-resource-unit" + LabelCustomResourceUnit = "compute.functionmesh.io/custom-resource-unit" FunctionContainerName = "pulsar-function" SinkContainerName = "pulsar-sink" From 00737e902b9affd35403e8a3f5567b08098d8e3e Mon Sep 17 00:00:00 2001 From: jiangpengcheng Date: Thu, 9 May 2024 09:40:44 +0800 Subject: [PATCH 4/5] Use max multiplier --- .ci/helm.sh | 34 ++++++++++++++++++++-------- .github/workflows/trivy.yml | 3 ++- controllers/common.go | 11 +++++++--- controllers/common_test.go | 44 +++++++++++++++++++++++++++++++++---- controllers/spec/common.go | 1 + 5 files changed, 76 insertions(+), 17 deletions(-) diff --git a/.ci/helm.sh b/.ci/helm.sh index 3dce7655c..4e4fef388 100644 --- a/.ci/helm.sh +++ b/.ci/helm.sh @@ -269,6 +269,21 @@ function ci::verify_vpa_java_function() { ci::verify_exclamation_function "persistent://public/default/input-vpa-java-topic" "persistent://public/default/output-vpa-java-topic" "test-message" "test-message!" 10 } +function ci::calculate_multiplies() { + base=$1 + value=$2 + quotient=$(($value / $base)) + remainder=$(($value % $base)) + + # If there's any remainder, we need to round up + if [ $remainder -ne 0 ]; then + multiple=$(($quotient + 1)) + else + multiple=$quotient + fi + echo $multiple +} + function ci::verify_vpa_with_resource_unit() { name=$1 kind=$2 @@ -278,18 +293,19 @@ function ci::verify_vpa_with_resource_unit() { kubectl wait -l name=$name --for=condition=RecommendationProvided --timeout=2m vpa cpu=`kubectl get vpa $vpaName -o jsonpath='{.status.recommendation.containerRecommendations[0].target.cpu}'` cpu_value=${cpu%m} + multiplier=$(ci::calculate_multiplies $baseCpu $cpu_value) - quotient=$(($cpu_value / $baseCpu)) - remainder=$(($cpu_value % $baseCpu)) + memory=`kubectl get vpa $vpaName -o jsonpath='{.status.recommendation.containerRecommendations[0].target.memory}'` + memory_value=${memory%k} + memory_value=$((memory_value*1024)) + memoryMultiplier=$(ci::calculate_multiplies $baseMemory $memory_value) - # If there's any remainder, we need to round up - if [ $remainder -ne 0 ]; then - multiple=$(($quotient + 1)) - else - multiple=$quotient + if [ $memoryMultiplier -gt $multiplier ]; then + multiplier=$memoryMultiplier fi - targetCpu=`echo $(($baseCpu* $multiple ))m` - targetMemory=`echo $(($baseMemory * $multiple ))` + + targetCpu=`echo $(($baseCpu* $multiple))m` + targetMemory=`echo $(($baseMemory * $multiple))` resources='{"limits":{"cpu":"'$targetCpu'","memory":"'$targetMemory'"},"requests":{"cpu":"'$targetCpu'","memory":"'$targetMemory'"}}' diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml index 1352c83b1..9156ce19d 100644 --- a/.github/workflows/trivy.yml +++ b/.github/workflows/trivy.yml @@ -59,4 +59,5 @@ jobs: with: image-ref: 'function-mesh-operator:latest' format: 'table' - exit-code: '1' \ No newline at end of file + exit-code: '1' + severity: "MEDIUM,HIGH,CRITICAL" diff --git a/controllers/common.go b/controllers/common.go index 3a80311d3..ae805ddb1 100644 --- a/controllers/common.go +++ b/controllers/common.go @@ -152,10 +152,15 @@ func calculateVPARecommendation(vpa *vpav1.VerticalPodAutoscaler, vpaSpec *v1alp if recommend.Target.Cpu().MilliValue()%vpaSpec.ResourceUnit.CPU.MilliValue() != 0 { multiple += 1 } - } else if recommend.Target.Memory() != nil { // set resources based on Memory - multiple = recommend.Target.Memory().MilliValue() / vpaSpec.ResourceUnit.Memory.MilliValue() + } + if recommend.Target.Memory() != nil && recommend.Target.Memory().Value() != 0 { + multipleMemory := recommend.Target.Memory().MilliValue() / vpaSpec.ResourceUnit.Memory.MilliValue() if recommend.Target.Memory().MilliValue()%vpaSpec.ResourceUnit.Memory.MilliValue() != 0 { - multiple += 1 + multipleMemory += 1 + } + // use the larger multiple + if multipleMemory > multiple { + multiple = multipleMemory } } } diff --git a/controllers/common_test.go b/controllers/common_test.go index 89578dfae..b610254b2 100644 --- a/controllers/common_test.go +++ b/controllers/common_test.go @@ -50,7 +50,7 @@ func Test_calculateVPARecommendation(t *testing.T) { ContainerName: "*", Target: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("0.2"), - corev1.ResourceMemory: resource.MustParse("1Gi"), + corev1.ResourceMemory: resource.MustParse("600Mi"), }, }, }, @@ -86,7 +86,7 @@ func Test_calculateVPARecommendation(t *testing.T) { ContainerName: "*", Target: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("100m"), - corev1.ResourceMemory: resource.MustParse("1Gi"), + corev1.ResourceMemory: resource.MustParse("0.6Gi"), }, }, }, @@ -183,6 +183,42 @@ func Test_calculateVPARecommendation(t *testing.T) { }, }, }, + { + name: "Use memory to calculate multiplier when it increase more than cpu", + args: args{ + vpa: &vpav1.VerticalPodAutoscaler{ + Status: vpav1.VerticalPodAutoscalerStatus{ + Recommendation: &vpav1.RecommendedPodResources{ + ContainerRecommendations: []vpav1.RecommendedContainerResources{ + { + ContainerName: "*", + Target: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("0.2"), + corev1.ResourceMemory: resource.MustParse("1Gi"), + }, + }, + }, + }, + }, + }, + vpaSpec: &v1alpha1.VPASpec{ + ResourceUnit: &v1alpha1.ResourceUnit{ + CPU: resource.MustParse("200m"), + Memory: resource.MustParse("800Mi"), + }, + }, + }, + want: &corev1.ResourceRequirements{ + Requests: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(400, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(2*800*1024*1024*1000, resource.Milli), + }, + Limits: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewScaledQuantity(400, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(2*800*1024*1024*1000, resource.Milli), + }, + }, + }, { name: "Use the target memory when target memory is equal to the resource unit memory", args: args{ @@ -360,8 +396,8 @@ func Test_calculateVPARecommendation(t *testing.T) { }, want: &corev1.ResourceRequirements{ Requests: corev1.ResourceList{ - corev1.ResourceCPU: *resource.NewScaledQuantity(200, resource.Milli), - corev1.ResourceMemory: *resource.NewScaledQuantity(800*1024*1024*1000, resource.Milli), + corev1.ResourceCPU: *resource.NewScaledQuantity(400, resource.Milli), + corev1.ResourceMemory: *resource.NewScaledQuantity(2*800*1024*1024*1000, resource.Milli), }, }, }, diff --git a/controllers/spec/common.go b/controllers/spec/common.go index e02543857..c17a72148 100644 --- a/controllers/spec/common.go +++ b/controllers/spec/common.go @@ -20,6 +20,7 @@ package spec import ( "bytes" "context" + // used for template _ "embed" "encoding/json" From 0be5d4987e39e5ec590a158f8d5459d8cd44a83f Mon Sep 17 00:00:00 2001 From: jiangpengcheng Date: Thu, 9 May 2024 15:07:56 +0800 Subject: [PATCH 5/5] fix ci --- .ci/helm.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.ci/helm.sh b/.ci/helm.sh index 4e4fef388..57d3ad93f 100644 --- a/.ci/helm.sh +++ b/.ci/helm.sh @@ -296,16 +296,26 @@ function ci::verify_vpa_with_resource_unit() { multiplier=$(ci::calculate_multiplies $baseCpu $cpu_value) memory=`kubectl get vpa $vpaName -o jsonpath='{.status.recommendation.containerRecommendations[0].target.memory}'` - memory_value=${memory%k} - memory_value=$((memory_value*1024)) + if [[ "$memory" == "*k" ]]; then + memory_value=${memory%k} + memory_value=$((memory_value*1000)) + elif [[ "$memory" == "*Mi" ]]; then + memory_value=${memory%Mi} + memory_value=$((memory_value*1024*1024)) + elif [[ "$memory" == "*Gi" ]]; then + memory_value=${memory%Gi} + memory_value=$((memory_value*1024*1024*1024)) + else + memory_value=${memory} + fi memoryMultiplier=$(ci::calculate_multiplies $baseMemory $memory_value) if [ $memoryMultiplier -gt $multiplier ]; then multiplier=$memoryMultiplier fi - targetCpu=`echo $(($baseCpu* $multiple))m` - targetMemory=`echo $(($baseMemory * $multiple))` + targetCpu=`echo $(($baseCpu* $multiplier))m` + targetMemory=`echo $(($baseMemory * $multiplier))` resources='{"limits":{"cpu":"'$targetCpu'","memory":"'$targetMemory'"},"requests":{"cpu":"'$targetCpu'","memory":"'$targetMemory'"}}'