Make jenkins master pod security context optional (#6122)

Cluster configurations may include mutating admission controllers which
dynamically add security contexts to pods and containers.

OpenShift uses this pattern to implement required uid ranges that
differ on a per-namespace basis, and OpenShift's security admission
plugin rejects any pods that make runAsUser requests outside of that
valid uid range.

Removing the securityContext field from the Jenkins pod spec allows the
OpenShift security admission plugin to assign a uid in the correct
range to each container in the pod on behalf of the user, avoiding the
need to provide helm with a different runAsUser value for each
namespace in which Jenkins is deployed.
This commit is contained in:
Jacob LeGrone
2018-07-01 12:39:18 -07:00
committed by k8s-ci-robot
parent c0b445ee55
commit 63653fd596
4 changed files with 6 additions and 1 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
name: jenkins
home: https://jenkins.io/
version: 0.16.5
version: 0.16.6
appVersion: 2.121.1
description: Open source continuous integration server. It supports multiple SCM tools
including CVS, Subversion and Git. It can execute Apache Ant and Apache Maven-based
+1
View File
@@ -41,6 +41,7 @@ The following tables list the configurable parameters of the Jenkins chart and t
| `Master.resources` | Resources allocation (Requests and Limits) | `{requests: {cpu: 50m, memory: 256Mi}, limits: {cpu: 2000m, memory: 2048Mi}}`|
| `Master.InitContainerEnv` | Environment variables for Init Container | Not set |
| `Master.ContainerEnv` | Environment variables for Jenkins Container | Not set |
| `Master.UsePodSecurityContext` | Enable pod security context (must be `true` if `RunAsUser` or `FsGroup` are set) | `true` |
| `Master.RunAsUser` | uid that jenkins runs with | `0` |
| `Master.FsGroup` | uid that will be used for persistent volume | `0` |
| `Master.ServiceAnnotations` | Service annotations | `{}` |
@@ -40,12 +40,14 @@ spec:
affinity:
{{ toYaml .Values.Master.Affinity | indent 8 }}
{{- end }}
{{- if .Values.Master.UsePodSecurityContext }}
securityContext:
runAsUser: {{ default 0 .Values.Master.RunAsUser }}
{{- if and (.Values.Master.RunAsUser) (.Values.Master.FsGroup) }}
{{- if not (eq .Values.Master.RunAsUser 0.0) }}
fsGroup: {{ .Values.Master.FsGroup }}
{{- end }}
{{- end }}
{{- end }}
serviceAccountName: {{ if .Values.rbac.install }}{{ template "jenkins.fullname" . }}{{ else }}"{{ .Values.rbac.serviceAccountName }}"{{ end }}
initContainers:
+2
View File
@@ -36,6 +36,8 @@ Master:
# JavaOpts: "-Xms512m -Xmx512m"
# JenkinsOpts: ""
# JenkinsUriPrefix: "/jenkins"
# Enable pod security context (must be `true` if RunAsUser or FsGroup are set)
UsePodSecurityContext: true
# Set RunAsUser to 1000 to let Jenkins run as non-root user 'jenkins' which exists in 'jenkins/jenkins' docker image.
# When setting RunAsUser to a different value than 0 also set FsGroup to the same value:
# RunAsUser: <defaults to 0>