Initial v1.0.0 commit

This commit is contained in:
Jakub Vavřík
2021-01-28 17:37:47 +01:00
commit 1481d27782
4164 changed files with 1264675 additions and 0 deletions

296
vendor/github.com/gardener/hvpa-controller/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,296 @@
```
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.
```
## APIs
This project may include APIs to SAP or third party products or services. The use of these APIs,
products and services may be subject to additional agreements. In no event shall the application
of the Apache Software License, v.2 to this project grant any rights in or to these APIs, products
or services that would alter, expand, be inconsistent with, or supersede any terms of these additional
agreements. API means application programming interfaces, as well as their respective specifications
and implementing code that allows other software products to communicate with or call on SAP or
third party products or services (for example, SAP Enterprise Services, BAPIs, Idocs, RFCs and
ABAP calls or other user exits) and may be made available through SAP or third party products,
SDKs, documentation or other media.
## Subcomponents
This project includes the following subcomponents that are subject to separate license terms.
Your use of these subcomponents is subject to the separate license terms applicable to
each subcomponent.
API.
https://github.com/kubernetes/api/
Copyright 2017 The Kubernetes Authors.
Apache 2 license (https://github.com/kubernetes/api/blob/master/LICENSE ).
APIMachinery.
https://github.com/kubernetes/apimachinery
Copyright 2017 The Kubernetes Authors.
Apache 2 license (https://github.com/kubernetes/apimachinery/blob/master/LICENSE ).
Kubernetes client-go
https://github.com/kubernetes/client-go/
Copyright 2018 The Kubernetes Authors
Apache 2 license (https://github.com/kubernetes/client-go/blob/master/LICENSE)
Autoscaler.
https://github.com/kubernetes/autoscaler
Copyright 2017 The Kubernetes Authors.
Apache 2 license (https://github.com/kubernetes/autoscaler/blob/master/LICENSE ).
Code-Generator.
https://git.k8s.io/code-generator.
Copyright 2017 The Kubernetes Authors.
Apache 2 license (https://git.k8s.io/code-generator/LICENSE)
controller-runtime
https://github.com/kubernetes-sigs/controller-runtime
Copyright 2018 The Kubernetes Authors.
Apache 2 license (https://github.com/kubernetes-sigs/controller-runtime/blob/master/LICENSE).
controller-tools
https://github.com/kubernetes-sigs/controller-tools
Copyright 2018 The Kubernetes Authors.
Apache 2 license (https://github.com/kubernetes-sigs/controller-runtime/blob/master/LICENSE).
Klog
https://github.com/kubernetes/klog
Copyright 2017 The Kubernetes Authors
Apache 2 license (https://github.com/kubernetes/klog/blob/master/LICENSE)
Ginkgo.
https://github.com/onsi/ginkgo.
Copyright (c) 2013-2014 Onsi Fakhouri
MIT license (https://github.com/onsi/ginkgo/blob/master/LICENSE)
Gomega.
https://github.com/onsi/gomega.
Copyright (c) 2013-2014 Onsi Fakhouri
MIT license (https://github.com/onsi/gomega/blob/master/LICENSE)
------
## MIT License
The MIT License (MIT)
Copyright (c) <year> <owner>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,68 @@
/*
Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package v1alpha1 contains API Schema definitions for the autoscaling v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=autoscaling.k8s.io
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
vpa_api "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2"
)
var (
// GroupName is the group name use in this package
GroupName = "autoscaling.k8s.io"
// SchemeGroupVersionVpa is group version used to register these objects
SchemeGroupVersionVpa = schema.GroupVersion{Group: GroupName, Version: "v1beta2"}
// SchemeGroupVersionHvpa is group version used to register these objects
SchemeGroupVersionHvpa = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
localSchemeBuilder = &SchemeBuilder
// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
func init() {
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
localSchemeBuilder.Register(addKnownTypes)
}
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersionHvpa,
&Hvpa{},
&HvpaList{},
)
scheme.AddKnownTypes(SchemeGroupVersionVpa,
&vpa_api.VerticalPodAutoscaler{},
&vpa_api.VerticalPodAutoscalerList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersionVpa)
metav1.AddToGroupVersion(scheme, SchemeGroupVersionHvpa)
return nil
}

View File

@@ -0,0 +1,352 @@
/*
Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
import (
autoscaling "k8s.io/api/autoscaling/v2beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
vpa_api "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// VpaTemplateSpec defines the spec for VPA
type VpaTemplateSpec struct {
// 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.
// +optional
ResourcePolicy *vpa_api.PodResourcePolicy `json:"resourcePolicy,omitempty" protobuf:"bytes,2,opt,name=resourcePolicy"`
}
// UpdatePolicy describes the rules on how changes are applied.
type UpdatePolicy struct {
// Controls when autoscaler applies changes to the resources.
// The default is 'Auto'.
// +optional
UpdateMode *string `json:"updateMode,omitempty" protobuf:"bytes,1,opt,name=updateMode"`
}
const (
// UpdateModeOff means that autoscaler never changes resources.
UpdateModeOff string = "Off"
// UpdateModeAuto means that autoscaler can update resources during the lifetime of the resource.
UpdateModeAuto string = "Auto"
// UpdateModeMaintenanceWindow means that HPA/VPA will only act during maintenance window.
UpdateModeMaintenanceWindow string = "MaintenanceWindow"
// UpdateModeDefault is the default update mode
UpdateModeDefault = UpdateModeAuto
)
// MaintenanceTimeWindow contains information about the time window for maintenance operations.
type MaintenanceTimeWindow struct {
// Begin is the beginning of the time window in the format HHMMSS+ZONE, e.g. "220000+0100".
Begin string `json:"begin"`
// End is the end of the time window in the format HHMMSS+ZONE, e.g. "220000+0100".
End string `json:"end"`
}
// HpaTemplateSpec defines the spec for HPA
type HpaTemplateSpec struct {
// minReplicas is the lower limit for the number of replicas to which the autoscaler can scale down.
// It defaults to 1 pod.
// +optional
MinReplicas *int32 `json:"minReplicas,omitempty" protobuf:"varint,1,opt,name=minReplicas"`
// maxReplicas is the upper limit for the number of replicas to which the autoscaler can scale up.
// It cannot be less that minReplicas.
MaxReplicas int32 `json:"maxReplicas" protobuf:"varint,2,opt,name=maxReplicas"`
// metrics contains the specifications for which to use to calculate the
// desired replica count (the maximum replica count across all metrics will
// be used). The desired replica count is calculated multiplying the
// ratio between the target value and the current value by the current
// number of pods. Ergo, metrics used must decrease as the pod count is
// increased, and vice-versa. See the individual metric source types for
// more information about how each type of metric must respond.
// If not set, the default metric will be set to 80% average CPU utilization.
// +optional
Metrics []autoscaling.MetricSpec `json:"metrics,omitempty" protobuf:"bytes,3,rep,name=metrics"`
}
// WeightBasedScalingInterval defines the interval of replica counts in which VpaWeight is applied to VPA scaling
type WeightBasedScalingInterval struct {
// VpaWeight defines the weight (in percentage) to be given to VPA's recommendationd for the interval of number of replicas provided
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=100
VpaWeight VpaWeight `json:"vpaWeight,omitempty"`
// StartReplicaCount is the number of replicas from which VpaWeight is applied to VPA scaling
// If this field is not provided, it will default to minReplicas of HPA
// +optional
StartReplicaCount int32 `json:"startReplicaCount,omitempty"`
// LastReplicaCount is the number of replicas till which VpaWeight is applied to VPA scaling
// If this field is not provided, it will default to maxReplicas of HPA
// +optional
LastReplicaCount int32 `json:"lastReplicaCount,omitempty"`
}
// VpaSpec defines spec for VPA
type VpaSpec struct {
// Selector is a label query that should match VPA.
// Must match in order to be controlled.
// If empty, defaulted to labels on VPA template.
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
// +optional
Selector *metav1.LabelSelector `json:"selector,omitempty"`
// Deploy defines whether the VPA is deployed or not
Deploy bool `json:"deploy,omitempty"`
// ScaleUp defines the parameters for scale up
ScaleUp ScaleType `json:"scaleUp,omitempty"`
// ScaleDown defines the parameters for scale down
ScaleDown ScaleType `json:"scaleDown,omitempty"`
// Template is the object that describes the VPA that will be created.
// +optional
Template VpaTemplate `json:"template,omitempty"`
// LimitsRequestsGapScaleParams is the scaling thresholds for limits
LimitsRequestsGapScaleParams ScaleParams `json:"limitsRequestsGapScaleParams,omitempty"`
}
// ScaleType defines parameters for scaling
type ScaleType struct {
// Describes the rules on when changes are applied.
// If not specified, all fields in the `UpdatePolicy` are set to their
// default values.
// +optional
UpdatePolicy UpdatePolicy `json:"updatePolicy,omitempty"`
// MinChange is the minimum change in the resource on which HVPA acts
// HVPA uses minimum of the Value and Percentage value
MinChange ScaleParams `json:"minChange,omitempty"`
// StabilizationDuration defines the minimum delay in minutes between 2 consecutive scale operations
// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h"
StabilizationDuration *string `json:"stabilizationDuration,omitempty"`
}
// ScaleParams defines the scaling parameters for the limits
type ScaleParams struct {
// Scale parameters for CPU
CPU ChangeParams `json:"cpu,omitempty"`
// Scale parameters for memory
Memory ChangeParams `json:"memory,omitempty"`
// Scale patameters for replicas
Replicas ChangeParams `json:"replicas,omitempty"`
}
// VpaTemplate defines the template for VPA
type VpaTemplate struct {
// Metadata of the pods created from this template.
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
// Spec defines the behavior of a VPA.
// +optional
Spec VpaTemplateSpec `json:"spec,omitempty"`
}
// HpaTemplate defines the template for HPA
type HpaTemplate struct {
// Metadata of the pods created from this template.
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
// Spec defines the behavior of a HPA.
// +optional
Spec HpaTemplateSpec `json:"spec,omitempty"`
}
// HpaSpec defines spec for HPA
type HpaSpec struct {
// Selector is a label query that should match HPA.
// Must match in order to be controlled.
// If empty, defaulted to labels on HPA template.
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
// +optional
Selector *metav1.LabelSelector `json:"selector,omitempty"`
// Deploy defines whether the HPA is deployed or not
Deploy bool `json:"deploy,omitempty"`
// ScaleUp defines the parameters for scale up
ScaleUp ScaleType `json:"scaleUp,omitempty"`
// ScaleDown defines the parameters for scale down
ScaleDown ScaleType `json:"scaleDown,omitempty"`
// Template is the object that describes the HPA that will be created.
// +optional
Template HpaTemplate `json:"template,omitempty"`
}
// HvpaSpec defines the desired state of Hvpa
type HvpaSpec struct {
// Replicas is the number of replicas of target resource
Replicas *int32 `json:"replicas,omitempty"`
// Hpa defines the spec of HPA
Hpa HpaSpec `json:"hpa,omitempty"`
// Vpa defines the spec of VPA
Vpa VpaSpec `json:"vpa,omitempty"`
// WeightBasedScalingIntervals defines the intervals of replica counts, and the weights for scaling a deployment vertically
// If there are overlapping intervals, then the vpaWeight will be taken from the first matching interval
WeightBasedScalingIntervals []WeightBasedScalingInterval `json:"weightBasedScalingIntervals,omitempty"`
// TargetRef points to the controller managing the set of pods for the autoscaler to control
TargetRef *autoscaling.CrossVersionObjectReference `json:"targetRef"`
// MaintenanceTimeWindow contains information about the time window for maintenance operations.
// +optional
MaintenanceTimeWindow *MaintenanceTimeWindow `json:"maintenanceTimeWindow,omitempty"`
}
// ChangeParams defines the parameters for scaling
type ChangeParams struct {
// Value is the absolute value of the scaling
// +optional
Value *string `json:"value,omitempty"`
// Percentage is the percentage of currently allocated value to be used for scaling
// +optional
Percentage *int32 `json:"percentage,omitempty"`
}
// VpaWeight - weight to provide to VPA scaling
type VpaWeight int32
const (
// VpaOnly - only vertical scaling
VpaOnly VpaWeight = 100
// HpaOnly - only horizontal scaling
HpaOnly VpaWeight = 0
)
// LastError has detailed information of the error
type LastError struct {
// Description of the error
Description string `json:"description,omitempty"`
// Time at which the error occurred
LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
// LastOperation is the type of operation for which error occurred
LastOperation string `json:"lastOperation,omitempty"`
}
// HvpaStatus defines the observed state of Hvpa
type HvpaStatus struct {
// Replicas is the number of replicas of the target resource.
Replicas *int32 `json:"replicas,omitempty"`
// TargetSelector is the string form of the label selector of HPA. This is required for HPA to work with scale subresource.
TargetSelector *string `json:"targetSelector,omitempty"`
// Current HPA UpdatePolicy set in the spec
HpaScaleUpUpdatePolicy *UpdatePolicy `json:"hpaScaleUpUpdatePolicy,omitempty"`
// Current HPA UpdatePolicy set in the spec
HpaScaleDownUpdatePolicy *UpdatePolicy `json:"hpaScaleDownUpdatePolicy,omitempty"`
// Current VPA UpdatePolicy set in the spec
VpaScaleUpUpdatePolicy *UpdatePolicy `json:"vpaScaleUpUpdatePolicy,omitempty"`
// Current VPA UpdatePolicy set in the spec
VpaScaleDownUpdatePolicy *UpdatePolicy `json:"vpaScaleDownUpdatePolicy,omitempty"`
HpaWeight VpaWeight `json:"hpaWeight,omitempty"`
VpaWeight VpaWeight `json:"vpaWeight,omitempty"`
// Override scale up stabilization window
OverrideScaleUpStabilization bool `json:"overrideScaleUpStabilization,omitempty"`
LastBlockedScaling []*BlockedScaling `json:"lastBlockedScaling,omitempty"`
LastScaling ScalingStatus `json:"lastScaling,omitempty"`
// LastError has details of any errors that occurred
LastError *LastError `json:"lastError,omitempty"`
}
// BlockingReason defines the reason for blocking.
type BlockingReason string
const (
// BlockingReasonStabilizationWindow - HVPA is in stabilization window
BlockingReasonStabilizationWindow BlockingReason = "StabilizationWindow"
// BlockingReasonMaintenanceWindow - Resource is in maintenance window
BlockingReasonMaintenanceWindow BlockingReason = "MaintenanceWindow"
// BlockingReasonUpdatePolicy - Update policy doesn't support scaling
BlockingReasonUpdatePolicy BlockingReason = "UpdatePolicy"
// BlockingReasonWeight - VpaWeight doesn't support scaling
BlockingReasonWeight BlockingReason = "Weight"
// BlockingReasonMinChange - Min change doesn't support scaling
BlockingReasonMinChange BlockingReason = "MinChange"
)
// BlockingReasons lists all the blocking reasons
var BlockingReasons = [...]BlockingReason{
BlockingReasonMaintenanceWindow,
BlockingReasonMinChange,
BlockingReasonStabilizationWindow,
BlockingReasonUpdatePolicy,
BlockingReasonWeight,
}
// BlockedScaling defines the details for blocked scaling
type BlockedScaling struct {
Reason BlockingReason `json:"reason,omitempty"`
ScalingStatus `json:"scalingStatus,omitempty"`
}
// ScalingStatus defines the status of scaling
type ScalingStatus struct {
LastScaleTime *metav1.Time `json:"lastScaleTime,omitempty"`
HpaStatus HpaStatus `json:"hpaStatus,omitempty" protobuf:"bytes,1,opt,name=hpaStatus"`
VpaStatus vpa_api.VerticalPodAutoscalerStatus `json:"vpaStatus,omitempty" protobuf:"bytes,2,opt,name=vpaStatus"`
}
// HpaStatus defines the status of HPA
type HpaStatus struct {
CurrentReplicas int32 `json:"currentReplicas,omitempty"`
DesiredReplicas int32 `json:"desiredReplicas,omitempty"`
}
// Hvpa is the Schema for the hvpas API
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.targetSelector
type Hvpa struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec HvpaSpec `json:"spec,omitempty"`
Status HvpaStatus `json:"status,omitempty"`
}
// HvpaList contains a list of Hvpa
// +kubebuilder:object:root=true
type HvpaList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Hvpa `json:"items"`
}
/*func init() {
SchemeBuilder.Register(&Hvpa{}, &HvpaList{})
}*/

View File

@@ -0,0 +1,75 @@
/*
Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
import (
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
)
// log is for logging in this package.
var hvpalog = logf.Log.WithName("hvpa-resource")
// SetupWebhookWithManager sets up manager with a new webhook and r as the reconcile.Reconciler
func (r *Hvpa) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
Complete()
}
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// +kubebuilder:webhook:path=/mutate-autoscaling-k8s-io-v1alpha1-hvpa,mutating=true,failurePolicy=fail,groups=autoscaling.k8s.io,resources=hvpas,verbs=create;update,versions=v1alpha1,name=mhvpa.kb.io
var _ webhook.Defaulter = &Hvpa{}
// Default implements webhook.Defaulter so a webhook will be registered for the type
func (r *Hvpa) Default() {
hvpalog.Info("default", "name", r.Name)
// TODO(user): fill in your defaulting logic.
}
// +kubebuilder:webhook:path=/validate-autoscaling-k8s-io-v1alpha1-hvpa,mutating=false,failurePolicy=fail,groups=autoscaling.k8s.io,resources=hvpas,verbs=create;update,versions=v1alpha1,name=vhvpa.kb.io
var _ webhook.Validator = &Hvpa{}
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *Hvpa) ValidateCreate() error {
hvpalog.Info("validate create", "name", r.Name)
// TODO(user): fill in your validation logic upon object creation.
return nil
}
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *Hvpa) ValidateUpdate(old runtime.Object) error {
hvpalog.Info("validate update", "name", r.Name)
// TODO(user): fill in your validation logic upon object update.
return nil
}
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *Hvpa) ValidateDelete() error {
hvpalog.Info("validate delete", "name", r.Name)
// TODO(user): fill in your validation logic upon object update.
return nil
}

View File

@@ -0,0 +1,498 @@
// +build !ignore_autogenerated
/*
Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved.
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.
*/
// autogenerated by controller-gen object, do not modify manually
package v1alpha1
import (
"k8s.io/api/autoscaling/v2beta1"
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *BlockedScaling) DeepCopyInto(out *BlockedScaling) {
*out = *in
in.ScalingStatus.DeepCopyInto(&out.ScalingStatus)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BlockedScaling.
func (in *BlockedScaling) DeepCopy() *BlockedScaling {
if in == nil {
return nil
}
out := new(BlockedScaling)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ChangeParams) DeepCopyInto(out *ChangeParams) {
*out = *in
if in.Value != nil {
in, out := &in.Value, &out.Value
*out = new(string)
**out = **in
}
if in.Percentage != nil {
in, out := &in.Percentage, &out.Percentage
*out = new(int32)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChangeParams.
func (in *ChangeParams) DeepCopy() *ChangeParams {
if in == nil {
return nil
}
out := new(ChangeParams)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HpaSpec) DeepCopyInto(out *HpaSpec) {
*out = *in
if in.Selector != nil {
in, out := &in.Selector, &out.Selector
*out = new(v1.LabelSelector)
(*in).DeepCopyInto(*out)
}
in.ScaleUp.DeepCopyInto(&out.ScaleUp)
in.ScaleDown.DeepCopyInto(&out.ScaleDown)
in.Template.DeepCopyInto(&out.Template)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HpaSpec.
func (in *HpaSpec) DeepCopy() *HpaSpec {
if in == nil {
return nil
}
out := new(HpaSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HpaStatus) DeepCopyInto(out *HpaStatus) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HpaStatus.
func (in *HpaStatus) DeepCopy() *HpaStatus {
if in == nil {
return nil
}
out := new(HpaStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HpaTemplate) DeepCopyInto(out *HpaTemplate) {
*out = *in
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HpaTemplate.
func (in *HpaTemplate) DeepCopy() *HpaTemplate {
if in == nil {
return nil
}
out := new(HpaTemplate)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HpaTemplateSpec) DeepCopyInto(out *HpaTemplateSpec) {
*out = *in
if in.MinReplicas != nil {
in, out := &in.MinReplicas, &out.MinReplicas
*out = new(int32)
**out = **in
}
if in.Metrics != nil {
in, out := &in.Metrics, &out.Metrics
*out = make([]v2beta1.MetricSpec, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HpaTemplateSpec.
func (in *HpaTemplateSpec) DeepCopy() *HpaTemplateSpec {
if in == nil {
return nil
}
out := new(HpaTemplateSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Hvpa) DeepCopyInto(out *Hvpa) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Hvpa.
func (in *Hvpa) DeepCopy() *Hvpa {
if in == nil {
return nil
}
out := new(Hvpa)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *Hvpa) 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 *HvpaList) DeepCopyInto(out *HvpaList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]Hvpa, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HvpaList.
func (in *HvpaList) DeepCopy() *HvpaList {
if in == nil {
return nil
}
out := new(HvpaList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *HvpaList) 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 *HvpaSpec) DeepCopyInto(out *HvpaSpec) {
*out = *in
if in.Replicas != nil {
in, out := &in.Replicas, &out.Replicas
*out = new(int32)
**out = **in
}
in.Hpa.DeepCopyInto(&out.Hpa)
in.Vpa.DeepCopyInto(&out.Vpa)
if in.WeightBasedScalingIntervals != nil {
in, out := &in.WeightBasedScalingIntervals, &out.WeightBasedScalingIntervals
*out = make([]WeightBasedScalingInterval, len(*in))
copy(*out, *in)
}
if in.TargetRef != nil {
in, out := &in.TargetRef, &out.TargetRef
*out = new(v2beta1.CrossVersionObjectReference)
**out = **in
}
if in.MaintenanceTimeWindow != nil {
in, out := &in.MaintenanceTimeWindow, &out.MaintenanceTimeWindow
*out = new(MaintenanceTimeWindow)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HvpaSpec.
func (in *HvpaSpec) DeepCopy() *HvpaSpec {
if in == nil {
return nil
}
out := new(HvpaSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HvpaStatus) DeepCopyInto(out *HvpaStatus) {
*out = *in
if in.Replicas != nil {
in, out := &in.Replicas, &out.Replicas
*out = new(int32)
**out = **in
}
if in.TargetSelector != nil {
in, out := &in.TargetSelector, &out.TargetSelector
*out = new(string)
**out = **in
}
if in.HpaScaleUpUpdatePolicy != nil {
in, out := &in.HpaScaleUpUpdatePolicy, &out.HpaScaleUpUpdatePolicy
*out = new(UpdatePolicy)
(*in).DeepCopyInto(*out)
}
if in.HpaScaleDownUpdatePolicy != nil {
in, out := &in.HpaScaleDownUpdatePolicy, &out.HpaScaleDownUpdatePolicy
*out = new(UpdatePolicy)
(*in).DeepCopyInto(*out)
}
if in.VpaScaleUpUpdatePolicy != nil {
in, out := &in.VpaScaleUpUpdatePolicy, &out.VpaScaleUpUpdatePolicy
*out = new(UpdatePolicy)
(*in).DeepCopyInto(*out)
}
if in.VpaScaleDownUpdatePolicy != nil {
in, out := &in.VpaScaleDownUpdatePolicy, &out.VpaScaleDownUpdatePolicy
*out = new(UpdatePolicy)
(*in).DeepCopyInto(*out)
}
if in.LastBlockedScaling != nil {
in, out := &in.LastBlockedScaling, &out.LastBlockedScaling
*out = make([]*BlockedScaling, len(*in))
for i := range *in {
if (*in)[i] != nil {
in, out := &(*in)[i], &(*out)[i]
*out = new(BlockedScaling)
(*in).DeepCopyInto(*out)
}
}
}
in.LastScaling.DeepCopyInto(&out.LastScaling)
if in.LastError != nil {
in, out := &in.LastError, &out.LastError
*out = new(LastError)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HvpaStatus.
func (in *HvpaStatus) DeepCopy() *HvpaStatus {
if in == nil {
return nil
}
out := new(HvpaStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *LastError) DeepCopyInto(out *LastError) {
*out = *in
in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LastError.
func (in *LastError) DeepCopy() *LastError {
if in == nil {
return nil
}
out := new(LastError)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MaintenanceTimeWindow) DeepCopyInto(out *MaintenanceTimeWindow) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MaintenanceTimeWindow.
func (in *MaintenanceTimeWindow) DeepCopy() *MaintenanceTimeWindow {
if in == nil {
return nil
}
out := new(MaintenanceTimeWindow)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ScaleParams) DeepCopyInto(out *ScaleParams) {
*out = *in
in.CPU.DeepCopyInto(&out.CPU)
in.Memory.DeepCopyInto(&out.Memory)
in.Replicas.DeepCopyInto(&out.Replicas)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ScaleParams.
func (in *ScaleParams) DeepCopy() *ScaleParams {
if in == nil {
return nil
}
out := new(ScaleParams)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ScaleType) DeepCopyInto(out *ScaleType) {
*out = *in
in.UpdatePolicy.DeepCopyInto(&out.UpdatePolicy)
in.MinChange.DeepCopyInto(&out.MinChange)
if in.StabilizationDuration != nil {
in, out := &in.StabilizationDuration, &out.StabilizationDuration
*out = new(string)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ScaleType.
func (in *ScaleType) DeepCopy() *ScaleType {
if in == nil {
return nil
}
out := new(ScaleType)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ScalingStatus) DeepCopyInto(out *ScalingStatus) {
*out = *in
if in.LastScaleTime != nil {
in, out := &in.LastScaleTime, &out.LastScaleTime
*out = new(v1.Time)
(*in).DeepCopyInto(*out)
}
out.HpaStatus = in.HpaStatus
in.VpaStatus.DeepCopyInto(&out.VpaStatus)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ScalingStatus.
func (in *ScalingStatus) DeepCopy() *ScalingStatus {
if in == nil {
return nil
}
out := new(ScalingStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *UpdatePolicy) DeepCopyInto(out *UpdatePolicy) {
*out = *in
if in.UpdateMode != nil {
in, out := &in.UpdateMode, &out.UpdateMode
*out = new(string)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpdatePolicy.
func (in *UpdatePolicy) DeepCopy() *UpdatePolicy {
if in == nil {
return nil
}
out := new(UpdatePolicy)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *VpaSpec) DeepCopyInto(out *VpaSpec) {
*out = *in
if in.Selector != nil {
in, out := &in.Selector, &out.Selector
*out = new(v1.LabelSelector)
(*in).DeepCopyInto(*out)
}
in.ScaleUp.DeepCopyInto(&out.ScaleUp)
in.ScaleDown.DeepCopyInto(&out.ScaleDown)
in.Template.DeepCopyInto(&out.Template)
in.LimitsRequestsGapScaleParams.DeepCopyInto(&out.LimitsRequestsGapScaleParams)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VpaSpec.
func (in *VpaSpec) DeepCopy() *VpaSpec {
if in == nil {
return nil
}
out := new(VpaSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *VpaTemplate) DeepCopyInto(out *VpaTemplate) {
*out = *in
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VpaTemplate.
func (in *VpaTemplate) DeepCopy() *VpaTemplate {
if in == nil {
return nil
}
out := new(VpaTemplate)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *VpaTemplateSpec) DeepCopyInto(out *VpaTemplateSpec) {
*out = *in
if in.ResourcePolicy != nil {
in, out := &in.ResourcePolicy, &out.ResourcePolicy
*out = new(v1beta2.PodResourcePolicy)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VpaTemplateSpec.
func (in *VpaTemplateSpec) DeepCopy() *VpaTemplateSpec {
if in == nil {
return nil
}
out := new(VpaTemplateSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *WeightBasedScalingInterval) DeepCopyInto(out *WeightBasedScalingInterval) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WeightBasedScalingInterval.
func (in *WeightBasedScalingInterval) DeepCopy() *WeightBasedScalingInterval {
if in == nil {
return nil
}
out := new(WeightBasedScalingInterval)
in.DeepCopyInto(out)
return out
}