In Jenkins, when configuring a Kubernetes agent pod template, which of the following best describes the purpose of the containers section inside the pod template?
Think about what runs inside the agent pod that Jenkins uses to execute jobs.
The containers section defines the containers inside the Kubernetes pod that Jenkins uses as agents. These containers run the build steps.
Given the following Jenkins pipeline snippet that uses a Kubernetes agent:
pipeline {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: jnlp
image: jenkins/inbound-agent:latest
'''
}
}
stages {
stage('Test') {
steps {
sh 'echo Hello from Kubernetes agent'
}
}
}
}What will be the output of the sh step when this pipeline runs?
The sh step runs inside the container defined in the pod template.
The sh step executes the echo command inside the Kubernetes agent pod container, so it outputs the string as expected.
A Jenkins pipeline configured with a Kubernetes agent pod template fails to start the agent pod. The Jenkins logs show the error: Failed to schedule pod: insufficient cpu. What is the most likely cause?
Consider what 'insufficient cpu' means in Kubernetes scheduling.
The error indicates the Kubernetes scheduler cannot find a node with enough CPU resources to run the pod, causing scheduling failure.
Which sequence correctly describes the lifecycle of a Jenkins Kubernetes agent pod during a pipeline run?
Think about the order from pod request to pod deletion after job completion.
The Jenkins master requests the pod, Kubernetes schedules and starts it, the pipeline runs inside, then the pod is deleted after completion.
Which of the following is the best practice to enhance security when running Jenkins agents as Kubernetes pods?
Consider the principle of least privilege in container security.
Running containers as non-root users with restricted capabilities reduces security risks and limits damage if compromised.