I'm running Jenkins pod with helm charts and having weird logs when starting jenkins jobs. The requested resources and limits are seems to be in default state - compared to what I set in values.
helm install stable/jenkins --name jenkins -f jenkins.yaml
And after creating and running random job from UI
Agent jenkins-agent-mql8q is provisioned from template Kubernetes Pod Template
---
apiVersion: "v1"
kind: "Pod"
metadata:
annotations: {}
labels:
jenkins/jenkins-slave: "true"
jenkins/label: "jenkins-jenkins-slavex"
name: "jenkins-agent-mql8q"
spec:
containers:
- args:
- "********"
- "jenkins-agent-mql8q"
env:
- name: "JENKINS_SECRET"
value: "********"
- name: "JENKINS_TUNNEL"
value: "jenkins-agent:50000"
- name: "JENKINS_AGENT_NAME"
value: "jenkins-agent-mql8q"
- name: "JENKINS_NAME"
value: "jenkins-agent-mql8q"
- name: "JENKINS_AGENT_WORKDIR"
value: "/home/jenkins/agent"
- name: "JENKINS_URL"
value: "http://jenkins:8080/"
image: "jenkins/jnlp-slave:3.27.1"
imagePullPolicy: "IfNotPresent"
name: "jnlp"
resources:
limits:
memory: "2Gi"
cpu: "2"
requests:
memory: "1Gi"
cpu: "1"
And my helm values is
master:
(...)
resources:
requests:
cpu: "1"
memory: "1Gi"
limits:
cpu: "3"
memory: "3Gi"
agent:
resources:
requests:
cpu: "2"
memory: "2Gi"
limits:
cpu: "4"
memory: "3Gi"
Any idea why it spawns agents with default 1cpu/1Gi to 2cpu/2Gi
I've reproduced your scenario, I will explain how that works for me. I'm using GKE with Kubernetes 1.15.3 and HELM 2.16.1.
I've downloaded the helm chart to my local machine, and decompress the file to customize the value.yaml:
$ helm fetch stable/jenkins
$ tar xzvf jenkins-1.9.16.tgz
In jenkins folder, edit the lines 422-427 from values.yaml
file.
agent:
...
requests:
cpu: "2"
memory: "2Gi"
limits:
cpu: "4"
memory: "3Gi"
...
This will configure the agent container to spawn with the specified resources.
Perform other changes in file if you desire, for this example I'll let with default values.
Install helm chart:
helm install jenkins/ -n jenkins
After installed, follow the instructions on screen to access the jenkins console.
To verify if the agents will start with configured resources, let's create a new job using a simple shell command.
New Item > Freestyle project
In Job configuration, select "Execute shell" above the section "Build" in dropdown list. Type any linux command as id
, ls
, uname -a
etc...
Save and trigger Build Now
button.
Verify in kubernetes for the new containers, in this case a new agent container is named with default-6w3fq
See pod description:
kubectl describe pod default-6w3fq
Name: default-6w3fq
...
IP:
Containers:
jnlp:
Image: jenkins/jnlp-slave:3.27-1
...
Limits:
cpu: 4
memory: 3Gi
Requests:
cpu: 2
memory: 2Gi
...
You could wait for the job completion and see the job logs instead to use kubectl
command.
I've tried to deploy with default values, and upgrade the helm chart with new values values... nothing happened. That worked when I ran upgrade with --force
flag: helm upgrade jenkins jenkins/ --force
--force - force resource updates through a replacement strategy
References: https://helm.sh/docs/helm/helm_upgrade/ https://github.com/helm/charts/tree/master/stable/jenkins