diff --git a/config/crd/bases/autoscaling.katalyst.kubewharf.io_intelligenthorizontalpodautoscalers.yaml b/config/crd/bases/autoscaling.katalyst.kubewharf.io_intelligenthorizontalpodautoscalers.yaml new file mode 100644 index 0000000..6ff407b --- /dev/null +++ b/config/crd/bases/autoscaling.katalyst.kubewharf.io_intelligenthorizontalpodautoscalers.yaml @@ -0,0 +1,865 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.0 + creationTimestamp: null + name: intelligenthorizontalpodautoscalers.autoscaling.katalyst.kubewharf.io +spec: + group: autoscaling.katalyst.kubewharf.io + names: + kind: IntelligentHorizontalPodAutoscaler + listKind: IntelligentHorizontalPodAutoscalerList + plural: intelligenthorizontalpodautoscalers + shortNames: + - ihpa + singular: intelligenthorizontalpodautoscaler + scope: Namespaced + versions: + - name: v1alpha2 + schema: + openAPIV3Schema: + description: IntelligentHorizontalPodAutoscaler captures information about + a IHPA object + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: Spec defines the behavior of a IntelligentHorizontalPodAutoscaler. + properties: + algorithmConfig: + description: AlgorithmConfig defines the algorithm configuration. + If there is no configuration, the default configuration will be + used. + properties: + method: + description: Method is the method used to calculate the resource + portrait. + type: string + params: + additionalProperties: + type: string + description: Params contains a list of parameters used by the + algorithm. + type: object + resyncPeriod: + description: ResyncPeriod contains the resync period used by the + algorithm. + format: int64 + type: integer + timeWindow: + description: TimeWindow contains the time window used by the algorithm. + properties: + aggregator: + description: Aggregator is the aggregator used to aggregate + the time series data group. + enum: + - avg + - max + type: string + historySteps: + description: HistorySteps is the number of steps to use as + the input for the algorithm. + type: integer + input: + description: Input is the time interval used when querying + the time series data source, with the unit being seconds. + type: integer + output: + description: Output is the grouping interval of portrait data, + which groups portrait data at an integer multiple of Input. + type: integer + predictionSteps: + description: PredictionSteps is the number of steps to predict + the future value. + type: integer + required: + - aggregator + - historySteps + - input + - output + - predictionSteps + type: object + required: + - method + - resyncPeriod + - timeWindow + type: object + autoscaler: + description: Autoscaler defines the overall scaling configuration. + properties: + behavior: + description: Behavior defines scaling actions, which are transparently + transmitted to HPA and implemented by HPA Controller. + properties: + scaleDown: + description: scaleDown is scaling policy for scaling Down. + If not set, the default value is to allow to scale down + to minReplicas pods, with a 300 second stabilization window + (i.e., the highest recommendation for the last 300sec is + used). + properties: + policies: + description: policies is a list of potential scaling polices + which can be used during scaling. At least one policy + must be specified, otherwise the HPAScalingRules will + be discarded as invalid + items: + description: HPAScalingPolicy is a single policy which + must hold true for a specified past interval. + properties: + periodSeconds: + description: PeriodSeconds specifies the window + of time for which the policy should hold true. + PeriodSeconds must be greater than zero and less + than or equal to 1800 (30 min). + format: int32 + type: integer + type: + description: Type is used to specify the scaling + policy. + type: string + value: + description: Value contains the amount of change + which is permitted by the policy. It must be greater + than zero + format: int32 + type: integer + required: + - periodSeconds + - type + - value + type: object + type: array + x-kubernetes-list-type: atomic + selectPolicy: + description: selectPolicy is used to specify which policy + should be used. If not set, the default value Max is + used. + type: string + stabilizationWindowSeconds: + description: 'StabilizationWindowSeconds is the number + of seconds for which past recommendations should be + considered while scaling up or scaling down. StabilizationWindowSeconds + must be greater than or equal to zero and less than + or equal to 3600 (one hour). If not set, use the default + values: - For scale up: 0 (i.e. no stabilization is + done). - For scale down: 300 (i.e. the stabilization + window is 300 seconds long).' + format: int32 + type: integer + type: object + scaleUp: + description: 'scaleUp is scaling policy for scaling Up. If + not set, the default value is the higher of: * increase + no more than 4 pods per 60 seconds * double the number of + pods per 60 seconds No stabilization is used.' + properties: + policies: + description: policies is a list of potential scaling polices + which can be used during scaling. At least one policy + must be specified, otherwise the HPAScalingRules will + be discarded as invalid + items: + description: HPAScalingPolicy is a single policy which + must hold true for a specified past interval. + properties: + periodSeconds: + description: PeriodSeconds specifies the window + of time for which the policy should hold true. + PeriodSeconds must be greater than zero and less + than or equal to 1800 (30 min). + format: int32 + type: integer + type: + description: Type is used to specify the scaling + policy. + type: string + value: + description: Value contains the amount of change + which is permitted by the policy. It must be greater + than zero + format: int32 + type: integer + required: + - periodSeconds + - type + - value + type: object + type: array + x-kubernetes-list-type: atomic + selectPolicy: + description: selectPolicy is used to specify which policy + should be used. If not set, the default value Max is + used. + type: string + stabilizationWindowSeconds: + description: 'StabilizationWindowSeconds is the number + of seconds for which past recommendations should be + considered while scaling up or scaling down. StabilizationWindowSeconds + must be greater than or equal to zero and less than + or equal to 3600 (one hour). If not set, use the default + values: - For scale up: 0 (i.e. no stabilization is + done). - For scale down: 300 (i.e. the stabilization + window is 300 seconds long).' + format: int32 + type: integer + type: object + type: object + maxReplicas: + format: int32 + type: integer + metrics: + description: Metrics define the metrics used for workload scaling. + items: + description: MetricSpec is used to define a single metric of + HPA. Metric is preferred. Only one of Metric and CustomMetric + will take effect. The metrics source of Metric is API Server. + The metrics source of CustomMetric is the resource portrait. + properties: + customMetric: + description: CustomMetricSpec configures metrics derived + from resource portraits. + properties: + identify: + description: Identify defines the name of the resource + metric + type: string + query: + description: Query defines the metrics query statement. + There are preset templates for resource portraits, + so the query statement can be empty. + type: string + value: + anyOf: + - type: integer + - type: string + description: Value represents the threshold, corresponding + to the AverageValue in HPA. + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + required: + - identify + - value + type: object + metric: + description: MetricSpec specifies how to scale based on + a single metric (only `type` and one other matching field + should be set at once). + properties: + containerResource: + description: containerResource refers to a resource + metric (such as those specified in requests and limits) + known to Kubernetes describing a single container + in each pod of the current scale target (e.g. CPU + or memory). Such metrics are built in to Kubernetes, + and have special scaling options on top of those available + to normal per-pod metrics using the "pods" source. + This is an alpha feature and can be enabled by the + HPAContainerMetrics feature flag. + properties: + container: + description: container is the name of the container + in the pods of the scaling target + type: string + name: + description: name is the name of the resource in + question. + type: string + target: + description: target specifies the target value for + the given metric + properties: + averageUtilization: + description: averageUtilization is the target + value of the average of the resource metric + across all relevant pods, represented as a + percentage of the requested value of the resource + for the pods. Currently only valid for Resource + metric source type + format: int32 + type: integer + averageValue: + anyOf: + - type: integer + - type: string + description: averageValue is the target value + of the average of the metric across all relevant + pods (as a quantity) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: type represents whether the metric + type is Utilization, Value, or AverageValue + type: string + value: + anyOf: + - type: integer + - type: string + description: value is the target value of the + metric (as a quantity). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + required: + - type + type: object + required: + - container + - name + - target + type: object + external: + description: external refers to a global metric that + is not associated with any Kubernetes object. It allows + autoscaling based on information coming from components + running outside of cluster (for example length of + queue in cloud messaging service, or QPS from loadbalancer + running outside of cluster). + properties: + metric: + description: metric identifies the target metric + by name and selector + properties: + name: + description: name is the name of the given metric + type: string + selector: + description: selector is the string-encoded + form of a standard kubernetes label selector + for the given metric When set, it is passed + as an additional parameter to the metrics + server for more specific metrics scoping. + When unset, just the metricName will be used + to gather metrics. + properties: + matchExpressions: + description: matchExpressions is a list + of label selector requirements. The requirements + are ANDed. + items: + description: A label selector requirement + is a selector that contains values, + a key, and an operator that relates + the key and values. + properties: + key: + description: key is the label key + that the selector applies to. + type: string + operator: + description: operator represents a + key's relationship to a set of values. + Valid operators are In, NotIn, Exists + and DoesNotExist. + type: string + values: + description: values is an array of + string values. If the operator is + In or NotIn, the values array must + be non-empty. If the operator is + Exists or DoesNotExist, the values + array must be empty. This array + is replaced during a strategic merge + patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, + whose key field is "key", the operator + is "In", and the values array contains + only "value". The requirements are ANDed. + type: object + type: object + required: + - name + type: object + target: + description: target specifies the target value for + the given metric + properties: + averageUtilization: + description: averageUtilization is the target + value of the average of the resource metric + across all relevant pods, represented as a + percentage of the requested value of the resource + for the pods. Currently only valid for Resource + metric source type + format: int32 + type: integer + averageValue: + anyOf: + - type: integer + - type: string + description: averageValue is the target value + of the average of the metric across all relevant + pods (as a quantity) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: type represents whether the metric + type is Utilization, Value, or AverageValue + type: string + value: + anyOf: + - type: integer + - type: string + description: value is the target value of the + metric (as a quantity). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + required: + - type + type: object + required: + - metric + - target + type: object + object: + description: object refers to a metric describing a + single kubernetes object (for example, hits-per-second + on an Ingress object). + properties: + describedObject: + description: describedObject specifies the descriptions + of a object,such as kind,name apiVersion + properties: + apiVersion: + description: API version of the referent + type: string + kind: + description: 'Kind of the referent; More info: + https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds"' + type: string + name: + description: 'Name of the referent; More info: + http://kubernetes.io/docs/user-guide/identifiers#names' + type: string + required: + - kind + - name + type: object + metric: + description: metric identifies the target metric + by name and selector + properties: + name: + description: name is the name of the given metric + type: string + selector: + description: selector is the string-encoded + form of a standard kubernetes label selector + for the given metric When set, it is passed + as an additional parameter to the metrics + server for more specific metrics scoping. + When unset, just the metricName will be used + to gather metrics. + properties: + matchExpressions: + description: matchExpressions is a list + of label selector requirements. The requirements + are ANDed. + items: + description: A label selector requirement + is a selector that contains values, + a key, and an operator that relates + the key and values. + properties: + key: + description: key is the label key + that the selector applies to. + type: string + operator: + description: operator represents a + key's relationship to a set of values. + Valid operators are In, NotIn, Exists + and DoesNotExist. + type: string + values: + description: values is an array of + string values. If the operator is + In or NotIn, the values array must + be non-empty. If the operator is + Exists or DoesNotExist, the values + array must be empty. This array + is replaced during a strategic merge + patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, + whose key field is "key", the operator + is "In", and the values array contains + only "value". The requirements are ANDed. + type: object + type: object + required: + - name + type: object + target: + description: target specifies the target value for + the given metric + properties: + averageUtilization: + description: averageUtilization is the target + value of the average of the resource metric + across all relevant pods, represented as a + percentage of the requested value of the resource + for the pods. Currently only valid for Resource + metric source type + format: int32 + type: integer + averageValue: + anyOf: + - type: integer + - type: string + description: averageValue is the target value + of the average of the metric across all relevant + pods (as a quantity) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: type represents whether the metric + type is Utilization, Value, or AverageValue + type: string + value: + anyOf: + - type: integer + - type: string + description: value is the target value of the + metric (as a quantity). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + required: + - type + type: object + required: + - describedObject + - metric + - target + type: object + pods: + description: pods refers to a metric describing each + pod in the current scale target (for example, transactions-processed-per-second). The + values will be averaged together before being compared + to the target value. + properties: + metric: + description: metric identifies the target metric + by name and selector + properties: + name: + description: name is the name of the given metric + type: string + selector: + description: selector is the string-encoded + form of a standard kubernetes label selector + for the given metric When set, it is passed + as an additional parameter to the metrics + server for more specific metrics scoping. + When unset, just the metricName will be used + to gather metrics. + properties: + matchExpressions: + description: matchExpressions is a list + of label selector requirements. The requirements + are ANDed. + items: + description: A label selector requirement + is a selector that contains values, + a key, and an operator that relates + the key and values. + properties: + key: + description: key is the label key + that the selector applies to. + type: string + operator: + description: operator represents a + key's relationship to a set of values. + Valid operators are In, NotIn, Exists + and DoesNotExist. + type: string + values: + description: values is an array of + string values. If the operator is + In or NotIn, the values array must + be non-empty. If the operator is + Exists or DoesNotExist, the values + array must be empty. This array + is replaced during a strategic merge + patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, + whose key field is "key", the operator + is "In", and the values array contains + only "value". The requirements are ANDed. + type: object + type: object + required: + - name + type: object + target: + description: target specifies the target value for + the given metric + properties: + averageUtilization: + description: averageUtilization is the target + value of the average of the resource metric + across all relevant pods, represented as a + percentage of the requested value of the resource + for the pods. Currently only valid for Resource + metric source type + format: int32 + type: integer + averageValue: + anyOf: + - type: integer + - type: string + description: averageValue is the target value + of the average of the metric across all relevant + pods (as a quantity) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: type represents whether the metric + type is Utilization, Value, or AverageValue + type: string + value: + anyOf: + - type: integer + - type: string + description: value is the target value of the + metric (as a quantity). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + required: + - type + type: object + required: + - metric + - target + type: object + resource: + description: resource refers to a resource metric (such + as those specified in requests and limits) known to + Kubernetes describing each pod in the current scale + target (e.g. CPU or memory). Such metrics are built + in to Kubernetes, and have special scaling options + on top of those available to normal per-pod metrics + using the "pods" source. + properties: + name: + description: name is the name of the resource in + question. + type: string + target: + description: target specifies the target value for + the given metric + properties: + averageUtilization: + description: averageUtilization is the target + value of the average of the resource metric + across all relevant pods, represented as a + percentage of the requested value of the resource + for the pods. Currently only valid for Resource + metric source type + format: int32 + type: integer + averageValue: + anyOf: + - type: integer + - type: string + description: averageValue is the target value + of the average of the metric across all relevant + pods (as a quantity) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: type represents whether the metric + type is Utilization, Value, or AverageValue + type: string + value: + anyOf: + - type: integer + - type: string + description: value is the target value of the + metric (as a quantity). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + required: + - type + type: object + required: + - name + - target + type: object + type: + description: 'type is the type of metric source. It + should be one of "ContainerResource", "External", + "Object", "Pods" or "Resource", each mapping to a + matching field in the object. Note: "ContainerResource" + type is available on when the feature-gate HPAContainerMetrics + is enabled' + type: string + required: + - type + type: object + type: object + type: array + minReplicas: + description: MinReplicas and MaxReplicas are consistent with those + in HPA. + format: int32 + type: integer + scaleTargetRef: + description: ScaleTargetRef defines the associated workload. + properties: + apiVersion: + description: API version of the referent + type: string + kind: + description: 'Kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds"' + type: string + name: + description: 'Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names' + type: string + required: + - kind + - name + type: object + required: + - maxReplicas + - scaleTargetRef + type: object + scaleStrategy: + default: Preview + description: ScaleStrategy defines whether to enable IHPA to scale + workloads. IHPA provides a preview mode. In preview mode, IHPA does + not modify the number of replicas of the workload. The default is + 'Preview'. + type: string + timeBounds: + description: TimeBounds supports dynamically adjusting HPA Replicas + in different time periods, providing capability similar to CronHPA. + items: + description: TimeBound supports adjusting HPA max/min replicas based + on the period and the time within the period. + properties: + bounds: + items: + description: Bound defines the max/min replicas of HPA configured + under the specified CronTab. + properties: + cronTab: + type: string + maxReplicas: + format: int32 + type: integer + minReplicas: + format: int32 + type: integer + required: + - cronTab + type: object + type: array + end: + format: date-time + type: string + start: + description: Start and End are the time period. + format: date-time + type: string + type: object + type: array + required: + - autoscaler + type: object + status: + description: Status represents the current information about a IntelligentHorizontalPodAutoscaler. + properties: + conditions: + description: Conditions record the creation or modification time of + IHPA's associated resource objects. + items: + description: IntelligentHorizontalPodAutoscalerCondition describes + the state of a IntelligentHorizontalPodAutoscaler at a certain + point. + properties: + lastTransitionTime: + description: lastTransitionTime is the last time the condition + transitioned from one status to another + format: date-time + type: string + message: + description: message is a human-readable explanation containing + details about the transition + type: string + reason: + description: reason is the reason for the condition's last transition. + type: string + status: + description: status is the status of the condition (True, False, + Unknown) + type: string + type: + description: type describes the current condition + type: string + required: + - status + - type + type: object + type: array + lastHorizontalPodAutoscalerUpdatedTime: + description: LastHorizontalPodAutoscalerUpdatedTime is the time when + the HPA replicas configuration was last refreshed by IHPA. + format: date-time + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/config/crd/bases/autoscaling.katalyst.kubewharf.io_virtualworkloads.yaml b/config/crd/bases/autoscaling.katalyst.kubewharf.io_virtualworkloads.yaml new file mode 100644 index 0000000..9a3a978 --- /dev/null +++ b/config/crd/bases/autoscaling.katalyst.kubewharf.io_virtualworkloads.yaml @@ -0,0 +1,66 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.0 + creationTimestamp: null + name: virtualworkloads.autoscaling.katalyst.kubewharf.io +spec: + group: autoscaling.katalyst.kubewharf.io + names: + kind: VirtualWorkload + listKind: VirtualWorkloadList + plural: virtualworkloads + singular: virtualworkload + scope: Namespaced + versions: + - name: v1alpha2 + schema: + openAPIV3Schema: + description: VirtualWorkload is the Schema for the virtualworkloads API VirtualWorkload + is used to support IHPA's Preview mode, that is, by providing a virtual + workload reference so that scaling will not affect the real workload. + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: VirtualWorkloadSpec defines the desired state of VirtualWorkload + properties: + replicas: + format: int32 + type: integer + required: + - replicas + type: object + status: + description: VirtualWorkloadStatus defines the observed state of VirtualWorkload + properties: + replicas: + format: int32 + type: integer + selector: + type: string + required: + - replicas + - selector + type: object + type: object + served: true + storage: true + subresources: + scale: + labelSelectorPath: .status.selector + specReplicasPath: .spec.replicas + statusReplicasPath: .status.replicas + status: {} diff --git a/pkg/apis/autoscaling/v1alpha2/ihpa.go b/pkg/apis/autoscaling/v1alpha2/ihpa.go new file mode 100644 index 0000000..a1afede --- /dev/null +++ b/pkg/apis/autoscaling/v1alpha2/ihpa.go @@ -0,0 +1,220 @@ +package v1alpha2 + +import ( + autoscalingv2 "k8s.io/api/autoscaling/v2" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/kubewharf/katalyst-api/pkg/apis/config/v1alpha1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:storageversion +// +kubebuilder:resource:shortName=ihpa + +// IntelligentHorizontalPodAutoscaler captures information about a IHPA object +type IntelligentHorizontalPodAutoscaler struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the behavior of a IntelligentHorizontalPodAutoscaler. + // +optional + Spec IntelligentHorizontalPodAutoscalerSpec `json:"spec,omitempty"` + + // Status represents the current information about a IntelligentHorizontalPodAutoscaler. + // +optional + Status IntelligentHorizontalPodAutoscalerStatus `json:"status,omitempty"` +} + +// IntelligentHorizontalPodAutoscalerSpec is the specification of the behavior of the autoscaler. +type IntelligentHorizontalPodAutoscalerSpec struct { + // Autoscaler defines the overall scaling configuration. + Autoscaler AutoscalerSpec `json:"autoscaler"` + + // ScaleStrategy defines whether to enable IHPA to scale workloads. + // IHPA provides a preview mode. In preview mode, IHPA does not modify the number of replicas of the workload. + // The default is 'Preview'. + // +kubebuilder:default:=Preview + ScaleStrategy ScaleStrategyType `json:"scaleStrategy,omitempty"` + + // AlgorithmConfig defines the algorithm configuration. If there is no configuration, + // the default configuration will be used. + AlgorithmConfig v1alpha1.AlgorithmConfig `json:"algorithmConfig,omitempty"` + + // TimeBounds supports dynamically adjusting HPA Replicas in different time periods, + // providing capability similar to CronHPA. + TimeBounds []TimeBound `json:"timeBounds,omitempty"` +} + +// IntelligentHorizontalPodAutoscalerStatus describes the runtime state of the autoscaler. +type IntelligentHorizontalPodAutoscalerStatus struct { + // LastHorizontalPodAutoscalerUpdatedTime is the time when the HPA replicas configuration was last refreshed by IHPA. + // +optional + LastHorizontalPodAutoscalerUpdatedTime *metav1.Time `json:"lastHorizontalPodAutoscalerUpdatedTime,omitempty"` + + // Conditions record the creation or modification time of IHPA's associated resource objects. + // +optional + // +patchMergeKey=type + // +patchStrategy=merge + Conditions []IntelligentHorizontalPodAutoscalerCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` +} + +// AutoscalerSpec defines the associated workload, the metrics used, and the scaling behavior. +type AutoscalerSpec struct { + // ScaleTargetRef defines the associated workload. + ScaleTargetRef autoscalingv2.CrossVersionObjectReference `json:"scaleTargetRef"` + + // Behavior defines scaling actions, which are transparently transmitted to HPA and implemented by HPA Controller. + // +optional + Behavior *autoscalingv2.HorizontalPodAutoscalerBehavior `json:"behavior,omitempty"` + + // Metrics define the metrics used for workload scaling. + // +optional + Metrics []MetricSpec `json:"metrics,omitempty"` + + // MinReplicas and MaxReplicas are consistent with those in HPA. + // +optional + MinReplicas *int32 `json:"minReplicas,omitempty"` + MaxReplicas int32 `json:"maxReplicas"` +} + +// MetricSpec is used to define a single metric of HPA. +// Metric is preferred. Only one of Metric and CustomMetric will take effect. +// The metrics source of Metric is API Server. +// The metrics source of CustomMetric is the resource portrait. +type MetricSpec struct { + Metric *autoscalingv2.MetricSpec `json:"metric,omitempty"` + CustomMetric *CustomMetricSpec `json:"customMetric,omitempty"` +} + +// CustomMetricSpec configures metrics derived from resource portraits. +type CustomMetricSpec struct { + // Identify defines the name of the resource metric + Identify corev1.ResourceName `json:"identify"` + + // Query defines the metrics query statement. + // There are preset templates for resource portraits, so the query statement can be empty. + Query string `json:"query,omitempty"` + + // Value represents the threshold, corresponding to the AverageValue in HPA. + Value *resource.Quantity `json:"value"` +} + +// TimeBound supports adjusting HPA max/min replicas based on the period and the time within the period. +type TimeBound struct { + // Start and End are the time period. + Start metav1.Time `json:"start,omitempty"` + End metav1.Time `json:"end,omitempty"` + Bounds []Bound `json:"bounds,omitempty"` +} + +// Bound defines the max/min replicas of HPA configured under the specified CronTab. +type Bound struct { + CronTab string `json:"cronTab"` + + MinReplicas *int32 `json:"minReplicas,omitempty"` + MaxReplicas *int32 `json:"maxReplicas,omitempty"` +} + +// ScaleStrategyType is the strategy of IHPA to scale workloads. +type ScaleStrategyType string + +const ( + Preview ScaleStrategyType = "Preview" + Auto ScaleStrategyType = "Auto" +) + +// IntelligentHorizontalPodAutoscalerConditionType are the valid conditions of IntelligentHorizontalPodAutoscaler +type IntelligentHorizontalPodAutoscalerConditionType string + +const ( + // ServiceProfileDescriptorSynced indicates that the SPD had been synced. + ServiceProfileDescriptorSynced IntelligentHorizontalPodAutoscalerConditionType = "SPDSynced" + // VirtualWorkloadSynced indicates that the VW had been synced. + VirtualWorkloadSynced IntelligentHorizontalPodAutoscalerConditionType = "VWCreated" + // HorizontalPodAutoscalerSynced indicates that the HPA had been synced. + HorizontalPodAutoscalerSynced IntelligentHorizontalPodAutoscalerConditionType = "HPASynced" +) + +// IntelligentHorizontalPodAutoscalerCondition describes the state of +// a IntelligentHorizontalPodAutoscaler at a certain point. +type IntelligentHorizontalPodAutoscalerCondition struct { + // type describes the current condition + Type IntelligentHorizontalPodAutoscalerConditionType `json:"type"` + // status is the status of the condition (True, False, Unknown) + Status corev1.ConditionStatus `json:"status"` + // lastTransitionTime is the last time the condition transitioned from + // one status to another + // +optional + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` + // reason is the reason for the condition's last transition. + // +optional + Reason string `json:"reason,omitempty"` + // message is a human-readable explanation containing details about + // the transition + // +optional + Message string `json:"message,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// IntelligentHorizontalPodAutoscalerList is a collection of IntelligentHorizontalPodAutoscaler objects. +type IntelligentHorizontalPodAutoscalerList struct { + metav1.TypeMeta `json:",inline"` + + // Standard list metadata + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + // items is the list of IntelligentHorizontalPodAutoscaler + Items []IntelligentHorizontalPodAutoscaler `json:"items"` +} + +// VirtualWorkloadSpec defines the desired state of VirtualWorkload +type VirtualWorkloadSpec struct { + Replicas int32 `json:"replicas"` +} + +// VirtualWorkloadStatus defines the observed state of VirtualWorkload +type VirtualWorkloadStatus struct { + Replicas int32 `json:"replicas"` + Selector string `json:"selector"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status +//+kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector + +// VirtualWorkload is the Schema for the virtualworkloads API +// VirtualWorkload is used to support IHPA's Preview mode, that is, by providing +// a virtual workload reference so that scaling will not affect the real workload. +type VirtualWorkload struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec VirtualWorkloadSpec `json:"spec,omitempty"` + Status VirtualWorkloadStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// VirtualWorkloadList contains a list of VirtualWorkload +type VirtualWorkloadList struct { + metav1.TypeMeta `json:",inline"` + + // Standard list metadata + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + // items is the list of VirtualWorkload + Items []VirtualWorkload `json:"items"` +} diff --git a/pkg/apis/autoscaling/v1alpha2/register.go b/pkg/apis/autoscaling/v1alpha2/register.go index da08418..52c26ab 100644 --- a/pkg/apis/autoscaling/v1alpha2/register.go +++ b/pkg/apis/autoscaling/v1alpha2/register.go @@ -32,7 +32,9 @@ var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha // ResourceName const is used to construct standard gvr const ( - ResourceNameKatalystVPA = "katalystverticalpodautoscalers" + ResourceNameKatalystVPA = "katalystverticalpodautoscalers" + ResourceNameIHPA = "intelligenthorizontalpodautoscalers" + ResourceNameVirtualWorkload = "virtualworkloads" ) // Resource takes an unqualified resource and returns a Group qualified GroupResource @@ -52,6 +54,10 @@ func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &KatalystVerticalPodAutoscaler{}, &KatalystVerticalPodAutoscalerList{}, + &IntelligentHorizontalPodAutoscaler{}, + &IntelligentHorizontalPodAutoscalerList{}, + &VirtualWorkload{}, + &VirtualWorkloadList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) diff --git a/pkg/apis/autoscaling/v1alpha2/types.go b/pkg/apis/autoscaling/v1alpha2/vpa.go similarity index 100% rename from pkg/apis/autoscaling/v1alpha2/types.go rename to pkg/apis/autoscaling/v1alpha2/vpa.go diff --git a/pkg/apis/autoscaling/v1alpha2/zz_generated.deepcopy.go b/pkg/apis/autoscaling/v1alpha2/zz_generated.deepcopy.go index dfb106b..2a05975 100644 --- a/pkg/apis/autoscaling/v1alpha2/zz_generated.deepcopy.go +++ b/pkg/apis/autoscaling/v1alpha2/zz_generated.deepcopy.go @@ -22,9 +22,221 @@ limitations under the License. package v1alpha2 import ( + v2 "k8s.io/api/autoscaling/v2" runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AutoscalerSpec) DeepCopyInto(out *AutoscalerSpec) { + *out = *in + out.ScaleTargetRef = in.ScaleTargetRef + if in.Behavior != nil { + in, out := &in.Behavior, &out.Behavior + *out = new(v2.HorizontalPodAutoscalerBehavior) + (*in).DeepCopyInto(*out) + } + if in.Metrics != nil { + in, out := &in.Metrics, &out.Metrics + *out = make([]MetricSpec, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.MinReplicas != nil { + in, out := &in.MinReplicas, &out.MinReplicas + *out = new(int32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AutoscalerSpec. +func (in *AutoscalerSpec) DeepCopy() *AutoscalerSpec { + if in == nil { + return nil + } + out := new(AutoscalerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Bound) DeepCopyInto(out *Bound) { + *out = *in + if in.MinReplicas != nil { + in, out := &in.MinReplicas, &out.MinReplicas + *out = new(int32) + **out = **in + } + if in.MaxReplicas != nil { + in, out := &in.MaxReplicas, &out.MaxReplicas + *out = new(int32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Bound. +func (in *Bound) DeepCopy() *Bound { + if in == nil { + return nil + } + out := new(Bound) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CustomMetricSpec) DeepCopyInto(out *CustomMetricSpec) { + *out = *in + if in.Value != nil { + in, out := &in.Value, &out.Value + x := (*in).DeepCopy() + *out = &x + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomMetricSpec. +func (in *CustomMetricSpec) DeepCopy() *CustomMetricSpec { + if in == nil { + return nil + } + out := new(CustomMetricSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IntelligentHorizontalPodAutoscaler) DeepCopyInto(out *IntelligentHorizontalPodAutoscaler) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IntelligentHorizontalPodAutoscaler. +func (in *IntelligentHorizontalPodAutoscaler) DeepCopy() *IntelligentHorizontalPodAutoscaler { + if in == nil { + return nil + } + out := new(IntelligentHorizontalPodAutoscaler) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IntelligentHorizontalPodAutoscaler) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IntelligentHorizontalPodAutoscalerCondition) DeepCopyInto(out *IntelligentHorizontalPodAutoscalerCondition) { + *out = *in + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IntelligentHorizontalPodAutoscalerCondition. +func (in *IntelligentHorizontalPodAutoscalerCondition) DeepCopy() *IntelligentHorizontalPodAutoscalerCondition { + if in == nil { + return nil + } + out := new(IntelligentHorizontalPodAutoscalerCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IntelligentHorizontalPodAutoscalerList) DeepCopyInto(out *IntelligentHorizontalPodAutoscalerList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]IntelligentHorizontalPodAutoscaler, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IntelligentHorizontalPodAutoscalerList. +func (in *IntelligentHorizontalPodAutoscalerList) DeepCopy() *IntelligentHorizontalPodAutoscalerList { + if in == nil { + return nil + } + out := new(IntelligentHorizontalPodAutoscalerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IntelligentHorizontalPodAutoscalerList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IntelligentHorizontalPodAutoscalerSpec) DeepCopyInto(out *IntelligentHorizontalPodAutoscalerSpec) { + *out = *in + in.Autoscaler.DeepCopyInto(&out.Autoscaler) + in.AlgorithmConfig.DeepCopyInto(&out.AlgorithmConfig) + if in.TimeBounds != nil { + in, out := &in.TimeBounds, &out.TimeBounds + *out = make([]TimeBound, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IntelligentHorizontalPodAutoscalerSpec. +func (in *IntelligentHorizontalPodAutoscalerSpec) DeepCopy() *IntelligentHorizontalPodAutoscalerSpec { + if in == nil { + return nil + } + out := new(IntelligentHorizontalPodAutoscalerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IntelligentHorizontalPodAutoscalerStatus) DeepCopyInto(out *IntelligentHorizontalPodAutoscalerStatus) { + *out = *in + if in.LastHorizontalPodAutoscalerUpdatedTime != nil { + in, out := &in.LastHorizontalPodAutoscalerUpdatedTime, &out.LastHorizontalPodAutoscalerUpdatedTime + *out = (*in).DeepCopy() + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]IntelligentHorizontalPodAutoscalerCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IntelligentHorizontalPodAutoscalerStatus. +func (in *IntelligentHorizontalPodAutoscalerStatus) DeepCopy() *IntelligentHorizontalPodAutoscalerStatus { + if in == nil { + return nil + } + out := new(IntelligentHorizontalPodAutoscalerStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KatalystVerticalPodAutoscaler) DeepCopyInto(out *KatalystVerticalPodAutoscaler) { *out = *in @@ -129,6 +341,32 @@ func (in *KatalystVerticalPodAutoscalerStatus) DeepCopy() *KatalystVerticalPodAu return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricSpec) DeepCopyInto(out *MetricSpec) { + *out = *in + if in.Metric != nil { + in, out := &in.Metric, &out.Metric + *out = new(v2.MetricSpec) + (*in).DeepCopyInto(*out) + } + if in.CustomMetric != nil { + in, out := &in.CustomMetric, &out.CustomMetric + *out = new(CustomMetricSpec) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricSpec. +func (in *MetricSpec) DeepCopy() *MetricSpec { + if in == nil { + return nil + } + out := new(MetricSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PodUpdatePolicy) DeepCopyInto(out *PodUpdatePolicy) { *out = *in @@ -145,6 +383,31 @@ func (in *PodUpdatePolicy) DeepCopy() *PodUpdatePolicy { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TimeBound) DeepCopyInto(out *TimeBound) { + *out = *in + in.Start.DeepCopyInto(&out.Start) + in.End.DeepCopyInto(&out.End) + if in.Bounds != nil { + in, out := &in.Bounds, &out.Bounds + *out = make([]Bound, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TimeBound. +func (in *TimeBound) DeepCopy() *TimeBound { + if in == nil { + return nil + } + out := new(TimeBound) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VerticalPodAutoscalerCondition) DeepCopyInto(out *VerticalPodAutoscalerCondition) { *out = *in @@ -161,3 +424,96 @@ func (in *VerticalPodAutoscalerCondition) DeepCopy() *VerticalPodAutoscalerCondi in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualWorkload) DeepCopyInto(out *VirtualWorkload) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualWorkload. +func (in *VirtualWorkload) DeepCopy() *VirtualWorkload { + if in == nil { + return nil + } + out := new(VirtualWorkload) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VirtualWorkload) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualWorkloadList) DeepCopyInto(out *VirtualWorkloadList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]VirtualWorkload, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualWorkloadList. +func (in *VirtualWorkloadList) DeepCopy() *VirtualWorkloadList { + if in == nil { + return nil + } + out := new(VirtualWorkloadList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VirtualWorkloadList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualWorkloadSpec) DeepCopyInto(out *VirtualWorkloadSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualWorkloadSpec. +func (in *VirtualWorkloadSpec) DeepCopy() *VirtualWorkloadSpec { + if in == nil { + return nil + } + out := new(VirtualWorkloadSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualWorkloadStatus) DeepCopyInto(out *VirtualWorkloadStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualWorkloadStatus. +func (in *VirtualWorkloadStatus) DeepCopy() *VirtualWorkloadStatus { + if in == nil { + return nil + } + out := new(VirtualWorkloadStatus) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 0f7d311..9aaf89e 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -51,14 +51,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index 17ad6fb..ffa9cdb 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -51,14 +51,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/autoscaling_client.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/autoscaling_client.go index cfef426..42ad743 100644 --- a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/autoscaling_client.go +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/autoscaling_client.go @@ -28,7 +28,9 @@ import ( type AutoscalingV1alpha2Interface interface { RESTClient() rest.Interface + IntelligentHorizontalPodAutoscalersGetter KatalystVerticalPodAutoscalersGetter + VirtualWorkloadsGetter } // AutoscalingV1alpha2Client is used to interact with features provided by the autoscaling.katalyst.kubewharf.io group. @@ -36,10 +38,18 @@ type AutoscalingV1alpha2Client struct { restClient rest.Interface } +func (c *AutoscalingV1alpha2Client) IntelligentHorizontalPodAutoscalers(namespace string) IntelligentHorizontalPodAutoscalerInterface { + return newIntelligentHorizontalPodAutoscalers(c, namespace) +} + func (c *AutoscalingV1alpha2Client) KatalystVerticalPodAutoscalers(namespace string) KatalystVerticalPodAutoscalerInterface { return newKatalystVerticalPodAutoscalers(c, namespace) } +func (c *AutoscalingV1alpha2Client) VirtualWorkloads(namespace string) VirtualWorkloadInterface { + return newVirtualWorkloads(c, namespace) +} + // NewForConfig creates a new AutoscalingV1alpha2Client for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). diff --git a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/fake/fake_autoscaling_client.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/fake/fake_autoscaling_client.go index 43f4c1c..2cfc46f 100644 --- a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/fake/fake_autoscaling_client.go +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/fake/fake_autoscaling_client.go @@ -28,10 +28,18 @@ type FakeAutoscalingV1alpha2 struct { *testing.Fake } +func (c *FakeAutoscalingV1alpha2) IntelligentHorizontalPodAutoscalers(namespace string) v1alpha2.IntelligentHorizontalPodAutoscalerInterface { + return &FakeIntelligentHorizontalPodAutoscalers{c, namespace} +} + func (c *FakeAutoscalingV1alpha2) KatalystVerticalPodAutoscalers(namespace string) v1alpha2.KatalystVerticalPodAutoscalerInterface { return &FakeKatalystVerticalPodAutoscalers{c, namespace} } +func (c *FakeAutoscalingV1alpha2) VirtualWorkloads(namespace string) v1alpha2.VirtualWorkloadInterface { + return &FakeVirtualWorkloads{c, namespace} +} + // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. func (c *FakeAutoscalingV1alpha2) RESTClient() rest.Interface { diff --git a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/fake/fake_intelligenthorizontalpodautoscaler.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/fake/fake_intelligenthorizontalpodautoscaler.go new file mode 100644 index 0000000..591b131 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/fake/fake_intelligenthorizontalpodautoscaler.go @@ -0,0 +1,142 @@ +/* +Copyright 2022 The Katalyst 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha2 "github.com/kubewharf/katalyst-api/pkg/apis/autoscaling/v1alpha2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeIntelligentHorizontalPodAutoscalers implements IntelligentHorizontalPodAutoscalerInterface +type FakeIntelligentHorizontalPodAutoscalers struct { + Fake *FakeAutoscalingV1alpha2 + ns string +} + +var intelligenthorizontalpodautoscalersResource = schema.GroupVersionResource{Group: "autoscaling.katalyst.kubewharf.io", Version: "v1alpha2", Resource: "intelligenthorizontalpodautoscalers"} + +var intelligenthorizontalpodautoscalersKind = schema.GroupVersionKind{Group: "autoscaling.katalyst.kubewharf.io", Version: "v1alpha2", Kind: "IntelligentHorizontalPodAutoscaler"} + +// Get takes name of the intelligentHorizontalPodAutoscaler, and returns the corresponding intelligentHorizontalPodAutoscaler object, and an error if there is any. +func (c *FakeIntelligentHorizontalPodAutoscalers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.IntelligentHorizontalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(intelligenthorizontalpodautoscalersResource, c.ns, name), &v1alpha2.IntelligentHorizontalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.IntelligentHorizontalPodAutoscaler), err +} + +// List takes label and field selectors, and returns the list of IntelligentHorizontalPodAutoscalers that match those selectors. +func (c *FakeIntelligentHorizontalPodAutoscalers) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.IntelligentHorizontalPodAutoscalerList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(intelligenthorizontalpodautoscalersResource, intelligenthorizontalpodautoscalersKind, c.ns, opts), &v1alpha2.IntelligentHorizontalPodAutoscalerList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.IntelligentHorizontalPodAutoscalerList{ListMeta: obj.(*v1alpha2.IntelligentHorizontalPodAutoscalerList).ListMeta} + for _, item := range obj.(*v1alpha2.IntelligentHorizontalPodAutoscalerList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested intelligentHorizontalPodAutoscalers. +func (c *FakeIntelligentHorizontalPodAutoscalers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(intelligenthorizontalpodautoscalersResource, c.ns, opts)) + +} + +// Create takes the representation of a intelligentHorizontalPodAutoscaler and creates it. Returns the server's representation of the intelligentHorizontalPodAutoscaler, and an error, if there is any. +func (c *FakeIntelligentHorizontalPodAutoscalers) Create(ctx context.Context, intelligentHorizontalPodAutoscaler *v1alpha2.IntelligentHorizontalPodAutoscaler, opts v1.CreateOptions) (result *v1alpha2.IntelligentHorizontalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(intelligenthorizontalpodautoscalersResource, c.ns, intelligentHorizontalPodAutoscaler), &v1alpha2.IntelligentHorizontalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.IntelligentHorizontalPodAutoscaler), err +} + +// Update takes the representation of a intelligentHorizontalPodAutoscaler and updates it. Returns the server's representation of the intelligentHorizontalPodAutoscaler, and an error, if there is any. +func (c *FakeIntelligentHorizontalPodAutoscalers) Update(ctx context.Context, intelligentHorizontalPodAutoscaler *v1alpha2.IntelligentHorizontalPodAutoscaler, opts v1.UpdateOptions) (result *v1alpha2.IntelligentHorizontalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(intelligenthorizontalpodautoscalersResource, c.ns, intelligentHorizontalPodAutoscaler), &v1alpha2.IntelligentHorizontalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.IntelligentHorizontalPodAutoscaler), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeIntelligentHorizontalPodAutoscalers) UpdateStatus(ctx context.Context, intelligentHorizontalPodAutoscaler *v1alpha2.IntelligentHorizontalPodAutoscaler, opts v1.UpdateOptions) (*v1alpha2.IntelligentHorizontalPodAutoscaler, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(intelligenthorizontalpodautoscalersResource, "status", c.ns, intelligentHorizontalPodAutoscaler), &v1alpha2.IntelligentHorizontalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.IntelligentHorizontalPodAutoscaler), err +} + +// Delete takes name of the intelligentHorizontalPodAutoscaler and deletes it. Returns an error if one occurs. +func (c *FakeIntelligentHorizontalPodAutoscalers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(intelligenthorizontalpodautoscalersResource, c.ns, name, opts), &v1alpha2.IntelligentHorizontalPodAutoscaler{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeIntelligentHorizontalPodAutoscalers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(intelligenthorizontalpodautoscalersResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha2.IntelligentHorizontalPodAutoscalerList{}) + return err +} + +// Patch applies the patch and returns the patched intelligentHorizontalPodAutoscaler. +func (c *FakeIntelligentHorizontalPodAutoscalers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.IntelligentHorizontalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(intelligenthorizontalpodautoscalersResource, c.ns, name, pt, data, subresources...), &v1alpha2.IntelligentHorizontalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.IntelligentHorizontalPodAutoscaler), err +} diff --git a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/fake/fake_virtualworkload.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/fake/fake_virtualworkload.go new file mode 100644 index 0000000..0c94992 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/fake/fake_virtualworkload.go @@ -0,0 +1,142 @@ +/* +Copyright 2022 The Katalyst 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha2 "github.com/kubewharf/katalyst-api/pkg/apis/autoscaling/v1alpha2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeVirtualWorkloads implements VirtualWorkloadInterface +type FakeVirtualWorkloads struct { + Fake *FakeAutoscalingV1alpha2 + ns string +} + +var virtualworkloadsResource = schema.GroupVersionResource{Group: "autoscaling.katalyst.kubewharf.io", Version: "v1alpha2", Resource: "virtualworkloads"} + +var virtualworkloadsKind = schema.GroupVersionKind{Group: "autoscaling.katalyst.kubewharf.io", Version: "v1alpha2", Kind: "VirtualWorkload"} + +// Get takes name of the virtualWorkload, and returns the corresponding virtualWorkload object, and an error if there is any. +func (c *FakeVirtualWorkloads) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.VirtualWorkload, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(virtualworkloadsResource, c.ns, name), &v1alpha2.VirtualWorkload{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.VirtualWorkload), err +} + +// List takes label and field selectors, and returns the list of VirtualWorkloads that match those selectors. +func (c *FakeVirtualWorkloads) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.VirtualWorkloadList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(virtualworkloadsResource, virtualworkloadsKind, c.ns, opts), &v1alpha2.VirtualWorkloadList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.VirtualWorkloadList{ListMeta: obj.(*v1alpha2.VirtualWorkloadList).ListMeta} + for _, item := range obj.(*v1alpha2.VirtualWorkloadList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested virtualWorkloads. +func (c *FakeVirtualWorkloads) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(virtualworkloadsResource, c.ns, opts)) + +} + +// Create takes the representation of a virtualWorkload and creates it. Returns the server's representation of the virtualWorkload, and an error, if there is any. +func (c *FakeVirtualWorkloads) Create(ctx context.Context, virtualWorkload *v1alpha2.VirtualWorkload, opts v1.CreateOptions) (result *v1alpha2.VirtualWorkload, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(virtualworkloadsResource, c.ns, virtualWorkload), &v1alpha2.VirtualWorkload{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.VirtualWorkload), err +} + +// Update takes the representation of a virtualWorkload and updates it. Returns the server's representation of the virtualWorkload, and an error, if there is any. +func (c *FakeVirtualWorkloads) Update(ctx context.Context, virtualWorkload *v1alpha2.VirtualWorkload, opts v1.UpdateOptions) (result *v1alpha2.VirtualWorkload, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(virtualworkloadsResource, c.ns, virtualWorkload), &v1alpha2.VirtualWorkload{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.VirtualWorkload), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeVirtualWorkloads) UpdateStatus(ctx context.Context, virtualWorkload *v1alpha2.VirtualWorkload, opts v1.UpdateOptions) (*v1alpha2.VirtualWorkload, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(virtualworkloadsResource, "status", c.ns, virtualWorkload), &v1alpha2.VirtualWorkload{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.VirtualWorkload), err +} + +// Delete takes name of the virtualWorkload and deletes it. Returns an error if one occurs. +func (c *FakeVirtualWorkloads) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(virtualworkloadsResource, c.ns, name, opts), &v1alpha2.VirtualWorkload{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeVirtualWorkloads) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(virtualworkloadsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha2.VirtualWorkloadList{}) + return err +} + +// Patch applies the patch and returns the patched virtualWorkload. +func (c *FakeVirtualWorkloads) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.VirtualWorkload, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(virtualworkloadsResource, c.ns, name, pt, data, subresources...), &v1alpha2.VirtualWorkload{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.VirtualWorkload), err +} diff --git a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/generated_expansion.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/generated_expansion.go index a6d5ef6..2b6ee8c 100644 --- a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/generated_expansion.go @@ -18,4 +18,8 @@ limitations under the License. package v1alpha2 +type IntelligentHorizontalPodAutoscalerExpansion interface{} + type KatalystVerticalPodAutoscalerExpansion interface{} + +type VirtualWorkloadExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/intelligenthorizontalpodautoscaler.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/intelligenthorizontalpodautoscaler.go new file mode 100644 index 0000000..b04a262 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/intelligenthorizontalpodautoscaler.go @@ -0,0 +1,195 @@ +/* +Copyright 2022 The Katalyst 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + "context" + "time" + + v1alpha2 "github.com/kubewharf/katalyst-api/pkg/apis/autoscaling/v1alpha2" + scheme "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// IntelligentHorizontalPodAutoscalersGetter has a method to return a IntelligentHorizontalPodAutoscalerInterface. +// A group's client should implement this interface. +type IntelligentHorizontalPodAutoscalersGetter interface { + IntelligentHorizontalPodAutoscalers(namespace string) IntelligentHorizontalPodAutoscalerInterface +} + +// IntelligentHorizontalPodAutoscalerInterface has methods to work with IntelligentHorizontalPodAutoscaler resources. +type IntelligentHorizontalPodAutoscalerInterface interface { + Create(ctx context.Context, intelligentHorizontalPodAutoscaler *v1alpha2.IntelligentHorizontalPodAutoscaler, opts v1.CreateOptions) (*v1alpha2.IntelligentHorizontalPodAutoscaler, error) + Update(ctx context.Context, intelligentHorizontalPodAutoscaler *v1alpha2.IntelligentHorizontalPodAutoscaler, opts v1.UpdateOptions) (*v1alpha2.IntelligentHorizontalPodAutoscaler, error) + UpdateStatus(ctx context.Context, intelligentHorizontalPodAutoscaler *v1alpha2.IntelligentHorizontalPodAutoscaler, opts v1.UpdateOptions) (*v1alpha2.IntelligentHorizontalPodAutoscaler, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha2.IntelligentHorizontalPodAutoscaler, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.IntelligentHorizontalPodAutoscalerList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.IntelligentHorizontalPodAutoscaler, err error) + IntelligentHorizontalPodAutoscalerExpansion +} + +// intelligentHorizontalPodAutoscalers implements IntelligentHorizontalPodAutoscalerInterface +type intelligentHorizontalPodAutoscalers struct { + client rest.Interface + ns string +} + +// newIntelligentHorizontalPodAutoscalers returns a IntelligentHorizontalPodAutoscalers +func newIntelligentHorizontalPodAutoscalers(c *AutoscalingV1alpha2Client, namespace string) *intelligentHorizontalPodAutoscalers { + return &intelligentHorizontalPodAutoscalers{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the intelligentHorizontalPodAutoscaler, and returns the corresponding intelligentHorizontalPodAutoscaler object, and an error if there is any. +func (c *intelligentHorizontalPodAutoscalers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.IntelligentHorizontalPodAutoscaler, err error) { + result = &v1alpha2.IntelligentHorizontalPodAutoscaler{} + err = c.client.Get(). + Namespace(c.ns). + Resource("intelligenthorizontalpodautoscalers"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of IntelligentHorizontalPodAutoscalers that match those selectors. +func (c *intelligentHorizontalPodAutoscalers) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.IntelligentHorizontalPodAutoscalerList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha2.IntelligentHorizontalPodAutoscalerList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("intelligenthorizontalpodautoscalers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested intelligentHorizontalPodAutoscalers. +func (c *intelligentHorizontalPodAutoscalers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("intelligenthorizontalpodautoscalers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a intelligentHorizontalPodAutoscaler and creates it. Returns the server's representation of the intelligentHorizontalPodAutoscaler, and an error, if there is any. +func (c *intelligentHorizontalPodAutoscalers) Create(ctx context.Context, intelligentHorizontalPodAutoscaler *v1alpha2.IntelligentHorizontalPodAutoscaler, opts v1.CreateOptions) (result *v1alpha2.IntelligentHorizontalPodAutoscaler, err error) { + result = &v1alpha2.IntelligentHorizontalPodAutoscaler{} + err = c.client.Post(). + Namespace(c.ns). + Resource("intelligenthorizontalpodautoscalers"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(intelligentHorizontalPodAutoscaler). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a intelligentHorizontalPodAutoscaler and updates it. Returns the server's representation of the intelligentHorizontalPodAutoscaler, and an error, if there is any. +func (c *intelligentHorizontalPodAutoscalers) Update(ctx context.Context, intelligentHorizontalPodAutoscaler *v1alpha2.IntelligentHorizontalPodAutoscaler, opts v1.UpdateOptions) (result *v1alpha2.IntelligentHorizontalPodAutoscaler, err error) { + result = &v1alpha2.IntelligentHorizontalPodAutoscaler{} + err = c.client.Put(). + Namespace(c.ns). + Resource("intelligenthorizontalpodautoscalers"). + Name(intelligentHorizontalPodAutoscaler.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(intelligentHorizontalPodAutoscaler). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *intelligentHorizontalPodAutoscalers) UpdateStatus(ctx context.Context, intelligentHorizontalPodAutoscaler *v1alpha2.IntelligentHorizontalPodAutoscaler, opts v1.UpdateOptions) (result *v1alpha2.IntelligentHorizontalPodAutoscaler, err error) { + result = &v1alpha2.IntelligentHorizontalPodAutoscaler{} + err = c.client.Put(). + Namespace(c.ns). + Resource("intelligenthorizontalpodautoscalers"). + Name(intelligentHorizontalPodAutoscaler.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(intelligentHorizontalPodAutoscaler). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the intelligentHorizontalPodAutoscaler and deletes it. Returns an error if one occurs. +func (c *intelligentHorizontalPodAutoscalers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("intelligenthorizontalpodautoscalers"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *intelligentHorizontalPodAutoscalers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("intelligenthorizontalpodautoscalers"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched intelligentHorizontalPodAutoscaler. +func (c *intelligentHorizontalPodAutoscalers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.IntelligentHorizontalPodAutoscaler, err error) { + result = &v1alpha2.IntelligentHorizontalPodAutoscaler{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("intelligenthorizontalpodautoscalers"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/virtualworkload.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/virtualworkload.go new file mode 100644 index 0000000..1046167 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha2/virtualworkload.go @@ -0,0 +1,195 @@ +/* +Copyright 2022 The Katalyst 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + "context" + "time" + + v1alpha2 "github.com/kubewharf/katalyst-api/pkg/apis/autoscaling/v1alpha2" + scheme "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// VirtualWorkloadsGetter has a method to return a VirtualWorkloadInterface. +// A group's client should implement this interface. +type VirtualWorkloadsGetter interface { + VirtualWorkloads(namespace string) VirtualWorkloadInterface +} + +// VirtualWorkloadInterface has methods to work with VirtualWorkload resources. +type VirtualWorkloadInterface interface { + Create(ctx context.Context, virtualWorkload *v1alpha2.VirtualWorkload, opts v1.CreateOptions) (*v1alpha2.VirtualWorkload, error) + Update(ctx context.Context, virtualWorkload *v1alpha2.VirtualWorkload, opts v1.UpdateOptions) (*v1alpha2.VirtualWorkload, error) + UpdateStatus(ctx context.Context, virtualWorkload *v1alpha2.VirtualWorkload, opts v1.UpdateOptions) (*v1alpha2.VirtualWorkload, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha2.VirtualWorkload, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.VirtualWorkloadList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.VirtualWorkload, err error) + VirtualWorkloadExpansion +} + +// virtualWorkloads implements VirtualWorkloadInterface +type virtualWorkloads struct { + client rest.Interface + ns string +} + +// newVirtualWorkloads returns a VirtualWorkloads +func newVirtualWorkloads(c *AutoscalingV1alpha2Client, namespace string) *virtualWorkloads { + return &virtualWorkloads{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the virtualWorkload, and returns the corresponding virtualWorkload object, and an error if there is any. +func (c *virtualWorkloads) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.VirtualWorkload, err error) { + result = &v1alpha2.VirtualWorkload{} + err = c.client.Get(). + Namespace(c.ns). + Resource("virtualworkloads"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of VirtualWorkloads that match those selectors. +func (c *virtualWorkloads) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.VirtualWorkloadList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha2.VirtualWorkloadList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("virtualworkloads"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested virtualWorkloads. +func (c *virtualWorkloads) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("virtualworkloads"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a virtualWorkload and creates it. Returns the server's representation of the virtualWorkload, and an error, if there is any. +func (c *virtualWorkloads) Create(ctx context.Context, virtualWorkload *v1alpha2.VirtualWorkload, opts v1.CreateOptions) (result *v1alpha2.VirtualWorkload, err error) { + result = &v1alpha2.VirtualWorkload{} + err = c.client.Post(). + Namespace(c.ns). + Resource("virtualworkloads"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(virtualWorkload). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a virtualWorkload and updates it. Returns the server's representation of the virtualWorkload, and an error, if there is any. +func (c *virtualWorkloads) Update(ctx context.Context, virtualWorkload *v1alpha2.VirtualWorkload, opts v1.UpdateOptions) (result *v1alpha2.VirtualWorkload, err error) { + result = &v1alpha2.VirtualWorkload{} + err = c.client.Put(). + Namespace(c.ns). + Resource("virtualworkloads"). + Name(virtualWorkload.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(virtualWorkload). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *virtualWorkloads) UpdateStatus(ctx context.Context, virtualWorkload *v1alpha2.VirtualWorkload, opts v1.UpdateOptions) (result *v1alpha2.VirtualWorkload, err error) { + result = &v1alpha2.VirtualWorkload{} + err = c.client.Put(). + Namespace(c.ns). + Resource("virtualworkloads"). + Name(virtualWorkload.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(virtualWorkload). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the virtualWorkload and deletes it. Returns an error if one occurs. +func (c *virtualWorkloads) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("virtualworkloads"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *virtualWorkloads) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("virtualworkloads"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched virtualWorkload. +func (c *virtualWorkloads) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.VirtualWorkload, err error) { + result = &v1alpha2.VirtualWorkload{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("virtualworkloads"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/informers/externalversions/autoscaling/v1alpha2/intelligenthorizontalpodautoscaler.go b/pkg/client/informers/externalversions/autoscaling/v1alpha2/intelligenthorizontalpodautoscaler.go new file mode 100644 index 0000000..440b9a9 --- /dev/null +++ b/pkg/client/informers/externalversions/autoscaling/v1alpha2/intelligenthorizontalpodautoscaler.go @@ -0,0 +1,90 @@ +/* +Copyright 2022 The Katalyst 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. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + "context" + time "time" + + autoscalingv1alpha2 "github.com/kubewharf/katalyst-api/pkg/apis/autoscaling/v1alpha2" + versioned "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned" + internalinterfaces "github.com/kubewharf/katalyst-api/pkg/client/informers/externalversions/internalinterfaces" + v1alpha2 "github.com/kubewharf/katalyst-api/pkg/client/listers/autoscaling/v1alpha2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// IntelligentHorizontalPodAutoscalerInformer provides access to a shared informer and lister for +// IntelligentHorizontalPodAutoscalers. +type IntelligentHorizontalPodAutoscalerInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha2.IntelligentHorizontalPodAutoscalerLister +} + +type intelligentHorizontalPodAutoscalerInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewIntelligentHorizontalPodAutoscalerInformer constructs a new informer for IntelligentHorizontalPodAutoscaler type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewIntelligentHorizontalPodAutoscalerInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredIntelligentHorizontalPodAutoscalerInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredIntelligentHorizontalPodAutoscalerInformer constructs a new informer for IntelligentHorizontalPodAutoscaler type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredIntelligentHorizontalPodAutoscalerInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AutoscalingV1alpha2().IntelligentHorizontalPodAutoscalers(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AutoscalingV1alpha2().IntelligentHorizontalPodAutoscalers(namespace).Watch(context.TODO(), options) + }, + }, + &autoscalingv1alpha2.IntelligentHorizontalPodAutoscaler{}, + resyncPeriod, + indexers, + ) +} + +func (f *intelligentHorizontalPodAutoscalerInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredIntelligentHorizontalPodAutoscalerInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *intelligentHorizontalPodAutoscalerInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&autoscalingv1alpha2.IntelligentHorizontalPodAutoscaler{}, f.defaultInformer) +} + +func (f *intelligentHorizontalPodAutoscalerInformer) Lister() v1alpha2.IntelligentHorizontalPodAutoscalerLister { + return v1alpha2.NewIntelligentHorizontalPodAutoscalerLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/autoscaling/v1alpha2/interface.go b/pkg/client/informers/externalversions/autoscaling/v1alpha2/interface.go index 4424795..38e822f 100644 --- a/pkg/client/informers/externalversions/autoscaling/v1alpha2/interface.go +++ b/pkg/client/informers/externalversions/autoscaling/v1alpha2/interface.go @@ -24,8 +24,12 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { + // IntelligentHorizontalPodAutoscalers returns a IntelligentHorizontalPodAutoscalerInformer. + IntelligentHorizontalPodAutoscalers() IntelligentHorizontalPodAutoscalerInformer // KatalystVerticalPodAutoscalers returns a KatalystVerticalPodAutoscalerInformer. KatalystVerticalPodAutoscalers() KatalystVerticalPodAutoscalerInformer + // VirtualWorkloads returns a VirtualWorkloadInformer. + VirtualWorkloads() VirtualWorkloadInformer } type version struct { @@ -39,7 +43,17 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } +// IntelligentHorizontalPodAutoscalers returns a IntelligentHorizontalPodAutoscalerInformer. +func (v *version) IntelligentHorizontalPodAutoscalers() IntelligentHorizontalPodAutoscalerInformer { + return &intelligentHorizontalPodAutoscalerInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // KatalystVerticalPodAutoscalers returns a KatalystVerticalPodAutoscalerInformer. func (v *version) KatalystVerticalPodAutoscalers() KatalystVerticalPodAutoscalerInformer { return &katalystVerticalPodAutoscalerInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } + +// VirtualWorkloads returns a VirtualWorkloadInformer. +func (v *version) VirtualWorkloads() VirtualWorkloadInformer { + return &virtualWorkloadInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/autoscaling/v1alpha2/virtualworkload.go b/pkg/client/informers/externalversions/autoscaling/v1alpha2/virtualworkload.go new file mode 100644 index 0000000..3f3928f --- /dev/null +++ b/pkg/client/informers/externalversions/autoscaling/v1alpha2/virtualworkload.go @@ -0,0 +1,90 @@ +/* +Copyright 2022 The Katalyst 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. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + "context" + time "time" + + autoscalingv1alpha2 "github.com/kubewharf/katalyst-api/pkg/apis/autoscaling/v1alpha2" + versioned "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned" + internalinterfaces "github.com/kubewharf/katalyst-api/pkg/client/informers/externalversions/internalinterfaces" + v1alpha2 "github.com/kubewharf/katalyst-api/pkg/client/listers/autoscaling/v1alpha2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// VirtualWorkloadInformer provides access to a shared informer and lister for +// VirtualWorkloads. +type VirtualWorkloadInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha2.VirtualWorkloadLister +} + +type virtualWorkloadInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewVirtualWorkloadInformer constructs a new informer for VirtualWorkload type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewVirtualWorkloadInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredVirtualWorkloadInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredVirtualWorkloadInformer constructs a new informer for VirtualWorkload type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredVirtualWorkloadInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AutoscalingV1alpha2().VirtualWorkloads(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AutoscalingV1alpha2().VirtualWorkloads(namespace).Watch(context.TODO(), options) + }, + }, + &autoscalingv1alpha2.VirtualWorkload{}, + resyncPeriod, + indexers, + ) +} + +func (f *virtualWorkloadInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredVirtualWorkloadInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *virtualWorkloadInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&autoscalingv1alpha2.VirtualWorkload{}, f.defaultInformer) +} + +func (f *virtualWorkloadInformer) Lister() v1alpha2.VirtualWorkloadLister { + return v1alpha2.NewVirtualWorkloadLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 969bb67..aab8401 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -66,8 +66,12 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V1alpha1().VerticalPodAutoscalerRecommendations().Informer()}, nil // Group=autoscaling.katalyst.kubewharf.io, Version=v1alpha2 + case v1alpha2.SchemeGroupVersion.WithResource("intelligenthorizontalpodautoscalers"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V1alpha2().IntelligentHorizontalPodAutoscalers().Informer()}, nil case v1alpha2.SchemeGroupVersion.WithResource("katalystverticalpodautoscalers"): return &genericInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V1alpha2().KatalystVerticalPodAutoscalers().Informer()}, nil + case v1alpha2.SchemeGroupVersion.WithResource("virtualworkloads"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V1alpha2().VirtualWorkloads().Informer()}, nil // Group=config.katalyst.kubewharf.io, Version=v1alpha1 case configv1alpha1.SchemeGroupVersion.WithResource("customnodeconfigs"): diff --git a/pkg/client/listers/autoscaling/v1alpha2/expansion_generated.go b/pkg/client/listers/autoscaling/v1alpha2/expansion_generated.go index 4cba354..6c53a7d 100644 --- a/pkg/client/listers/autoscaling/v1alpha2/expansion_generated.go +++ b/pkg/client/listers/autoscaling/v1alpha2/expansion_generated.go @@ -18,6 +18,14 @@ limitations under the License. package v1alpha2 +// IntelligentHorizontalPodAutoscalerListerExpansion allows custom methods to be added to +// IntelligentHorizontalPodAutoscalerLister. +type IntelligentHorizontalPodAutoscalerListerExpansion interface{} + +// IntelligentHorizontalPodAutoscalerNamespaceListerExpansion allows custom methods to be added to +// IntelligentHorizontalPodAutoscalerNamespaceLister. +type IntelligentHorizontalPodAutoscalerNamespaceListerExpansion interface{} + // KatalystVerticalPodAutoscalerListerExpansion allows custom methods to be added to // KatalystVerticalPodAutoscalerLister. type KatalystVerticalPodAutoscalerListerExpansion interface{} @@ -25,3 +33,11 @@ type KatalystVerticalPodAutoscalerListerExpansion interface{} // KatalystVerticalPodAutoscalerNamespaceListerExpansion allows custom methods to be added to // KatalystVerticalPodAutoscalerNamespaceLister. type KatalystVerticalPodAutoscalerNamespaceListerExpansion interface{} + +// VirtualWorkloadListerExpansion allows custom methods to be added to +// VirtualWorkloadLister. +type VirtualWorkloadListerExpansion interface{} + +// VirtualWorkloadNamespaceListerExpansion allows custom methods to be added to +// VirtualWorkloadNamespaceLister. +type VirtualWorkloadNamespaceListerExpansion interface{} diff --git a/pkg/client/listers/autoscaling/v1alpha2/intelligenthorizontalpodautoscaler.go b/pkg/client/listers/autoscaling/v1alpha2/intelligenthorizontalpodautoscaler.go new file mode 100644 index 0000000..6f4221e --- /dev/null +++ b/pkg/client/listers/autoscaling/v1alpha2/intelligenthorizontalpodautoscaler.go @@ -0,0 +1,99 @@ +/* +Copyright 2022 The Katalyst 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. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + v1alpha2 "github.com/kubewharf/katalyst-api/pkg/apis/autoscaling/v1alpha2" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// IntelligentHorizontalPodAutoscalerLister helps list IntelligentHorizontalPodAutoscalers. +// All objects returned here must be treated as read-only. +type IntelligentHorizontalPodAutoscalerLister interface { + // List lists all IntelligentHorizontalPodAutoscalers in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha2.IntelligentHorizontalPodAutoscaler, err error) + // IntelligentHorizontalPodAutoscalers returns an object that can list and get IntelligentHorizontalPodAutoscalers. + IntelligentHorizontalPodAutoscalers(namespace string) IntelligentHorizontalPodAutoscalerNamespaceLister + IntelligentHorizontalPodAutoscalerListerExpansion +} + +// intelligentHorizontalPodAutoscalerLister implements the IntelligentHorizontalPodAutoscalerLister interface. +type intelligentHorizontalPodAutoscalerLister struct { + indexer cache.Indexer +} + +// NewIntelligentHorizontalPodAutoscalerLister returns a new IntelligentHorizontalPodAutoscalerLister. +func NewIntelligentHorizontalPodAutoscalerLister(indexer cache.Indexer) IntelligentHorizontalPodAutoscalerLister { + return &intelligentHorizontalPodAutoscalerLister{indexer: indexer} +} + +// List lists all IntelligentHorizontalPodAutoscalers in the indexer. +func (s *intelligentHorizontalPodAutoscalerLister) List(selector labels.Selector) (ret []*v1alpha2.IntelligentHorizontalPodAutoscaler, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha2.IntelligentHorizontalPodAutoscaler)) + }) + return ret, err +} + +// IntelligentHorizontalPodAutoscalers returns an object that can list and get IntelligentHorizontalPodAutoscalers. +func (s *intelligentHorizontalPodAutoscalerLister) IntelligentHorizontalPodAutoscalers(namespace string) IntelligentHorizontalPodAutoscalerNamespaceLister { + return intelligentHorizontalPodAutoscalerNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// IntelligentHorizontalPodAutoscalerNamespaceLister helps list and get IntelligentHorizontalPodAutoscalers. +// All objects returned here must be treated as read-only. +type IntelligentHorizontalPodAutoscalerNamespaceLister interface { + // List lists all IntelligentHorizontalPodAutoscalers in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha2.IntelligentHorizontalPodAutoscaler, err error) + // Get retrieves the IntelligentHorizontalPodAutoscaler from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha2.IntelligentHorizontalPodAutoscaler, error) + IntelligentHorizontalPodAutoscalerNamespaceListerExpansion +} + +// intelligentHorizontalPodAutoscalerNamespaceLister implements the IntelligentHorizontalPodAutoscalerNamespaceLister +// interface. +type intelligentHorizontalPodAutoscalerNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all IntelligentHorizontalPodAutoscalers in the indexer for a given namespace. +func (s intelligentHorizontalPodAutoscalerNamespaceLister) List(selector labels.Selector) (ret []*v1alpha2.IntelligentHorizontalPodAutoscaler, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha2.IntelligentHorizontalPodAutoscaler)) + }) + return ret, err +} + +// Get retrieves the IntelligentHorizontalPodAutoscaler from the indexer for a given namespace and name. +func (s intelligentHorizontalPodAutoscalerNamespaceLister) Get(name string) (*v1alpha2.IntelligentHorizontalPodAutoscaler, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha2.Resource("intelligenthorizontalpodautoscaler"), name) + } + return obj.(*v1alpha2.IntelligentHorizontalPodAutoscaler), nil +} diff --git a/pkg/client/listers/autoscaling/v1alpha2/virtualworkload.go b/pkg/client/listers/autoscaling/v1alpha2/virtualworkload.go new file mode 100644 index 0000000..4cd4386 --- /dev/null +++ b/pkg/client/listers/autoscaling/v1alpha2/virtualworkload.go @@ -0,0 +1,99 @@ +/* +Copyright 2022 The Katalyst 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. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + v1alpha2 "github.com/kubewharf/katalyst-api/pkg/apis/autoscaling/v1alpha2" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// VirtualWorkloadLister helps list VirtualWorkloads. +// All objects returned here must be treated as read-only. +type VirtualWorkloadLister interface { + // List lists all VirtualWorkloads in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha2.VirtualWorkload, err error) + // VirtualWorkloads returns an object that can list and get VirtualWorkloads. + VirtualWorkloads(namespace string) VirtualWorkloadNamespaceLister + VirtualWorkloadListerExpansion +} + +// virtualWorkloadLister implements the VirtualWorkloadLister interface. +type virtualWorkloadLister struct { + indexer cache.Indexer +} + +// NewVirtualWorkloadLister returns a new VirtualWorkloadLister. +func NewVirtualWorkloadLister(indexer cache.Indexer) VirtualWorkloadLister { + return &virtualWorkloadLister{indexer: indexer} +} + +// List lists all VirtualWorkloads in the indexer. +func (s *virtualWorkloadLister) List(selector labels.Selector) (ret []*v1alpha2.VirtualWorkload, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha2.VirtualWorkload)) + }) + return ret, err +} + +// VirtualWorkloads returns an object that can list and get VirtualWorkloads. +func (s *virtualWorkloadLister) VirtualWorkloads(namespace string) VirtualWorkloadNamespaceLister { + return virtualWorkloadNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// VirtualWorkloadNamespaceLister helps list and get VirtualWorkloads. +// All objects returned here must be treated as read-only. +type VirtualWorkloadNamespaceLister interface { + // List lists all VirtualWorkloads in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha2.VirtualWorkload, err error) + // Get retrieves the VirtualWorkload from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha2.VirtualWorkload, error) + VirtualWorkloadNamespaceListerExpansion +} + +// virtualWorkloadNamespaceLister implements the VirtualWorkloadNamespaceLister +// interface. +type virtualWorkloadNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all VirtualWorkloads in the indexer for a given namespace. +func (s virtualWorkloadNamespaceLister) List(selector labels.Selector) (ret []*v1alpha2.VirtualWorkload, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha2.VirtualWorkload)) + }) + return ret, err +} + +// Get retrieves the VirtualWorkload from the indexer for a given namespace and name. +func (s virtualWorkloadNamespaceLister) Get(name string) (*v1alpha2.VirtualWorkload, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha2.Resource("virtualworkload"), name) + } + return obj.(*v1alpha2.VirtualWorkload), nil +}