mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Adding lifecycle to RC, RCSet, Deployment, and Job testutils
This commit is contained in:
parent
6392b69a1d
commit
24f15a5823
@ -131,6 +131,7 @@ type RCConfig struct {
|
|||||||
DNSPolicy *v1.DNSPolicy
|
DNSPolicy *v1.DNSPolicy
|
||||||
PriorityClassName string
|
PriorityClassName string
|
||||||
TerminationGracePeriodSeconds *int64
|
TerminationGracePeriodSeconds *int64
|
||||||
|
Lifecycle *v1.Lifecycle
|
||||||
|
|
||||||
// Env vars, set the same for every pod.
|
// Env vars, set the same for every pod.
|
||||||
Env map[string]string
|
Env map[string]string
|
||||||
@ -326,10 +327,11 @@ func (config *DeploymentConfig) create() error {
|
|||||||
TerminationGracePeriodSeconds: config.getTerminationGracePeriodSeconds(nil),
|
TerminationGracePeriodSeconds: config.getTerminationGracePeriodSeconds(nil),
|
||||||
Containers: []v1.Container{
|
Containers: []v1.Container{
|
||||||
{
|
{
|
||||||
Name: config.Name,
|
Name: config.Name,
|
||||||
Image: config.Image,
|
Image: config.Image,
|
||||||
Command: config.Command,
|
Command: config.Command,
|
||||||
Ports: []v1.ContainerPort{{ContainerPort: 80}},
|
Ports: []v1.ContainerPort{{ContainerPort: 80}},
|
||||||
|
Lifecycle: config.Lifecycle,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -407,10 +409,11 @@ func (config *ReplicaSetConfig) create() error {
|
|||||||
TerminationGracePeriodSeconds: config.getTerminationGracePeriodSeconds(nil),
|
TerminationGracePeriodSeconds: config.getTerminationGracePeriodSeconds(nil),
|
||||||
Containers: []v1.Container{
|
Containers: []v1.Container{
|
||||||
{
|
{
|
||||||
Name: config.Name,
|
Name: config.Name,
|
||||||
Image: config.Image,
|
Image: config.Image,
|
||||||
Command: config.Command,
|
Command: config.Command,
|
||||||
Ports: []v1.ContainerPort{{ContainerPort: 80}},
|
Ports: []v1.ContainerPort{{ContainerPort: 80}},
|
||||||
|
Lifecycle: config.Lifecycle,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -480,9 +483,10 @@ func (config *JobConfig) create() error {
|
|||||||
TerminationGracePeriodSeconds: config.getTerminationGracePeriodSeconds(nil),
|
TerminationGracePeriodSeconds: config.getTerminationGracePeriodSeconds(nil),
|
||||||
Containers: []v1.Container{
|
Containers: []v1.Container{
|
||||||
{
|
{
|
||||||
Name: config.Name,
|
Name: config.Name,
|
||||||
Image: config.Image,
|
Image: config.Image,
|
||||||
Command: config.Command,
|
Command: config.Command,
|
||||||
|
Lifecycle: config.Lifecycle,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
RestartPolicy: v1.RestartPolicyOnFailure,
|
RestartPolicy: v1.RestartPolicyOnFailure,
|
||||||
@ -597,6 +601,7 @@ func (config *RCConfig) create() error {
|
|||||||
Command: config.Command,
|
Command: config.Command,
|
||||||
Ports: []v1.ContainerPort{{ContainerPort: 80}},
|
Ports: []v1.ContainerPort{{ContainerPort: 80}},
|
||||||
ReadinessProbe: config.ReadinessProbe,
|
ReadinessProbe: config.ReadinessProbe,
|
||||||
|
Lifecycle: config.Lifecycle,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
DNSPolicy: *config.DNSPolicy,
|
DNSPolicy: *config.DNSPolicy,
|
||||||
@ -679,6 +684,9 @@ func (config *RCConfig) applyTo(template *v1.PodTemplateSpec) {
|
|||||||
if config.GpuLimit > 0 {
|
if config.GpuLimit > 0 {
|
||||||
template.Spec.Containers[0].Resources.Limits["nvidia.com/gpu"] = *resource.NewQuantity(config.GpuLimit, resource.DecimalSI)
|
template.Spec.Containers[0].Resources.Limits["nvidia.com/gpu"] = *resource.NewQuantity(config.GpuLimit, resource.DecimalSI)
|
||||||
}
|
}
|
||||||
|
if config.Lifecycle != nil {
|
||||||
|
template.Spec.Containers[0].Lifecycle = config.Lifecycle
|
||||||
|
}
|
||||||
if len(config.Volumes) > 0 {
|
if len(config.Volumes) > 0 {
|
||||||
template.Spec.Volumes = config.Volumes
|
template.Spec.Volumes = config.Volumes
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user