mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 12:18:16 +00:00 
			
		
		
		
	Adding lifecycle to RC, RCSet, Deployment, and Job testutils
This commit is contained in:
		@@ -131,6 +131,7 @@ type RCConfig struct {
 | 
			
		||||
	DNSPolicy                     *v1.DNSPolicy
 | 
			
		||||
	PriorityClassName             string
 | 
			
		||||
	TerminationGracePeriodSeconds *int64
 | 
			
		||||
	Lifecycle                     *v1.Lifecycle
 | 
			
		||||
 | 
			
		||||
	// Env vars, set the same for every pod.
 | 
			
		||||
	Env map[string]string
 | 
			
		||||
@@ -326,10 +327,11 @@ func (config *DeploymentConfig) create() error {
 | 
			
		||||
					TerminationGracePeriodSeconds: config.getTerminationGracePeriodSeconds(nil),
 | 
			
		||||
					Containers: []v1.Container{
 | 
			
		||||
						{
 | 
			
		||||
							Name:    config.Name,
 | 
			
		||||
							Image:   config.Image,
 | 
			
		||||
							Command: config.Command,
 | 
			
		||||
							Ports:   []v1.ContainerPort{{ContainerPort: 80}},
 | 
			
		||||
							Name:      config.Name,
 | 
			
		||||
							Image:     config.Image,
 | 
			
		||||
							Command:   config.Command,
 | 
			
		||||
							Ports:     []v1.ContainerPort{{ContainerPort: 80}},
 | 
			
		||||
							Lifecycle: config.Lifecycle,
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
@@ -407,10 +409,11 @@ func (config *ReplicaSetConfig) create() error {
 | 
			
		||||
					TerminationGracePeriodSeconds: config.getTerminationGracePeriodSeconds(nil),
 | 
			
		||||
					Containers: []v1.Container{
 | 
			
		||||
						{
 | 
			
		||||
							Name:    config.Name,
 | 
			
		||||
							Image:   config.Image,
 | 
			
		||||
							Command: config.Command,
 | 
			
		||||
							Ports:   []v1.ContainerPort{{ContainerPort: 80}},
 | 
			
		||||
							Name:      config.Name,
 | 
			
		||||
							Image:     config.Image,
 | 
			
		||||
							Command:   config.Command,
 | 
			
		||||
							Ports:     []v1.ContainerPort{{ContainerPort: 80}},
 | 
			
		||||
							Lifecycle: config.Lifecycle,
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
@@ -480,9 +483,10 @@ func (config *JobConfig) create() error {
 | 
			
		||||
					TerminationGracePeriodSeconds: config.getTerminationGracePeriodSeconds(nil),
 | 
			
		||||
					Containers: []v1.Container{
 | 
			
		||||
						{
 | 
			
		||||
							Name:    config.Name,
 | 
			
		||||
							Image:   config.Image,
 | 
			
		||||
							Command: config.Command,
 | 
			
		||||
							Name:      config.Name,
 | 
			
		||||
							Image:     config.Image,
 | 
			
		||||
							Command:   config.Command,
 | 
			
		||||
							Lifecycle: config.Lifecycle,
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					RestartPolicy: v1.RestartPolicyOnFailure,
 | 
			
		||||
@@ -597,6 +601,7 @@ func (config *RCConfig) create() error {
 | 
			
		||||
							Command:        config.Command,
 | 
			
		||||
							Ports:          []v1.ContainerPort{{ContainerPort: 80}},
 | 
			
		||||
							ReadinessProbe: config.ReadinessProbe,
 | 
			
		||||
							Lifecycle:      config.Lifecycle,
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					DNSPolicy:                     *config.DNSPolicy,
 | 
			
		||||
@@ -679,6 +684,9 @@ func (config *RCConfig) applyTo(template *v1.PodTemplateSpec) {
 | 
			
		||||
	if config.GpuLimit > 0 {
 | 
			
		||||
		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 {
 | 
			
		||||
		template.Spec.Volumes = config.Volumes
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user