$ sudo grep docker /etc/group
CloudBees Core is the successor to CloudBees Jenkins Platform and CloudBees Jenkins Enterprise. This article explains how to integrate the Prisma Cloud Jenkins plugin with a CloudBees Core build pipeline running in a Kubernetes cluster.
Refer to the article on setting up a Jenkins Pipeline in Kubernetes, as the core concepts are the same. In the case of CloudBees Core on Kubernetes, much of the configuration is already done and the pipeline script is simpler because the JNLP Agent/Slave container is launched automatically. The only tricky bit of configuration is determining the group ID (gid) of the docker group on your Kubernetes hosts, and using it to add some YAML to the default JNLP Agent/Slave pod configuration in CloudBees core. This allows a pod running your pipeline to build and scan images using the mapped Docker socket of the underlying hosts.
After installing the Prisma Cloud Jenkins plugin, configure the default pod template.
You have set up a Kubernetes cluster using the Docker runtime and can SSH to nodes (see gid note below).
You have installed Prisma Cloud Console. You can install Prisma Cloud inside or outside of the cluster, as long as any cluster node can reach Console over the network.
You have installed CloudBees Core in your cluster. The CloudBees Core Install Guides are very helpful.
You’ve built or identified an image for your Docker build executor that contains the docker binary. See an example Dockerfile below.
Get the docker group ID (GID) used by the hosts in your Kubernetes cluster.
SSH to a node in the cluster.
Get the docker group GID. Copy it and set it aside for now.
$ sudo grep docker /etc/group
Log into the CloudBees Core console, and navigate to <CLOUDBEES_CONSOLE>/cjoc/view/All/.
Click on kubernetes shared cloud.
In the left navigation bar, click on Configure.
Scroll down to the Kubernetes pod template section. You’ll notice a pod template named default-java with a single container named jnlp.
Scroll to the bottom of the section. In Raw yaml for the Pod, enter the following snippet, replacing <GID> with the docker GID for your environment.
spec: securityContext: fsGroup: <GID>
Grant all containers in the pod access to the underlying host’s Docker socket (unless you do this manually in the pipeline script).
Scroll up to the Volumes section.
Add a Host Path Volume to the pod template.
In both Host path and Mount path, enter /var/run/docker.sock.
Add a second container to the pod template.
In addition to the JNLP agent/slave, you’ll also want to spin up a container with the docker binary inside of it. Use the official docker image from DockerHub and name it build, although you could use any image with the docker client command installed in it. The docker client will use the Docker socket mounted from the underlying host.
Scroll up the Container Template section.
Click Add Container.
In Name, enter build.
In Docker image, enter docker.
In Working directory, enter /home/jenkins.
In Command to run, enter /bin/sh -c.
In Arguments to pass to the command, enter cat.
Enable Allocate pseudo-TTY.
Your CloudBees Core pod template config page should look like the folowing screenshot.