mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
Adding termination grace period to Deployment, RC, RCSet, and Job
This commit is contained in:
parent
96439cc97f
commit
6392b69a1d
@ -111,25 +111,26 @@ type RunObjectConfig interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type RCConfig struct {
|
type RCConfig struct {
|
||||||
Affinity *v1.Affinity
|
Affinity *v1.Affinity
|
||||||
Client clientset.Interface
|
Client clientset.Interface
|
||||||
ScalesGetter scaleclient.ScalesGetter
|
ScalesGetter scaleclient.ScalesGetter
|
||||||
Image string
|
Image string
|
||||||
Command []string
|
Command []string
|
||||||
Name string
|
Name string
|
||||||
Namespace string
|
Namespace string
|
||||||
PollInterval time.Duration
|
PollInterval time.Duration
|
||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
PodStatusFile *os.File
|
PodStatusFile *os.File
|
||||||
Replicas int
|
Replicas int
|
||||||
CpuRequest int64 // millicores
|
CpuRequest int64 // millicores
|
||||||
CpuLimit int64 // millicores
|
CpuLimit int64 // millicores
|
||||||
MemRequest int64 // bytes
|
MemRequest int64 // bytes
|
||||||
MemLimit int64 // bytes
|
MemLimit int64 // bytes
|
||||||
GpuLimit int64 // count
|
GpuLimit int64 // count
|
||||||
ReadinessProbe *v1.Probe
|
ReadinessProbe *v1.Probe
|
||||||
DNSPolicy *v1.DNSPolicy
|
DNSPolicy *v1.DNSPolicy
|
||||||
PriorityClassName string
|
PriorityClassName string
|
||||||
|
TerminationGracePeriodSeconds *int64
|
||||||
|
|
||||||
// Env vars, set the same for every pod.
|
// Env vars, set the same for every pod.
|
||||||
Env map[string]string
|
Env map[string]string
|
||||||
@ -321,7 +322,8 @@ func (config *DeploymentConfig) create() error {
|
|||||||
Annotations: config.Annotations,
|
Annotations: config.Annotations,
|
||||||
},
|
},
|
||||||
Spec: v1.PodSpec{
|
Spec: v1.PodSpec{
|
||||||
Affinity: config.Affinity,
|
Affinity: config.Affinity,
|
||||||
|
TerminationGracePeriodSeconds: config.getTerminationGracePeriodSeconds(nil),
|
||||||
Containers: []v1.Container{
|
Containers: []v1.Container{
|
||||||
{
|
{
|
||||||
Name: config.Name,
|
Name: config.Name,
|
||||||
@ -401,7 +403,8 @@ func (config *ReplicaSetConfig) create() error {
|
|||||||
Annotations: config.Annotations,
|
Annotations: config.Annotations,
|
||||||
},
|
},
|
||||||
Spec: v1.PodSpec{
|
Spec: v1.PodSpec{
|
||||||
Affinity: config.Affinity,
|
Affinity: config.Affinity,
|
||||||
|
TerminationGracePeriodSeconds: config.getTerminationGracePeriodSeconds(nil),
|
||||||
Containers: []v1.Container{
|
Containers: []v1.Container{
|
||||||
{
|
{
|
||||||
Name: config.Name,
|
Name: config.Name,
|
||||||
@ -473,7 +476,8 @@ func (config *JobConfig) create() error {
|
|||||||
Annotations: config.Annotations,
|
Annotations: config.Annotations,
|
||||||
},
|
},
|
||||||
Spec: v1.PodSpec{
|
Spec: v1.PodSpec{
|
||||||
Affinity: config.Affinity,
|
Affinity: config.Affinity,
|
||||||
|
TerminationGracePeriodSeconds: config.getTerminationGracePeriodSeconds(nil),
|
||||||
Containers: []v1.Container{
|
Containers: []v1.Container{
|
||||||
{
|
{
|
||||||
Name: config.Name,
|
Name: config.Name,
|
||||||
@ -598,7 +602,7 @@ func (config *RCConfig) create() error {
|
|||||||
DNSPolicy: *config.DNSPolicy,
|
DNSPolicy: *config.DNSPolicy,
|
||||||
NodeSelector: config.NodeSelector,
|
NodeSelector: config.NodeSelector,
|
||||||
Tolerations: config.Tolerations,
|
Tolerations: config.Tolerations,
|
||||||
TerminationGracePeriodSeconds: &one,
|
TerminationGracePeriodSeconds: config.getTerminationGracePeriodSeconds(&one),
|
||||||
PriorityClassName: config.PriorityClassName,
|
PriorityClassName: config.PriorityClassName,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1537,6 +1541,13 @@ func attachConfigMaps(template *v1.PodTemplateSpec, configMapNames []string) {
|
|||||||
template.Spec.Containers[0].VolumeMounts = mounts
|
template.Spec.Containers[0].VolumeMounts = mounts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (config *RCConfig) getTerminationGracePeriodSeconds(defaultGrace *int64) *int64 {
|
||||||
|
if config.TerminationGracePeriodSeconds == nil || *config.TerminationGracePeriodSeconds < 0 {
|
||||||
|
return defaultGrace
|
||||||
|
}
|
||||||
|
return config.TerminationGracePeriodSeconds
|
||||||
|
}
|
||||||
|
|
||||||
func attachServiceAccountTokenProjection(template *v1.PodTemplateSpec, name string) {
|
func attachServiceAccountTokenProjection(template *v1.PodTemplateSpec, name string) {
|
||||||
template.Spec.Containers[0].VolumeMounts = append(template.Spec.Containers[0].VolumeMounts,
|
template.Spec.Containers[0].VolumeMounts = append(template.Spec.Containers[0].VolumeMounts,
|
||||||
v1.VolumeMount{
|
v1.VolumeMount{
|
||||||
|
Loading…
Reference in New Issue
Block a user