mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-10-31 05:40:42 +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 | 	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 | ||||||
| @@ -330,6 +331,7 @@ func (config *DeploymentConfig) create() error { | |||||||
| 							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, | ||||||
| 						}, | 						}, | ||||||
| 					}, | 					}, | ||||||
| 				}, | 				}, | ||||||
| @@ -411,6 +413,7 @@ func (config *ReplicaSetConfig) create() error { | |||||||
| 							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, | ||||||
| 						}, | 						}, | ||||||
| 					}, | 					}, | ||||||
| 				}, | 				}, | ||||||
| @@ -483,6 +486,7 @@ func (config *JobConfig) create() error { | |||||||
| 							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 | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user