diff --git a/vertical-pod-autoscaler/deploy/kustomization.yaml b/vertical-pod-autoscaler/deploy/kustomization.yaml index 438ffb5902d5..685616d73d3f 100644 --- a/vertical-pod-autoscaler/deploy/kustomization.yaml +++ b/vertical-pod-autoscaler/deploy/kustomization.yaml @@ -3,4 +3,4 @@ resources: - recommender-deployment.yaml - updater-deployment.yaml - vpa-rbac.yaml -- vpa-v1-crd.yaml +- vpa-v1-crd-gen.yaml diff --git a/vertical-pod-autoscaler/deploy/vpa-v1-crd-gen.yaml b/vertical-pod-autoscaler/deploy/vpa-v1-crd-gen.yaml new file mode 100644 index 000000000000..f4262d83efb5 --- /dev/null +++ b/vertical-pod-autoscaler/deploy/vpa-v1-crd-gen.yaml @@ -0,0 +1,716 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + api-approved.kubernetes.io: https://github.com/kubernetes/kubernetes/pull/63797 + controller-gen.kubebuilder.io/version: v0.4.0 + creationTimestamp: null + name: verticalpodautoscalercheckpoints.autoscaling.k8s.io +spec: + group: autoscaling.k8s.io + names: + kind: VerticalPodAutoscalerCheckpoint + listKind: VerticalPodAutoscalerCheckpointList + plural: verticalpodautoscalercheckpoints + shortNames: + - vpacheckpoint + singular: verticalpodautoscalercheckpoint + scope: Namespaced + versions: + - name: v1 + schema: + openAPIV3Schema: + description: VerticalPodAutoscalerCheckpoint is the checkpoint of the internal + state of VPA that is used for recovery after recommender's restart. + 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: 'Specification of the checkpoint. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status.' + properties: + containerName: + description: Name of the checkpointed container. + type: string + vpaObjectName: + description: Name of the VPA object that stored VerticalPodAutoscalerCheckpoint + object. + type: string + type: object + status: + description: Data of the checkpoint. + properties: + cpuHistogram: + description: Checkpoint of histogram for consumption of CPU. + properties: + bucketWeights: + description: Map from bucket index to bucket weight. + type: object + x-kubernetes-preserve-unknown-fields: true + referenceTimestamp: + description: Reference timestamp for samples collected within + this histogram. + format: date-time + nullable: true + type: string + totalWeight: + description: Sum of samples to be used as denominator for weights + from BucketWeights. + type: number + type: object + firstSampleStart: + description: Timestamp of the fist sample from the histograms. + format: date-time + nullable: true + type: string + lastSampleStart: + description: Timestamp of the last sample from the histograms. + format: date-time + nullable: true + type: string + lastUpdateTime: + description: The time when the status was last refreshed. + format: date-time + nullable: true + type: string + memoryHistogram: + description: Checkpoint of histogram for consumption of memory. + properties: + bucketWeights: + description: Map from bucket index to bucket weight. + type: object + x-kubernetes-preserve-unknown-fields: true + referenceTimestamp: + description: Reference timestamp for samples collected within + this histogram. + format: date-time + nullable: true + type: string + totalWeight: + description: Sum of samples to be used as denominator for weights + from BucketWeights. + type: number + type: object + totalSamplesCount: + description: Total number of samples in the histograms. + type: integer + version: + description: Version of the format of the stored data. + type: string + type: object + type: object + served: true + storage: false + - name: v1beta2 + schema: + openAPIV3Schema: + description: VerticalPodAutoscalerCheckpoint is the checkpoint of the internal + state of VPA that is used for recovery after recommender's restart. + 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: 'Specification of the checkpoint. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status.' + properties: + containerName: + description: Name of the checkpointed container. + type: string + vpaObjectName: + description: Name of the VPA object that stored VerticalPodAutoscalerCheckpoint + object. + type: string + type: object + status: + description: Data of the checkpoint. + properties: + cpuHistogram: + description: Checkpoint of histogram for consumption of CPU. + properties: + bucketWeights: + description: Map from bucket index to bucket weight. + type: object + x-kubernetes-preserve-unknown-fields: true + referenceTimestamp: + description: Reference timestamp for samples collected within + this histogram. + format: date-time + nullable: true + type: string + totalWeight: + description: Sum of samples to be used as denominator for weights + from BucketWeights. + type: number + type: object + firstSampleStart: + description: Timestamp of the fist sample from the histograms. + format: date-time + nullable: true + type: string + lastSampleStart: + description: Timestamp of the last sample from the histograms. + format: date-time + nullable: true + type: string + lastUpdateTime: + description: The time when the status was last refreshed. + format: date-time + nullable: true + type: string + memoryHistogram: + description: Checkpoint of histogram for consumption of memory. + properties: + bucketWeights: + description: Map from bucket index to bucket weight. + type: object + x-kubernetes-preserve-unknown-fields: true + referenceTimestamp: + description: Reference timestamp for samples collected within + this histogram. + format: date-time + nullable: true + type: string + totalWeight: + description: Sum of samples to be used as denominator for weights + from BucketWeights. + type: number + type: object + totalSamplesCount: + description: Total number of samples in the histograms. + type: integer + version: + description: Version of the format of the stored data. + type: string + type: object + type: object + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + api-approved.kubernetes.io: https://github.com/kubernetes/kubernetes/pull/63797 + controller-gen.kubebuilder.io/version: v0.4.0 + creationTimestamp: null + name: verticalpodautoscalers.autoscaling.k8s.io +spec: + group: autoscaling.k8s.io + names: + kind: VerticalPodAutoscaler + listKind: VerticalPodAutoscalerList + plural: verticalpodautoscalers + shortNames: + - vpa + singular: verticalpodautoscaler + scope: Namespaced + versions: + - name: v1 + schema: + openAPIV3Schema: + description: VerticalPodAutoscaler is the configuration for a vertical pod + autoscaler, which automatically manages pod resources based on historical + and real time resource utilization. + 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: 'Specification of the behavior of the autoscaler. More info: + https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status.' + properties: + resourcePolicy: + description: Controls how the autoscaler computes recommended resources. + The resource policy may be used to set constraints on the recommendations + for individual containers. If not specified, the autoscaler computes + recommended resources for all containers in the pod, without additional + constraints. + properties: + containerPolicies: + description: Per-container resource policies. + items: + description: ContainerResourcePolicy controls how autoscaler + computes the recommended resources for a specific container. + properties: + containerName: + description: Name of the container or DefaultContainerResourcePolicy, + in which case the policy is used by the containers that + don't have their own policy specified. + type: string + controlledResources: + description: Specifies the type of recommendations that + will be computed (and possibly applied) by VPA. If not + specified, the default of [ResourceCPU, ResourceMemory] + will be used. + items: + description: ResourceName is the name identifying various + resources in a ResourceList. + type: string + type: array + controlledValues: + description: Specifies which resource values should be controlled. + The default is "RequestsAndLimits". + enum: + - RequestsAndLimits + - RequestsOnly + type: string + maxAllowed: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Specifies the maximum amount of resources that + will be recommended for the container. The default is + no maximum. + type: object + minAllowed: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Specifies the minimal amount of resources that + will be recommended for the container. The default is + no minimum. + type: object + mode: + description: Whether autoscaler is enabled for the container. + The default is "Auto". + enum: + - Auto + - "Off" + type: string + type: object + type: array + type: object + targetRef: + description: TargetRef points to the controller managing the set of + pods for the autoscaler to control - e.g. Deployment, StatefulSet. + VerticalPodAutoscaler can be targeted at controller implementing + scale subresource (the pod set is retrieved from the controller's + ScaleStatus) or some well known controllers (e.g. for DaemonSet + the pod set is read from the controller's spec). If VerticalPodAutoscaler + cannot use specified target it will report ConfigUnsupported condition. + Note that VerticalPodAutoscaler does not require full implementation + of scale subresource - it will not use it to modify the replica + count. The only thing retrieved is a label selector matching pods + grouped by the target resource. + 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 + updatePolicy: + description: Describes the rules on how changes are applied to the + pods. If not specified, all fields in the `PodUpdatePolicy` are + set to their default values. + properties: + updateMode: + description: Controls when autoscaler applies changes to the pod + resources. The default is 'Auto'. + enum: + - "Off" + - Initial + - Recreate + - Auto + type: string + type: object + required: + - targetRef + type: object + status: + description: Current information about the autoscaler. + properties: + conditions: + description: Conditions is the set of conditions required for this + autoscaler to scale its target, and indicates whether or not those + conditions are met. + items: + description: VerticalPodAutoscalerCondition describes the state + of a VerticalPodAutoscaler 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 + recommendation: + description: The most recently computed amount of resources recommended + by the autoscaler for the controlled pods. + properties: + containerRecommendations: + description: Resources recommended by the autoscaler for each + container. + items: + description: RecommendedContainerResources is the recommendation + of resources computed by autoscaler for a specific container. + Respects the container resource policy if present in the spec. + In particular the recommendation is not produced for containers + with `ContainerScalingMode` set to 'Off'. + properties: + containerName: + description: Name of the container. + type: string + lowerBound: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Minimum recommended amount of resources. Observes + ContainerResourcePolicy. This amount is not guaranteed + to be sufficient for the application to operate in a stable + way, however running with less resources is likely to + have significant impact on performance/availability. + type: object + target: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Recommended amount of resources. Observes ContainerResourcePolicy. + type: object + uncappedTarget: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: The most recent recommended resources target + computed by the autoscaler for the controlled pods, based + only on actual resource usage, not taking into account + the ContainerResourcePolicy. May differ from the Recommendation + if the actual resource usage causes the target to violate + the ContainerResourcePolicy (lower than MinAllowed or + higher that MaxAllowed). Used only as status indication, + will not affect actual resource assignment. + type: object + upperBound: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Maximum recommended amount of resources. Observes + ContainerResourcePolicy. Any resources allocated beyond + this value are likely wasted. This value may be larger + than the maximum amount of application is actually capable + of consuming. + type: object + required: + - target + type: object + type: array + type: object + type: object + required: + - spec + type: object + served: true + storage: false + - name: v1beta2 + schema: + openAPIV3Schema: + description: VerticalPodAutoscaler is the configuration for a vertical pod + autoscaler, which automatically manages pod resources based on historical + and real time resource utilization. + 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: 'Specification of the behavior of the autoscaler. More info: + https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status.' + properties: + resourcePolicy: + description: Controls how the autoscaler computes recommended resources. + The resource policy may be used to set constraints on the recommendations + for individual containers. If not specified, the autoscaler computes + recommended resources for all containers in the pod, without additional + constraints. + properties: + containerPolicies: + description: Per-container resource policies. + items: + description: ContainerResourcePolicy controls how autoscaler + computes the recommended resources for a specific container. + properties: + containerName: + description: Name of the container or DefaultContainerResourcePolicy, + in which case the policy is used by the containers that + don't have their own policy specified. + type: string + maxAllowed: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Specifies the maximum amount of resources that + will be recommended for the container. The default is + no maximum. + type: object + minAllowed: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Specifies the minimal amount of resources that + will be recommended for the container. The default is + no minimum. + type: object + mode: + description: Whether autoscaler is enabled for the container. + The default is "Auto". + enum: + - Auto + - "Off" + type: string + type: object + type: array + type: object + targetRef: + description: TargetRef points to the controller managing the set of + pods for the autoscaler to control - e.g. Deployment, StatefulSet. + VerticalPodAutoscaler can be targeted at controller implementing + scale subresource (the pod set is retrieved from the controller's + ScaleStatus) or some well known controllers (e.g. for DaemonSet + the pod set is read from the controller's spec). If VerticalPodAutoscaler + cannot use specified target it will report ConfigUnsupported condition. + Note that VerticalPodAutoscaler does not require full implementation + of scale subresource - it will not use it to modify the replica + count. The only thing retrieved is a label selector matching pods + grouped by the target resource. + 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 + updatePolicy: + description: Describes the rules on how changes are applied to the + pods. If not specified, all fields in the `PodUpdatePolicy` are + set to their default values. + properties: + updateMode: + description: Controls when autoscaler applies changes to the pod + resources. The default is 'Auto'. + enum: + - "Off" + - Initial + - Recreate + - Auto + type: string + type: object + required: + - targetRef + type: object + status: + description: Current information about the autoscaler. + properties: + conditions: + description: Conditions is the set of conditions required for this + autoscaler to scale its target, and indicates whether or not those + conditions are met. + items: + description: VerticalPodAutoscalerCondition describes the state + of a VerticalPodAutoscaler 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 + recommendation: + description: The most recently computed amount of resources recommended + by the autoscaler for the controlled pods. + properties: + containerRecommendations: + description: Resources recommended by the autoscaler for each + container. + items: + description: RecommendedContainerResources is the recommendation + of resources computed by autoscaler for a specific container. + Respects the container resource policy if present in the spec. + In particular the recommendation is not produced for containers + with `ContainerScalingMode` set to 'Off'. + properties: + containerName: + description: Name of the container. + type: string + lowerBound: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Minimum recommended amount of resources. Observes + ContainerResourcePolicy. This amount is not guaranteed + to be sufficient for the application to operate in a stable + way, however running with less resources is likely to + have significant impact on performance/availability. + type: object + target: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Recommended amount of resources. Observes ContainerResourcePolicy. + type: object + uncappedTarget: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: The most recent recommended resources target + computed by the autoscaler for the controlled pods, based + only on actual resource usage, not taking into account + the ContainerResourcePolicy. May differ from the Recommendation + if the actual resource usage causes the target to violate + the ContainerResourcePolicy (lower than MinAllowed or + higher that MaxAllowed). Used only as status indication, + will not affect actual resource assignment. + type: object + upperBound: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Maximum recommended amount of resources. Observes + ContainerResourcePolicy. Any resources allocated beyond + this value are likely wasted. This value may be larger + than the maximum amount of application is actually capable + of consuming. + type: object + required: + - target + type: object + type: array + type: object + type: object + required: + - spec + type: object + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/vertical-pod-autoscaler/hack/deploy-for-e2e.sh b/vertical-pod-autoscaler/hack/deploy-for-e2e.sh index afa5a5877344..c71864836492 100755 --- a/vertical-pod-autoscaler/hack/deploy-for-e2e.sh +++ b/vertical-pod-autoscaler/hack/deploy-for-e2e.sh @@ -73,7 +73,7 @@ for i in ${COMPONENTS}; do ALL_ARCHITECTURES=amd64 make --directory ${SCRIPT_ROOT}/pkg/${i} release done -kubectl create -f ${SCRIPT_ROOT}/deploy/vpa-v1-crd.yaml +kubectl create -f ${SCRIPT_ROOT}/deploy/vpa-v1-crd-gen.yaml kubectl create -f ${SCRIPT_ROOT}/deploy/vpa-rbac.yaml for i in ${COMPONENTS}; do diff --git a/vertical-pod-autoscaler/hack/generate-crd-yaml.sh b/vertical-pod-autoscaler/hack/generate-crd-yaml.sh new file mode 100755 index 000000000000..23aa66e9b85c --- /dev/null +++ b/vertical-pod-autoscaler/hack/generate-crd-yaml.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +# Copyright 2020 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail + +REPOSITORY_ROOT=$(realpath $(dirname ${BASH_SOURCE})/..) +CRD_OPTS=crd:trivialVersions=false,allowDangerousTypes=true +APIS_PATH=${REPOSITORY_ROOT}/pkg/apis +OUTPUT=${REPOSITORY_ROOT}/deploy/vpa-v1-crd-gen.yaml +WORKSPACE=$(mktemp -d) + +function cleanup() { + rm -r ${WORKSPACE} +} +trap cleanup EXIT + +if [[ -z $(which controller-gen) ]]; then + ( + cd $WORKSPACE + go mod init tmp + go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.0 + ) + CONTROLLER_GEN=${GOBIN:-$(go env GOPATH)/bin}/controller-gen +else + CONTROLLER_GEN=$(which controller-gen) +fi + +# The following commands always returns an error because controller-gen does not accept keys other than strings. +${CONTROLLER_GEN} ${CRD_OPTS} paths="${APIS_PATH}/..." output:crd:dir=${WORKSPACE} >& ${WORKSPACE}/errors.log ||: +grep -v -e 'map keys must be strings, not int' -e 'not all generators ran successfully' -e 'usage' ${WORKSPACE}/errors.log \ + && { echo "Failed to generate CRD YAMLs."; exit 1; } + +cd ${WORKSPACE} +cat < kustomization.yaml +resources: +- autoscaling.k8s.io_verticalpodautoscalers.yaml +- autoscaling.k8s.io_verticalpodautoscalercheckpoints.yaml +commonAnnotations: + "api-approved.kubernetes.io": "https://github.com/kubernetes/kubernetes/pull/63797" +EOF +kubectl kustomize . > ${OUTPUT} diff --git a/vertical-pod-autoscaler/hack/vpa-process-yamls.sh b/vertical-pod-autoscaler/hack/vpa-process-yamls.sh index 95d19641786c..d30552efcbe7 100755 --- a/vertical-pod-autoscaler/hack/vpa-process-yamls.sh +++ b/vertical-pod-autoscaler/hack/vpa-process-yamls.sh @@ -40,7 +40,7 @@ if [ $# -gt 2 ]; then fi ACTION=$1 -COMPONENTS="vpa-v1-crd vpa-rbac updater-deployment recommender-deployment admission-controller-deployment" +COMPONENTS="vpa-v1-crd-gen vpa-rbac updater-deployment recommender-deployment admission-controller-deployment" case ${ACTION} in delete|diff|print) COMPONENTS+=" vpa-beta2-crd" ;; esac diff --git a/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/doc.go b/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/doc.go index ecc8f33d1bda..8b8169081002 100644 --- a/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/doc.go +++ b/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/doc.go @@ -18,4 +18,5 @@ limitations under the License. // Package v1 contains definitions of Vertical Pod Autoscaler related objects. // +groupName=autoscaling.k8s.io +// +kubebuilder:object:generate=true package v1 diff --git a/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go b/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go index 1b25eff4919b..fe5e3bf3e4dd 100644 --- a/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go +++ b/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go @@ -38,14 +38,13 @@ type VerticalPodAutoscalerList struct { // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:shortName=vpa // VerticalPodAutoscaler is the configuration for a vertical pod // autoscaler, which automatically manages pod resources based on historical and // real time resource utilization. type VerticalPodAutoscaler struct { - metav1.TypeMeta `json:",inline"` - // Standard object metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata - // +optional + metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // Specification of the behavior of the autoscaler. @@ -96,6 +95,7 @@ type PodUpdatePolicy struct { } // UpdateMode controls when autoscaler applies changes to the pod resoures. +// +kubebuilder:validation:Enum=Off;Initial;Recreate;Auto type UpdateMode string const ( @@ -167,6 +167,7 @@ const ( // ContainerScalingMode controls whether autoscaler is enabled for a specific // container. +// +kubebuilder:validation:Enum=Auto;Off type ContainerScalingMode string const ( @@ -177,6 +178,7 @@ const ( ) // ContainerControlledValues controls which resource value should be autoscaled. +// +kubebuilder:validation:Enum=RequestsAndLimits;RequestsOnly type ContainerControlledValues string const ( @@ -286,13 +288,12 @@ type VerticalPodAutoscalerCondition struct { // +genclient // +genclient:noStatus // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:shortName=vpacheckpoint // VerticalPodAutoscalerCheckpoint is the checkpoint of the internal state of VPA that // is used for recovery after recommender's restart. type VerticalPodAutoscalerCheckpoint struct { - metav1.TypeMeta `json:",inline"` - // Standard object metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata - // +optional + metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // Specification of the checkpoint. @@ -326,6 +327,7 @@ type VerticalPodAutoscalerCheckpointSpec struct { // VerticalPodAutoscalerCheckpointStatus contains data of the checkpoint. type VerticalPodAutoscalerCheckpointStatus struct { // The time when the status was last refreshed. + // +nullable LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty" protobuf:"bytes,1,opt,name=lastUpdateTime"` // Version of the format of the stored data. @@ -338,9 +340,11 @@ type VerticalPodAutoscalerCheckpointStatus struct { MemoryHistogram HistogramCheckpoint `json:"memoryHistogram,omitempty" protobuf:"bytes,4,rep,name=memoryHistogram"` // Timestamp of the fist sample from the histograms. + // +nullable FirstSampleStart metav1.Time `json:"firstSampleStart,omitempty" protobuf:"bytes,5,opt,name=firstSampleStart"` // Timestamp of the last sample from the histograms. + // +nullable LastSampleStart metav1.Time `json:"lastSampleStart,omitempty" protobuf:"bytes,6,opt,name=lastSampleStart"` // Total number of samples in the histograms. @@ -350,9 +354,12 @@ type VerticalPodAutoscalerCheckpointStatus struct { // HistogramCheckpoint contains data needed to reconstruct the histogram. type HistogramCheckpoint struct { // Reference timestamp for samples collected within this histogram. + // +nullable ReferenceTimestamp metav1.Time `json:"referenceTimestamp,omitempty" protobuf:"bytes,1,opt,name=referenceTimestamp"` // Map from bucket index to bucket weight. + // +kubebuilder:validation:Type=object + // +kubebuilder:validation:XPreserveUnknownFields BucketWeights map[int]uint32 `json:"bucketWeights,omitempty" protobuf:"bytes,2,opt,name=bucketWeights"` // Sum of samples to be used as denominator for weights from BucketWeights. diff --git a/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta1/doc.go b/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta1/doc.go index 2803d49a5cb9..b931b7f5ca1e 100644 --- a/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta1/doc.go +++ b/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta1/doc.go @@ -18,4 +18,5 @@ limitations under the License. // Package v1beta1 contains definitions of Vertical Pod Autoscaler related objects. // +groupName=autoscaling.k8s.io +// +kubebuilder:skip package v1beta1 diff --git a/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2/doc.go b/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2/doc.go index bd274686bdfc..961d29e25242 100644 --- a/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2/doc.go +++ b/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2/doc.go @@ -18,4 +18,5 @@ limitations under the License. // Package v1beta2 contains definitions of Vertical Pod Autoscaler related objects. // +groupName=autoscaling.k8s.io +// +kubebuilder:object:generate=true package v1beta2 diff --git a/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2/types.go b/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2/types.go index 74c73ba015fa..46d86329e431 100644 --- a/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2/types.go +++ b/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2/types.go @@ -38,14 +38,14 @@ type VerticalPodAutoscalerList struct { // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:shortName=vpa +// +kubebuilder:storageversion // VerticalPodAutoscaler is the configuration for a vertical pod // autoscaler, which automatically manages pod resources based on historical and // real time resource utilization. type VerticalPodAutoscaler struct { - metav1.TypeMeta `json:",inline"` - // Standard object metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata - // +optional + metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // Specification of the behavior of the autoscaler. @@ -96,6 +96,7 @@ type PodUpdatePolicy struct { } // UpdateMode controls when autoscaler applies changes to the pod resoures. +// +kubebuilder:validation:Enum=Off;Initial;Recreate;Auto type UpdateMode string const ( @@ -157,6 +158,7 @@ const ( // ContainerScalingMode controls whether autoscaler is enabled for a specific // container. +// +kubebuilder:validation:Enum=Auto;Off type ContainerScalingMode string const ( @@ -265,13 +267,13 @@ type VerticalPodAutoscalerCondition struct { // +genclient // +genclient:noStatus // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:storageversion +// +kubebuilder:resource:shortName=vpacheckpoint // VerticalPodAutoscalerCheckpoint is the checkpoint of the internal state of VPA that // is used for recovery after recommender's restart. type VerticalPodAutoscalerCheckpoint struct { - metav1.TypeMeta `json:",inline"` - // Standard object metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata - // +optional + metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // Specification of the checkpoint. @@ -305,6 +307,7 @@ type VerticalPodAutoscalerCheckpointSpec struct { // VerticalPodAutoscalerCheckpointStatus contains data of the checkpoint. type VerticalPodAutoscalerCheckpointStatus struct { // The time when the status was last refreshed. + // +nullable LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty" protobuf:"bytes,1,opt,name=lastUpdateTime"` // Version of the format of the stored data. @@ -317,9 +320,11 @@ type VerticalPodAutoscalerCheckpointStatus struct { MemoryHistogram HistogramCheckpoint `json:"memoryHistogram,omitempty" protobuf:"bytes,4,rep,name=memoryHistogram"` // Timestamp of the fist sample from the histograms. + // +nullable FirstSampleStart metav1.Time `json:"firstSampleStart,omitempty" protobuf:"bytes,5,opt,name=firstSampleStart"` // Timestamp of the last sample from the histograms. + // +nullable LastSampleStart metav1.Time `json:"lastSampleStart,omitempty" protobuf:"bytes,6,opt,name=lastSampleStart"` // Total number of samples in the histograms. @@ -329,9 +334,12 @@ type VerticalPodAutoscalerCheckpointStatus struct { // HistogramCheckpoint contains data needed to reconstruct the histogram. type HistogramCheckpoint struct { // Reference timestamp for samples collected within this histogram. + // +nullable ReferenceTimestamp metav1.Time `json:"referenceTimestamp,omitempty" protobuf:"bytes,1,opt,name=referenceTimestamp"` // Map from bucket index to bucket weight. + // +kubebuilder:validation:Type=object + // +kubebuilder:validation:XPreserveUnknownFields BucketWeights map[int]uint32 `json:"bucketWeights,omitempty" protobuf:"bytes,2,opt,name=bucketWeights"` // Sum of samples to be used as denominator for weights from BucketWeights. diff --git a/vertical-pod-autoscaler/pkg/apis/poc.autoscaling.k8s.io/v1alpha1/doc.go b/vertical-pod-autoscaler/pkg/apis/poc.autoscaling.k8s.io/v1alpha1/doc.go index 93b8d770125a..4ef92109b9d3 100644 --- a/vertical-pod-autoscaler/pkg/apis/poc.autoscaling.k8s.io/v1alpha1/doc.go +++ b/vertical-pod-autoscaler/pkg/apis/poc.autoscaling.k8s.io/v1alpha1/doc.go @@ -18,4 +18,5 @@ limitations under the License. // Package v1alpha1 contains definitions of Vertical Pod Autoscaler related objects. // +groupName=poc.autoscaling.k8s.io +// +kubebuilder:skip package v1alpha1