Merge pull request #102884 from vinaykul/restart-free-pod-vertical-scaling

In-place Pod Vertical Scaling feature

Kubernetes-commit: b9fd1802ba0aec68508b4e9eec00819008a79370
This commit is contained in:
Kubernetes Publisher 2023-02-27 22:53:15 -08:00
commit 8f4ee7119f
10 changed files with 221 additions and 61 deletions

View File

@ -25,28 +25,29 @@ import (
// ContainerApplyConfiguration represents an declarative configuration of the Container type for use
// with apply.
type ContainerApplyConfiguration struct {
Name *string `json:"name,omitempty"`
Image *string `json:"image,omitempty"`
Command []string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
WorkingDir *string `json:"workingDir,omitempty"`
Ports []ContainerPortApplyConfiguration `json:"ports,omitempty"`
EnvFrom []EnvFromSourceApplyConfiguration `json:"envFrom,omitempty"`
Env []EnvVarApplyConfiguration `json:"env,omitempty"`
Resources *ResourceRequirementsApplyConfiguration `json:"resources,omitempty"`
VolumeMounts []VolumeMountApplyConfiguration `json:"volumeMounts,omitempty"`
VolumeDevices []VolumeDeviceApplyConfiguration `json:"volumeDevices,omitempty"`
LivenessProbe *ProbeApplyConfiguration `json:"livenessProbe,omitempty"`
ReadinessProbe *ProbeApplyConfiguration `json:"readinessProbe,omitempty"`
StartupProbe *ProbeApplyConfiguration `json:"startupProbe,omitempty"`
Lifecycle *LifecycleApplyConfiguration `json:"lifecycle,omitempty"`
TerminationMessagePath *string `json:"terminationMessagePath,omitempty"`
TerminationMessagePolicy *corev1.TerminationMessagePolicy `json:"terminationMessagePolicy,omitempty"`
ImagePullPolicy *corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
SecurityContext *SecurityContextApplyConfiguration `json:"securityContext,omitempty"`
Stdin *bool `json:"stdin,omitempty"`
StdinOnce *bool `json:"stdinOnce,omitempty"`
TTY *bool `json:"tty,omitempty"`
Name *string `json:"name,omitempty"`
Image *string `json:"image,omitempty"`
Command []string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
WorkingDir *string `json:"workingDir,omitempty"`
Ports []ContainerPortApplyConfiguration `json:"ports,omitempty"`
EnvFrom []EnvFromSourceApplyConfiguration `json:"envFrom,omitempty"`
Env []EnvVarApplyConfiguration `json:"env,omitempty"`
Resources *ResourceRequirementsApplyConfiguration `json:"resources,omitempty"`
ResizePolicy []ContainerResizePolicyApplyConfiguration `json:"resizePolicy,omitempty"`
VolumeMounts []VolumeMountApplyConfiguration `json:"volumeMounts,omitempty"`
VolumeDevices []VolumeDeviceApplyConfiguration `json:"volumeDevices,omitempty"`
LivenessProbe *ProbeApplyConfiguration `json:"livenessProbe,omitempty"`
ReadinessProbe *ProbeApplyConfiguration `json:"readinessProbe,omitempty"`
StartupProbe *ProbeApplyConfiguration `json:"startupProbe,omitempty"`
Lifecycle *LifecycleApplyConfiguration `json:"lifecycle,omitempty"`
TerminationMessagePath *string `json:"terminationMessagePath,omitempty"`
TerminationMessagePolicy *corev1.TerminationMessagePolicy `json:"terminationMessagePolicy,omitempty"`
ImagePullPolicy *corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
SecurityContext *SecurityContextApplyConfiguration `json:"securityContext,omitempty"`
Stdin *bool `json:"stdin,omitempty"`
StdinOnce *bool `json:"stdinOnce,omitempty"`
TTY *bool `json:"tty,omitempty"`
}
// ContainerApplyConfiguration constructs an declarative configuration of the Container type for use with
@ -146,6 +147,19 @@ func (b *ContainerApplyConfiguration) WithResources(value *ResourceRequirementsA
return b
}
// WithResizePolicy adds the given value to the ResizePolicy field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the ResizePolicy field.
func (b *ContainerApplyConfiguration) WithResizePolicy(values ...*ContainerResizePolicyApplyConfiguration) *ContainerApplyConfiguration {
for i := range values {
if values[i] == nil {
panic("nil value passed to WithResizePolicy")
}
b.ResizePolicy = append(b.ResizePolicy, *values[i])
}
return b
}
// WithVolumeMounts adds the given value to the VolumeMounts field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the VolumeMounts field.

View File

@ -0,0 +1,52 @@
/*
Copyright 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.
*/
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v1
import (
v1 "k8s.io/api/core/v1"
)
// ContainerResizePolicyApplyConfiguration represents an declarative configuration of the ContainerResizePolicy type for use
// with apply.
type ContainerResizePolicyApplyConfiguration struct {
ResourceName *v1.ResourceName `json:"resourceName,omitempty"`
Policy *v1.ResourceResizePolicy `json:"policy,omitempty"`
}
// ContainerResizePolicyApplyConfiguration constructs an declarative configuration of the ContainerResizePolicy type for use with
// apply.
func ContainerResizePolicy() *ContainerResizePolicyApplyConfiguration {
return &ContainerResizePolicyApplyConfiguration{}
}
// WithResourceName sets the ResourceName field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the ResourceName field is set to the value of the last call.
func (b *ContainerResizePolicyApplyConfiguration) WithResourceName(value v1.ResourceName) *ContainerResizePolicyApplyConfiguration {
b.ResourceName = &value
return b
}
// WithPolicy sets the Policy field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Policy field is set to the value of the last call.
func (b *ContainerResizePolicyApplyConfiguration) WithPolicy(value v1.ResourceResizePolicy) *ContainerResizePolicyApplyConfiguration {
b.Policy = &value
return b
}

View File

@ -18,18 +18,24 @@ limitations under the License.
package v1
import (
corev1 "k8s.io/api/core/v1"
)
// ContainerStatusApplyConfiguration represents an declarative configuration of the ContainerStatus type for use
// with apply.
type ContainerStatusApplyConfiguration struct {
Name *string `json:"name,omitempty"`
State *ContainerStateApplyConfiguration `json:"state,omitempty"`
LastTerminationState *ContainerStateApplyConfiguration `json:"lastState,omitempty"`
Ready *bool `json:"ready,omitempty"`
RestartCount *int32 `json:"restartCount,omitempty"`
Image *string `json:"image,omitempty"`
ImageID *string `json:"imageID,omitempty"`
ContainerID *string `json:"containerID,omitempty"`
Started *bool `json:"started,omitempty"`
Name *string `json:"name,omitempty"`
State *ContainerStateApplyConfiguration `json:"state,omitempty"`
LastTerminationState *ContainerStateApplyConfiguration `json:"lastState,omitempty"`
Ready *bool `json:"ready,omitempty"`
RestartCount *int32 `json:"restartCount,omitempty"`
Image *string `json:"image,omitempty"`
ImageID *string `json:"imageID,omitempty"`
ContainerID *string `json:"containerID,omitempty"`
Started *bool `json:"started,omitempty"`
ResourcesAllocated *corev1.ResourceList `json:"resourcesAllocated,omitempty"`
Resources *ResourceRequirementsApplyConfiguration `json:"resources,omitempty"`
}
// ContainerStatusApplyConfiguration constructs an declarative configuration of the ContainerStatus type for use with
@ -109,3 +115,19 @@ func (b *ContainerStatusApplyConfiguration) WithStarted(value bool) *ContainerSt
b.Started = &value
return b
}
// WithResourcesAllocated sets the ResourcesAllocated field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the ResourcesAllocated field is set to the value of the last call.
func (b *ContainerStatusApplyConfiguration) WithResourcesAllocated(value corev1.ResourceList) *ContainerStatusApplyConfiguration {
b.ResourcesAllocated = &value
return b
}
// WithResources sets the Resources field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Resources field is set to the value of the last call.
func (b *ContainerStatusApplyConfiguration) WithResources(value *ResourceRequirementsApplyConfiguration) *ContainerStatusApplyConfiguration {
b.Resources = value
return b
}

View File

@ -126,6 +126,19 @@ func (b *EphemeralContainerApplyConfiguration) WithResources(value *ResourceRequ
return b
}
// WithResizePolicy adds the given value to the ResizePolicy field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the ResizePolicy field.
func (b *EphemeralContainerApplyConfiguration) WithResizePolicy(values ...*ContainerResizePolicyApplyConfiguration) *EphemeralContainerApplyConfiguration {
for i := range values {
if values[i] == nil {
panic("nil value passed to WithResizePolicy")
}
b.ResizePolicy = append(b.ResizePolicy, *values[i])
}
return b
}
// WithVolumeMounts adds the given value to the VolumeMounts field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the VolumeMounts field.

View File

@ -25,28 +25,29 @@ import (
// EphemeralContainerCommonApplyConfiguration represents an declarative configuration of the EphemeralContainerCommon type for use
// with apply.
type EphemeralContainerCommonApplyConfiguration struct {
Name *string `json:"name,omitempty"`
Image *string `json:"image,omitempty"`
Command []string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
WorkingDir *string `json:"workingDir,omitempty"`
Ports []ContainerPortApplyConfiguration `json:"ports,omitempty"`
EnvFrom []EnvFromSourceApplyConfiguration `json:"envFrom,omitempty"`
Env []EnvVarApplyConfiguration `json:"env,omitempty"`
Resources *ResourceRequirementsApplyConfiguration `json:"resources,omitempty"`
VolumeMounts []VolumeMountApplyConfiguration `json:"volumeMounts,omitempty"`
VolumeDevices []VolumeDeviceApplyConfiguration `json:"volumeDevices,omitempty"`
LivenessProbe *ProbeApplyConfiguration `json:"livenessProbe,omitempty"`
ReadinessProbe *ProbeApplyConfiguration `json:"readinessProbe,omitempty"`
StartupProbe *ProbeApplyConfiguration `json:"startupProbe,omitempty"`
Lifecycle *LifecycleApplyConfiguration `json:"lifecycle,omitempty"`
TerminationMessagePath *string `json:"terminationMessagePath,omitempty"`
TerminationMessagePolicy *corev1.TerminationMessagePolicy `json:"terminationMessagePolicy,omitempty"`
ImagePullPolicy *corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
SecurityContext *SecurityContextApplyConfiguration `json:"securityContext,omitempty"`
Stdin *bool `json:"stdin,omitempty"`
StdinOnce *bool `json:"stdinOnce,omitempty"`
TTY *bool `json:"tty,omitempty"`
Name *string `json:"name,omitempty"`
Image *string `json:"image,omitempty"`
Command []string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
WorkingDir *string `json:"workingDir,omitempty"`
Ports []ContainerPortApplyConfiguration `json:"ports,omitempty"`
EnvFrom []EnvFromSourceApplyConfiguration `json:"envFrom,omitempty"`
Env []EnvVarApplyConfiguration `json:"env,omitempty"`
Resources *ResourceRequirementsApplyConfiguration `json:"resources,omitempty"`
ResizePolicy []ContainerResizePolicyApplyConfiguration `json:"resizePolicy,omitempty"`
VolumeMounts []VolumeMountApplyConfiguration `json:"volumeMounts,omitempty"`
VolumeDevices []VolumeDeviceApplyConfiguration `json:"volumeDevices,omitempty"`
LivenessProbe *ProbeApplyConfiguration `json:"livenessProbe,omitempty"`
ReadinessProbe *ProbeApplyConfiguration `json:"readinessProbe,omitempty"`
StartupProbe *ProbeApplyConfiguration `json:"startupProbe,omitempty"`
Lifecycle *LifecycleApplyConfiguration `json:"lifecycle,omitempty"`
TerminationMessagePath *string `json:"terminationMessagePath,omitempty"`
TerminationMessagePolicy *corev1.TerminationMessagePolicy `json:"terminationMessagePolicy,omitempty"`
ImagePullPolicy *corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
SecurityContext *SecurityContextApplyConfiguration `json:"securityContext,omitempty"`
Stdin *bool `json:"stdin,omitempty"`
StdinOnce *bool `json:"stdinOnce,omitempty"`
TTY *bool `json:"tty,omitempty"`
}
// EphemeralContainerCommonApplyConfiguration constructs an declarative configuration of the EphemeralContainerCommon type for use with
@ -146,6 +147,19 @@ func (b *EphemeralContainerCommonApplyConfiguration) WithResources(value *Resour
return b
}
// WithResizePolicy adds the given value to the ResizePolicy field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the ResizePolicy field.
func (b *EphemeralContainerCommonApplyConfiguration) WithResizePolicy(values ...*ContainerResizePolicyApplyConfiguration) *EphemeralContainerCommonApplyConfiguration {
for i := range values {
if values[i] == nil {
panic("nil value passed to WithResizePolicy")
}
b.ResizePolicy = append(b.ResizePolicy, *values[i])
}
return b
}
// WithVolumeMounts adds the given value to the VolumeMounts field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the VolumeMounts field.

View File

@ -39,6 +39,7 @@ type PodStatusApplyConfiguration struct {
ContainerStatuses []ContainerStatusApplyConfiguration `json:"containerStatuses,omitempty"`
QOSClass *v1.PodQOSClass `json:"qosClass,omitempty"`
EphemeralContainerStatuses []ContainerStatusApplyConfiguration `json:"ephemeralContainerStatuses,omitempty"`
Resize *v1.PodResizeStatus `json:"resize,omitempty"`
}
// PodStatusApplyConfiguration constructs an declarative configuration of the PodStatus type for use with
@ -175,3 +176,11 @@ func (b *PodStatusApplyConfiguration) WithEphemeralContainerStatuses(values ...*
}
return b
}
// WithResize sets the Resize field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Resize field is set to the value of the last call.
func (b *PodStatusApplyConfiguration) WithResize(value v1.PodResizeStatus) *PodStatusApplyConfiguration {
b.Resize = &value
return b
}

View File

@ -4129,6 +4129,12 @@ var schemaYAML = typed.YAMLObject(`types:
- name: readinessProbe
type:
namedType: io.k8s.api.core.v1.Probe
- name: resizePolicy
type:
list:
elementType:
namedType: io.k8s.api.core.v1.ContainerResizePolicy
elementRelationship: atomic
- name: resources
type:
namedType: io.k8s.api.core.v1.ResourceRequirements
@ -4205,6 +4211,17 @@ var schemaYAML = typed.YAMLObject(`types:
type:
scalar: string
default: TCP
- name: io.k8s.api.core.v1.ContainerResizePolicy
map:
fields:
- name: policy
type:
scalar: string
default: ""
- name: resourceName
type:
scalar: string
default: ""
- name: io.k8s.api.core.v1.ContainerState
map:
fields:
@ -4286,6 +4303,14 @@ var schemaYAML = typed.YAMLObject(`types:
type:
scalar: boolean
default: false
- name: resources
type:
namedType: io.k8s.api.core.v1.ResourceRequirements
- name: resourcesAllocated
type:
map:
elementType:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: restartCount
type:
scalar: numeric
@ -4521,6 +4546,12 @@ var schemaYAML = typed.YAMLObject(`types:
- name: readinessProbe
type:
namedType: io.k8s.api.core.v1.Probe
- name: resizePolicy
type:
list:
elementType:
namedType: io.k8s.api.core.v1.ContainerResizePolicy
elementRelationship: atomic
- name: resources
type:
namedType: io.k8s.api.core.v1.ResourceRequirements
@ -6185,6 +6216,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: reason
type:
scalar: string
- name: resize
type:
scalar: string
- name: startTime
type:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time

View File

@ -579,6 +579,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
return &applyconfigurationscorev1.ContainerImageApplyConfiguration{}
case corev1.SchemeGroupVersion.WithKind("ContainerPort"):
return &applyconfigurationscorev1.ContainerPortApplyConfiguration{}
case corev1.SchemeGroupVersion.WithKind("ContainerResizePolicy"):
return &applyconfigurationscorev1.ContainerResizePolicyApplyConfiguration{}
case corev1.SchemeGroupVersion.WithKind("ContainerState"):
return &applyconfigurationscorev1.ContainerStateApplyConfiguration{}
case corev1.SchemeGroupVersion.WithKind("ContainerStateRunning"):

8
go.mod
View File

@ -24,8 +24,8 @@ require (
golang.org/x/term v0.5.0
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8
google.golang.org/protobuf v1.28.1
k8s.io/api v0.0.0-20230224170233-ec40acc5b8d7
k8s.io/apimachinery v0.0.0-20230223090012-28259f54ab7d
k8s.io/api v0.0.0-20230228090259-b5b22ca1babf
k8s.io/apimachinery v0.0.0-20230227225516-80f59387d3d1
k8s.io/klog/v2 v2.80.1
k8s.io/kube-openapi v0.0.0-20230123231816-1cb3ae25d79a
k8s.io/utils v0.0.0-20230209194617-a36077c30491
@ -59,6 +59,6 @@ require (
)
replace (
k8s.io/api => k8s.io/api v0.0.0-20230224170233-ec40acc5b8d7
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20230223090012-28259f54ab7d
k8s.io/api => k8s.io/api v0.0.0-20230228090259-b5b22ca1babf
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20230227225516-80f59387d3d1
)

8
go.sum
View File

@ -473,10 +473,10 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
k8s.io/api v0.0.0-20230224170233-ec40acc5b8d7 h1:QRn9B/c3nFBOr/y1ZvkxSj+8csklqfM0eKhJhQ7ujCo=
k8s.io/api v0.0.0-20230224170233-ec40acc5b8d7/go.mod h1:ZgBZcyAg9mrSMLoN3CT3jXA80Nglj1iAeLPjz64hQZ8=
k8s.io/apimachinery v0.0.0-20230223090012-28259f54ab7d h1:/diE2y6H2T5l0s265p3l0Dfi4S9vAH3mx0azm51dyEM=
k8s.io/apimachinery v0.0.0-20230223090012-28259f54ab7d/go.mod h1:8B/+OdWlScxVvirboh1J5IZSHQrCreQ7fi/5UQntvX0=
k8s.io/api v0.0.0-20230228090259-b5b22ca1babf h1:nOM4wjFnU0nlgQ5xSvS24ayMbBOFw1N/jyEj4ni0ugA=
k8s.io/api v0.0.0-20230228090259-b5b22ca1babf/go.mod h1:XAyCRdxxjlGJLzvSsIhA8Ccnsryd6Xh0CgmB3ah3AmQ=
k8s.io/apimachinery v0.0.0-20230227225516-80f59387d3d1 h1:Any9/HFr7VOfgDnp+b98WhCql/Tup2fuQD4QYMMSt60=
k8s.io/apimachinery v0.0.0-20230227225516-80f59387d3d1/go.mod h1:8B/+OdWlScxVvirboh1J5IZSHQrCreQ7fi/5UQntvX0=
k8s.io/klog/v2 v2.80.1 h1:atnLQ121W371wYYFawwYx1aEY2eUfs4l3J72wtgAwV4=
k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
k8s.io/kube-openapi v0.0.0-20230123231816-1cb3ae25d79a h1:s6zvHjyDQX1NtVT88pvw2tddqhqY0Bz0Gbnn+yctsFU=