Skip to content

Commit 234f97f

Browse files
committed
Set pod fsGroup for non-root JNLP SSH key access
We are moving to run jobs on Kubernetes containers instead of the Jenkins built-in node. JNLP runs non-root(jenkins gid 1000) and could not read the SSH Secret mount. Add pod securityContext fsGroup 1000 and fsGroupChangePolicy to every podTemplate so JNLP can use mounted volumes. fsGroup lets the jenkins user read the SSH key without running JNLP as root. Signed-off-by: Noam Tsemah <ntsemah@nvidia.com>
1 parent e279ab9 commit 234f97f

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/com/mellanox/cicd/Matrix.groovy

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,9 @@ def runK8(image, branchName, config, axis, steps=config.steps) {
902902
def imagePullSecrets = parseImagePullSecrets(getConfigVal(config, ['kubernetes', 'imagePullSecrets'], "[]"))
903903
def yaml = """
904904
spec:
905+
securityContext:
906+
fsGroup: 1000
907+
fsGroupChangePolicy: OnRootMismatch
905908
containers:
906909
- name: ${cname}
907910
env:
@@ -1426,6 +1429,9 @@ def build_docker_on_k8(image, config) {
14261429
def imagePullSecrets = parseImagePullSecrets(getConfigVal(config, ['kubernetes', 'imagePullSecrets'], "[]"))
14271430
def yaml = """
14281431
spec:
1432+
securityContext:
1433+
fsGroup: 1000
1434+
fsGroupChangePolicy: OnRootMismatch
14291435
containers:
14301436
- name: docker
14311437
env:
@@ -1727,7 +1733,11 @@ def main() {
17271733
label = "worker-${UUID.randomUUID().toString()}"
17281734
println("Cloud launch on ${label}")
17291735

1730-
podTemplate(label: label) {
1736+
podTemplate(label: label, yamlMergeStrategy: merge(), yaml: """spec:
1737+
securityContext:
1738+
fsGroup: 1000
1739+
fsGroupChangePolicy: OnRootMismatch
1740+
""") {
17311741
startPipeline(label)
17321742
}
17331743
return

0 commit comments

Comments
 (0)