-
Type:
New Feature
-
Resolution: Not A Defect
-
Priority:
Minor
-
Component/s: kubernetes-plugin
-
Environment:Kubernetes 3600.v144b_cd192ca_a_
Kubernetes Client API Plugin 5.12.2-193.v26a_6078f65a_9
Kubernetes Credentials Plugin 0.9.0
Because the kubernetes plugin has a work around to specify a runAsUser when using multiple containers, this has led to an inability to copy files as needed (due to permission denied). To get around this I have been mounting volumes. This works if I add a secret or configmap to the Jenkins namespace manually. But, if I want this to be part of a pipeline I would need to include these someone in the pipeline.
Like so:
pipeline {
 agent {
  kubernetes {
   yaml '''
    apiVersion: v1
    kind: ConfigMap
    metadata:
     name: values
    data:
     ldap.conf: |
      TLS_CACERT    /etc/ssl/certs/ca-certificates.crt
    —
    apiVersion: v1
    kind: Pod
    spec:
     securityContext:
      runAsUser: 1001
     volumes:
     - name: ca-bundle
      secret:
       secretName: ca-bundle
       items:
       - key: ca-bundle.crt
        path: ca-certificates.crt
     - name: ldap.conf
      configMap:
       name: values
       items:
       - key: ldap.conf
        path: ldap.conf
     containers:
     - name: openldap
      image: bitnami/openldap
      tty: true
      securityContext:
       privileged: true
      volumeMounts:
      - name: ca-bundle
       mountPath: /etc/ssl/certs
       readOnly: true
      - name: values
       mountPath: /etc/openldap/ldap.conf
       readOnly: true
If there is some other way that I can add in additional objects such as a secret or configmap as part of the pipeline please let me know, I am still fairly new to working with Jenkins.