Add possibility to set Jenkins master pod's priority

Allow to set priorityClassName for master pod. This will make possible
for jenkins master to either not be preempted on other's pod low
resources or to preempt lesser priority pods on resources shortage.

Ref: https://github.com/jenkinsci/kubernetes-operator/issues/321
This commit is contained in:
Oleksandr Kovalchuk
2020-04-09 11:06:56 +03:00
parent 5dc125f308
commit 68ffc69d41
3 changed files with 11 additions and 0 deletions
@@ -374,6 +374,10 @@ type JenkinsMaster struct {
// DisableCSRFProtection allows you to toggle CSRF Protection on Jenkins
DisableCSRFProtection bool `json:"disableCSRFProtection"`
// PriorityClassName for Jenkins master pod
// +optional
PriorityClassName string `json:"priorityClassName,omitempty"`
}
// Service defines Kubernetes service attributes
@@ -648,6 +648,12 @@ func (r *ReconcileJenkinsBaseConfiguration) checkForPodRecreation(currentJenkins
len(currentJenkinsMasterPod.Spec.Containers), len(r.Configuration.Jenkins.Spec.Master.Containers)))
}
if r.Configuration.Jenkins.Spec.Master.PriorityClassName != currentJenkinsMasterPod.Spec.PriorityClassName {
messages = append(messages, "Jenkins priorityClassName has changed")
verbose = append(verbose, fmt.Sprintf("Jenkins priorityClassName has changed, actual '%+v' required '%+v'",
currentJenkinsMasterPod.Spec.PriorityClassName, r.Configuration.Jenkins.Spec.Master.PriorityClassName))
}
customResourceReplaced := (r.Configuration.Jenkins.Status.BaseConfigurationCompletedTime == nil ||
r.Configuration.Jenkins.Status.UserConfigurationCompletedTime == nil) &&
r.Configuration.Jenkins.Status.UserAndPasswordHash == ""
@@ -328,6 +328,7 @@ func NewJenkinsMasterPod(objectMeta metav1.ObjectMeta, jenkins *v1alpha2.Jenkins
SecurityContext: jenkins.Spec.Master.SecurityContext,
ImagePullSecrets: jenkins.Spec.Master.ImagePullSecrets,
Tolerations: jenkins.Spec.Master.Tolerations,
PriorityClassName: jenkins.Spec.Master.PriorityClassName,
},
}
}