Jenkins Kubernetes插件安全上下文

时间:2018-10-28 13:15:09

标签: docker jenkins kubernetes

如何更改Jenkins Kubernetes插件中pod的securityContext。例如,在Docker环境中以特权模式在Docker映像中运行docker。

1 个答案:

答案 0 :(得分:1)

我相信this应该有效(根据文档):

def label = "mypod-${UUID.randomUUID().toString()}"
podTemplate(label: label, yaml: """
apiVersion: v1
kind: Pod
metadata:
  labels:
    some-label: some-label-value
spec:
  containers:
  - name: busybox
    image: busybox
    command:
    - cat
    tty: true
    securityContext:
      allowPrivilegeEscalation: true
"""
) {
    node (label) {
      container('busybox') {
        sh "hostname"
      }
    }
}