Allow to specify seed agent image (#718)
* Allow to specify seed agent image * Fix formatting issue * Add optional for documentation * Add entry for helm chart * Add default value for helm chart Co-authored-by: bhubert <bhubert@expediagroup.com>
This commit is contained in:
		
							parent
							
								
									46f64fea6a
								
							
						
					
					
						commit
						56b65aed16
					
				|  | @ -18,6 +18,10 @@ type JenkinsSpec struct { | ||||||
| 	// +optional
 | 	// +optional
 | ||||||
| 	SeedJobs []SeedJob `json:"seedJobs,omitempty"` | 	SeedJobs []SeedJob `json:"seedJobs,omitempty"` | ||||||
| 
 | 
 | ||||||
|  | 	// SeedJobAgentImage defines the image that will be used by the seed job agent. If not defined jenkins/inbound-agent:4.9-1 will be used.
 | ||||||
|  | 	// +optional
 | ||||||
|  | 	SeedJobAgentImage string `json:"seedJobAgentImage,omitempty"` | ||||||
|  | 
 | ||||||
| 	// ValidateSecurityWarnings enables or disables validating potential security warnings in Jenkins plugins via admission webhooks.
 | 	// ValidateSecurityWarnings enables or disables validating potential security warnings in Jenkins plugins via admission webhooks.
 | ||||||
| 	//+optional
 | 	//+optional
 | ||||||
| 	ValidateSecurityWarnings bool `json:"validateSecurityWarnings,omitempty"` | 	ValidateSecurityWarnings bool `json:"validateSecurityWarnings,omitempty"` | ||||||
|  |  | ||||||
|  | @ -3118,6 +3118,9 @@ spec: | ||||||
|                   - name |                   - name | ||||||
|                   type: object |                   type: object | ||||||
|                 type: array |                 type: array | ||||||
|  |               seedJobAgentImage: | ||||||
|  |                   type: string | ||||||
|  |                   description: 'SeedJobAgentImage defines the image that will be used by the seed job agent. If not defined jenkins/inbound-agent:4.9-1 will be used.' | ||||||
|               seedJobs: |               seedJobs: | ||||||
|                 description: 'SeedJobs defines list of Jenkins Seed Job configurations |                 description: 'SeedJobs defines list of Jenkins Seed Job configurations | ||||||
|                   More info: https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configuration#configure-seed-jobs-and-pipelines' |                   More info: https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configuration#configure-seed-jobs-and-pipelines' | ||||||
|  |  | ||||||
|  | @ -111,6 +111,9 @@ jenkins: | ||||||
|   #    repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git |   #    repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git | ||||||
|   seedJobs: [] |   seedJobs: [] | ||||||
| 
 | 
 | ||||||
|  |   # SeedJobAgentImage defines the image that will be used by the seed job agent. If not defined jenkins/inbound-agent:4.9-1 will be used. | ||||||
|  |   seedJobAgentImage: "" | ||||||
|  | 
 | ||||||
|   # Resource limit/request for Jenkins |   # Resource limit/request for Jenkins | ||||||
|   # See https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/ for details |   # See https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/ for details | ||||||
|   resources: |   resources: | ||||||
|  |  | ||||||
|  | @ -45,6 +45,9 @@ const ( | ||||||
| 	// AgentName is the name of seed job agent
 | 	// AgentName is the name of seed job agent
 | ||||||
| 	AgentName = "seed-job-agent" | 	AgentName = "seed-job-agent" | ||||||
| 
 | 
 | ||||||
|  | 	// DefaultAgentImage is the default image used for the seed-job agent
 | ||||||
|  | 	defaultAgentImage = "jenkins/inbound-agent:4.9-1" | ||||||
|  | 
 | ||||||
| 	creatingGroovyScriptName = "seed-job-groovy-script.groovy" | 	creatingGroovyScriptName = "seed-job-groovy-script.groovy" | ||||||
| 
 | 
 | ||||||
| 	homeVolumeName = "home" | 	homeVolumeName = "home" | ||||||
|  | @ -416,6 +419,11 @@ func agentDeployment(jenkins *v1alpha2.Jenkins, namespace string, agentName stri | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	agentImage := jenkins.Spec.SeedJobAgentImage | ||||||
|  | 	if jenkins.Spec.SeedJobAgentImage == "" { | ||||||
|  | 		agentImage = defaultAgentImage | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	suffix := "" | 	suffix := "" | ||||||
| 	if prefix, ok := resources.GetJenkinsOpts(*jenkins)["prefix"]; ok { | 	if prefix, ok := resources.GetJenkinsOpts(*jenkins)["prefix"]; ok { | ||||||
| 		suffix = prefix | 		suffix = prefix | ||||||
|  | @ -445,7 +453,7 @@ func agentDeployment(jenkins *v1alpha2.Jenkins, namespace string, agentName stri | ||||||
| 					Containers: []corev1.Container{ | 					Containers: []corev1.Container{ | ||||||
| 						{ | 						{ | ||||||
| 							Name:  "jnlp", | 							Name:  "jnlp", | ||||||
| 							Image: "jenkins/inbound-agent:4.9-1", | 							Image: agentImage, | ||||||
| 							Env: []corev1.EnvVar{ | 							Env: []corev1.EnvVar{ | ||||||
| 								{ | 								{ | ||||||
| 									Name: "JENKINS_TUNNEL", | 									Name: "JENKINS_TUNNEL", | ||||||
|  |  | ||||||
|  | @ -113,6 +113,7 @@ func TestEnsureSeedJobs(t *testing.T) { | ||||||
| 		var agentDeployment appsv1.Deployment | 		var agentDeployment appsv1.Deployment | ||||||
| 		err = fakeClient.Get(ctx, types.NamespacedName{Namespace: jenkins.Namespace, Name: agentDeploymentName(*jenkins, AgentName)}, &agentDeployment) | 		err = fakeClient.Get(ctx, types.NamespacedName{Namespace: jenkins.Namespace, Name: agentDeploymentName(*jenkins, AgentName)}, &agentDeployment) | ||||||
| 		assert.NoError(t, err) | 		assert.NoError(t, err) | ||||||
|  | 		assert.Equal(t, "jenkins/inbound-agent:4.9-1", agentDeployment.Spec.Template.Spec.Containers[0].Image) | ||||||
| 	}) | 	}) | ||||||
| 
 | 
 | ||||||
| 	t.Run("delete agent deployment when no seed jobs", func(t *testing.T) { | 	t.Run("delete agent deployment when no seed jobs", func(t *testing.T) { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue