2

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

CptDolphin
  • 404
  • 7
  • 23
  • Are you trying to change the values in `values.yaml` and upgrade the helm chart or this behavior occurred after the helm chart installed for the first time? – Mr.KoopaKiller Jan 31 '20 at 11:31
  • i got the values with `helm inspect values stable/jenkins > jenkins.yaml` and edited there, it happens bouth when initially running jenkins with it and when upgrading – CptDolphin Feb 03 '20 at 07:51
  • In my tests, I've downloaded the chart with `helm fetch stable/jenkins`, unzip, change the values on `values.yaml` and then applied with `helm install ./`. What is the Helm version are you using? Verify if the correct values are configured on jenkins configmap created by helm on kubernetes. – Mr.KoopaKiller Feb 04 '20 at 08:35
  • helm at 2.13.0 and when i `kubectl get confimaps && kubectl edit configmap jenkins` I see my edits as they should be ` 2 2Gi 4 3Gi` – CptDolphin Feb 04 '20 at 08:43
  • what's even more surprising is that default agent has 512MI RAM and 512m CPU, so where did the 1Gi 2Gi came from ? : o – CptDolphin Feb 04 '20 at 08:45
  • But weird because the values in your configMap are correct. I did the tests using helm 3, I'll install helm 2.13.0 and test again. I could post an answer with the steps i followed to achieve the results if it helps. To test I just create a new job using shell command `id`. Jenkins spawned a new jenkins slave container using the resources I configured previously. – Mr.KoopaKiller Feb 04 '20 at 09:49
  • hey, yea I'd really appreciate it, i set up no matter how many times and on what environments jenkins he doesn't seem to even care about some of the configs - he installs plugins i specify etc. but resources is dthe deafult number – CptDolphin Feb 05 '20 at 10:35
  • hey update to the issue - when I go from `helm install stable/jenkins --name jenkins -f jenkins.yaml` with some values - they are deployed but when I upgrade the jenkins `helm upgrade jenkins stable/jenkins -f jenkins.yaml` it doesn't happen - try to upgrade the jenkins with new vals and see then – CptDolphin Feb 05 '20 at 11:47
  • I've posted the step i have followed. Let me know if that works for you! – Mr.KoopaKiller Feb 05 '20 at 13:25

1 Answers1

2

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

Mr.KoopaKiller
  • 3,665
  • 10
  • 21