feat: expose jenkins master terminationGracePeriodSeconds (#1012)
Co-authored-by: brokenpip3 <brokenpip3@gmail.com>
This commit is contained in:
parent
061995a65c
commit
18197e66b7
|
|
@ -386,6 +386,13 @@ type JenkinsMaster struct {
|
||||||
// HostAliases for Jenkins master pod and SeedJob agent
|
// HostAliases for Jenkins master pod and SeedJob agent
|
||||||
// +optional
|
// +optional
|
||||||
HostAliases []corev1.HostAlias `json:"hostAliases,omitempty"`
|
HostAliases []corev1.HostAlias `json:"hostAliases,omitempty"`
|
||||||
|
|
||||||
|
// The grace period is the duration in seconds after the processes running in the pod are sent
|
||||||
|
// a termination signal and the time when the processes are forcibly halted with a kill signal.
|
||||||
|
// Set this value longer than the expected cleanup time for your process.
|
||||||
|
// Defaults to 30 seconds.
|
||||||
|
// +optional
|
||||||
|
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Service defines Kubernetes service attributes
|
// Service defines Kubernetes service attributes
|
||||||
|
|
|
||||||
|
|
@ -368,6 +368,11 @@ func (in *JenkinsMaster) DeepCopyInto(out *JenkinsMaster) {
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if in.TerminationGracePeriodSeconds != nil {
|
||||||
|
in, out := &in.TerminationGracePeriodSeconds, &out.TerminationGracePeriodSeconds
|
||||||
|
*out = new(int64)
|
||||||
|
**out = **in
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JenkinsMaster.
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JenkinsMaster.
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ Kubernetes native operator which fully manages Jenkins on Kubernetes
|
||||||
| jenkins.seedJobAgentImage | string | `""` | |
|
| jenkins.seedJobAgentImage | string | `""` | |
|
||||||
| jenkins.seedJobs | list | `[]` | |
|
| jenkins.seedJobs | list | `[]` | |
|
||||||
| jenkins.serviceAccount.annotations | object | `{}` | |
|
| jenkins.serviceAccount.annotations | object | `{}` | |
|
||||||
|
| jenkins.terminationGracePeriodSeconds | int | `30` | |
|
||||||
| jenkins.tolerations | list | `[]` | |
|
| jenkins.tolerations | list | `[]` | |
|
||||||
| jenkins.validateSecurityWarnings | bool | `false` | |
|
| jenkins.validateSecurityWarnings | bool | `false` | |
|
||||||
| jenkins.volumeMounts | list | `[]` | |
|
| jenkins.volumeMounts | list | `[]` | |
|
||||||
|
|
|
||||||
|
|
@ -1330,6 +1330,10 @@ spec:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
type: object
|
type: object
|
||||||
|
terminationGracePeriodSeconds:
|
||||||
|
description: 'Optional duration in seconds the pod needs to terminate gracefully.'
|
||||||
|
type: integer
|
||||||
|
default: 30
|
||||||
tolerations:
|
tolerations:
|
||||||
description: If specified, the pod's tolerations.
|
description: If specified, the pod's tolerations.
|
||||||
items:
|
items:
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,9 @@ spec:
|
||||||
{{- with .Values.jenkins.hostAliases }}
|
{{- with .Values.jenkins.hostAliases }}
|
||||||
hostAliases: {{ toYaml . | nindent 4 }}
|
hostAliases: {{ toYaml . | nindent 4 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if .Values.jenkins.terminationGracePeriodSeconds }}
|
||||||
|
terminationGracePeriodSeconds: {{ .Values.jenkins.terminationGracePeriodSeconds }}
|
||||||
|
{{- end }}
|
||||||
containers:
|
containers:
|
||||||
- name: jenkins-master
|
- name: jenkins-master
|
||||||
image: {{ .Values.jenkins.image }}
|
image: {{ .Values.jenkins.image }}
|
||||||
|
|
@ -137,7 +140,7 @@ spec:
|
||||||
{{- if .Values.jenkins.backup.enabled }}
|
{{- if .Values.jenkins.backup.enabled }}
|
||||||
- name: {{ .Values.jenkins.backup.containerName }}
|
- name: {{ .Values.jenkins.backup.containerName }}
|
||||||
image: {{ .Values.jenkins.backup.image }}
|
image: {{ .Values.jenkins.backup.image }}
|
||||||
imagePullPolicy: {{ .Values.jenkins.imagePullPolicy }}
|
imagePullPolicy: {{ .Values.jenkins.imagePullPolicy }}
|
||||||
{{- with .Values.jenkins.backup.resources }}
|
{{- with .Values.jenkins.backup.resources }}
|
||||||
resources: {{ toYaml . | nindent 10 }}
|
resources: {{ toYaml . | nindent 10 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,10 @@ jenkins:
|
||||||
# - "foo.remote"
|
# - "foo.remote"
|
||||||
# - "bar.remote"
|
# - "bar.remote"
|
||||||
|
|
||||||
|
# Optional duration in seconds the pod needs to terminate gracefully.
|
||||||
|
# Default 30sec
|
||||||
|
terminationGracePeriodSeconds: 30
|
||||||
|
|
||||||
# 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.
|
||||||
validateSecurityWarnings: false
|
validateSecurityWarnings: false
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1330,6 +1330,14 @@ spec:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
type: object
|
type: object
|
||||||
|
terminationGracePeriodSeconds:
|
||||||
|
description: The grace period is the duration in seconds after
|
||||||
|
the processes running in the pod are sent a termination signal
|
||||||
|
and the time when the processes are forcibly halted with a kill
|
||||||
|
signal. Set this value longer than the expected cleanup time
|
||||||
|
for your process. Defaults to 30 seconds.
|
||||||
|
format: int64
|
||||||
|
type: integer
|
||||||
tolerations:
|
tolerations:
|
||||||
description: If specified, the pod's tolerations.
|
description: If specified, the pod's tolerations.
|
||||||
items:
|
items:
|
||||||
|
|
|
||||||
|
|
@ -369,20 +369,26 @@ func NewJenkinsMasterPod(objectMeta metav1.ObjectMeta, jenkins *v1alpha2.Jenkins
|
||||||
objectMeta.Name = GetJenkinsMasterPodName(jenkins)
|
objectMeta.Name = GetJenkinsMasterPodName(jenkins)
|
||||||
objectMeta.Labels = GetJenkinsMasterPodLabels(*jenkins)
|
objectMeta.Labels = GetJenkinsMasterPodLabels(*jenkins)
|
||||||
|
|
||||||
|
if jenkins.Spec.Master.TerminationGracePeriodSeconds == nil {
|
||||||
|
defaultGracePeriod := constants.DefaultTerminationGracePeriodSeconds
|
||||||
|
jenkins.Spec.Master.TerminationGracePeriodSeconds = &defaultGracePeriod
|
||||||
|
}
|
||||||
|
|
||||||
return &corev1.Pod{
|
return &corev1.Pod{
|
||||||
TypeMeta: buildPodTypeMeta(),
|
TypeMeta: buildPodTypeMeta(),
|
||||||
ObjectMeta: objectMeta,
|
ObjectMeta: objectMeta,
|
||||||
Spec: corev1.PodSpec{
|
Spec: corev1.PodSpec{
|
||||||
ServiceAccountName: serviceAccountName,
|
ServiceAccountName: serviceAccountName,
|
||||||
RestartPolicy: corev1.RestartPolicyNever,
|
RestartPolicy: corev1.RestartPolicyNever,
|
||||||
NodeSelector: jenkins.Spec.Master.NodeSelector,
|
NodeSelector: jenkins.Spec.Master.NodeSelector,
|
||||||
Containers: newContainers(jenkins),
|
Containers: newContainers(jenkins),
|
||||||
Volumes: append(GetJenkinsMasterPodBaseVolumes(jenkins), jenkins.Spec.Master.Volumes...),
|
Volumes: append(GetJenkinsMasterPodBaseVolumes(jenkins), jenkins.Spec.Master.Volumes...),
|
||||||
SecurityContext: jenkins.Spec.Master.SecurityContext,
|
SecurityContext: jenkins.Spec.Master.SecurityContext,
|
||||||
ImagePullSecrets: jenkins.Spec.Master.ImagePullSecrets,
|
ImagePullSecrets: jenkins.Spec.Master.ImagePullSecrets,
|
||||||
Tolerations: jenkins.Spec.Master.Tolerations,
|
Tolerations: jenkins.Spec.Master.Tolerations,
|
||||||
PriorityClassName: jenkins.Spec.Master.PriorityClassName,
|
PriorityClassName: jenkins.Spec.Master.PriorityClassName,
|
||||||
HostAliases: jenkins.Spec.Master.HostAliases,
|
HostAliases: jenkins.Spec.Master.HostAliases,
|
||||||
|
TerminationGracePeriodSeconds: jenkins.Spec.Master.TerminationGracePeriodSeconds,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,6 @@ const (
|
||||||
DefaultSlavePortInt32 = int32(50000)
|
DefaultSlavePortInt32 = int32(50000)
|
||||||
// JavaOpsVariableName is the name of environment variable which consists Jenkins Java options
|
// JavaOpsVariableName is the name of environment variable which consists Jenkins Java options
|
||||||
JavaOpsVariableName = "JAVA_OPTS"
|
JavaOpsVariableName = "JAVA_OPTS"
|
||||||
|
// DefaultTerminationGracePeriodSeconds is the default pod termination period second
|
||||||
|
DefaultTerminationGracePeriodSeconds = int64(30)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,8 @@ func verifyJenkinsMasterPodAttributes(jenkins *v1alpha2.Jenkins) {
|
||||||
jenkinsPod := getJenkinsMasterPod(jenkins)
|
jenkinsPod := getJenkinsMasterPod(jenkins)
|
||||||
jenkins = getJenkins(jenkins.Namespace, jenkins.Name)
|
jenkins = getJenkins(jenkins.Namespace, jenkins.Name)
|
||||||
|
|
||||||
|
defaultGracePeriod := constants.DefaultTerminationGracePeriodSeconds
|
||||||
|
|
||||||
assertMapContainsElementsFromAnotherMap(jenkins.Spec.Master.Annotations, jenkinsPod.ObjectMeta.Annotations)
|
assertMapContainsElementsFromAnotherMap(jenkins.Spec.Master.Annotations, jenkinsPod.ObjectMeta.Annotations)
|
||||||
Expect(jenkinsPod.Spec.NodeSelector).Should(Equal(jenkins.Spec.Master.NodeSelector))
|
Expect(jenkinsPod.Spec.NodeSelector).Should(Equal(jenkins.Spec.Master.NodeSelector))
|
||||||
|
|
||||||
|
|
@ -125,6 +127,7 @@ func verifyJenkinsMasterPodAttributes(jenkins *v1alpha2.Jenkins) {
|
||||||
|
|
||||||
Expect(jenkinsPod.Labels).Should(Equal(resources.GetJenkinsMasterPodLabels(*jenkins)))
|
Expect(jenkinsPod.Labels).Should(Equal(resources.GetJenkinsMasterPodLabels(*jenkins)))
|
||||||
Expect(jenkinsPod.Spec.PriorityClassName).Should(Equal(jenkins.Spec.Master.PriorityClassName))
|
Expect(jenkinsPod.Spec.PriorityClassName).Should(Equal(jenkins.Spec.Master.PriorityClassName))
|
||||||
|
Expect(jenkinsPod.Spec.TerminationGracePeriodSeconds).Should(Equal(&defaultGracePeriod))
|
||||||
|
|
||||||
for _, actualContainer := range jenkinsPod.Spec.Containers {
|
for _, actualContainer := range jenkinsPod.Spec.Containers {
|
||||||
if actualContainer.Name == resources.JenkinsMasterContainerName {
|
if actualContainer.Name == resources.JenkinsMasterContainerName {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue