# Incorrect space size for built in node on Kubernetes

**URL:** <https://community.jenkins.io/t/incorrect-space-size-for-built-in-node-on-kubernetes/9197>\
**Category:** Using Jenkins\
**Tags:** question, docker, kubernetes\
**Created:** [August 24, 2023, 6:21am UTC](https://community.jenkins.io/t/incorrect-space-size-for-built-in-node-on-kubernetes/9197 "2023-08-24T06:21:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hat3ck](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/hat3ck/32/5289_2.png) [@hat3ck](https://community.jenkins.io/u/hat3ck)\
**Post date:** [August 24, 2023, 6:21am UTC](https://community.jenkins.io/t/incorrect-space-size-for-built-in-node-on-kubernetes/9197/1 "2023-08-24T06:21:56Z")

</div>

Hi,

I am deploying jenkins on Kubernetes using the latest version of the official image.

I have an issue with how /computer route reports the size for built-in-node. Currently, I provide a 4GB PVC for the deployment and here is the deployment script:

```auto
apiVersion: apps/v1
kind: Deployment
metadata:
  name: testing-jenkins
  namespace: jenkins
spec:
  replicas: 1
  selector:
    matchLabels:
      app: testing-jenkins-server
  template:
    metadata:
      labels:
        app: testing-jenkins-server
    spec:
      securityContext:
            fsGroup: 1000
            runAsUser: 1000
      containers:
        - name: testing-jenkins
          image: jenkins/jenkins:lts
          env:
            - name: JAVA_OPTS
              value: "-Djenkins.install.runSetupWizard=false"
          resources:
            limits:
              memory: "1000Mi"
              cpu: "250m"
            requests:
              memory: "500Mi"
              cpu: "125m"
          ports:
            - name: httpport
              containerPort: 8080
            - name: jnlpport
              containerPort: 50000
          livenessProbe:
            httpGet:
              path: "/login"
              port: 8080
            initialDelaySeconds: 90
            periodSeconds: 10
            timeoutSeconds: 5
            failureThreshold: 5
          readinessProbe:
            httpGet:
              path: "/login"
              port: 8080
            initialDelaySeconds: 60
            periodSeconds: 10
            timeoutSeconds: 5
            failureThreshold: 3
          volumeMounts:
            - name: testing-jenkins-data
              mountPath: /var/jenkins_home
      volumes:
        - name: testing-jenkins-data
          persistentVolumeClaim:
              claimName: testing-jenkins-pvc

```

However, this is what I see when I view the nodes.

 ![Screen Shot 2023-08-24 at 2.17.25 AM](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/1/112a62f3351b4873e009bdd3273428ebde9e9580.png)

That is how much free space Kubernetes storage node has in total, but I would rather seeing the 4GB persistent volume that I assigned to the deployment.

I am not sure if this is a bug but I would be grateful if someone has a resolution.

---

<div class="post-metadata">

**Author:** ![longkang](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@longkang](https://community.jenkins.io/u/longkang)\
**Post date:** [August 24, 2023, 9:52am UTC](https://community.jenkins.io/t/incorrect-space-size-for-built-in-node-on-kubernetes/9197/2 "2023-08-24T09:52:32Z")

</div>

Could you run `kubectl get pv` and send the prints? Also `kubectl describe pv {the_pv_jenkins_claimed}`

---

<div class="post-metadata">

**Author:** ![hat3ck](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/hat3ck/32/5289_2.png) [@hat3ck](https://community.jenkins.io/u/hat3ck)\
**Post date:** [August 24, 2023, 1:27pm UTC](https://community.jenkins.io/t/incorrect-space-size-for-built-in-node-on-kubernetes/9197/3 "2023-08-24T13:27:43Z")

</div>

Result of “kubectl get pv”

```auto
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE

testing-jenkins-pv 4Gi RWO Retain Bound jenkins/testing-jenkins-pvc testing-jenkins-sc 47s

```

Result of “kubectl describe pv testing-jenkins-pv”

```auto
Name: testing-jenkins-pv
Labels: <none>
Annotations: pv.kubernetes.io/bound-by-controller: yes
Finalizers: [kubernetes.io/pv-protection]
StorageClass: testing-jenkins-sc
Status: Bound
Claim: jenkins/testing-jenkins-pvc
Reclaim Policy: Retain
Access Modes: RWO
VolumeMode: Filesystem
Capacity: 4Gi
Node Affinity:     
  Required Terms:  
    Term 0: kubernetes.io/hostname in [worker1]
Message:           
Source:
    Type: LocalVolume (a persistent volume backed by local storage on a node)
    Path: /data/jenkins-deployments
Events: <none>

```

---

<div class="post-metadata">

**Author:** ![longkang](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@longkang](https://community.jenkins.io/u/longkang)\
**Post date:** [August 25, 2023, 1:42am UTC](https://community.jenkins.io/t/incorrect-space-size-for-built-in-node-on-kubernetes/9197/4 "2023-08-25T01:42:40Z")

</div>

> [@hat3ck](#):
>
> `Type: LocalVolume (a persistent volume backed by local storage on a node)`

Hi, I believe the reason for this issue is your PV type is LocalVolume.

> **[Volumes](https://kubernetes.io/docs/concepts/storage/volumes/#local)**
>
> On-disk files in a container are ephemeral, which presents some problems for non-trivial applications when running in containers. One problem occurs when a container crashes or is stopped. Container state is not saved so all of the files that were...

---

<div class="post-metadata">

**Author:** ![hat3ck](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/hat3ck/32/5289_2.png) [@hat3ck](https://community.jenkins.io/u/hat3ck)\
**Post date:** [August 25, 2023, 2:36am UTC](https://community.jenkins.io/t/incorrect-space-size-for-built-in-node-on-kubernetes/9197/5 "2023-08-25T02:36:40Z")

</div>

To eliminate this I set the storage of the deployment as ephemeral:

```auto
apiVersion: apps/v1
kind: Deployment
metadata:
  name: testing-jenkins
  namespace: jenkins
spec:
  replicas: 1
  selector:
    matchLabels:
      app: testing-jenkins-server
  template:
    metadata:
      labels:
        app: testing-jenkins-server
    spec:
      securityContext:
            fsGroup: 1000
            runAsUser: 1000
      containers:
        - name: testing-jenkins
          image: jenkins/jenkins:lts
          env:
            - name: JAVA_OPTS
              value: "-Djenkins.install.runSetupWizard=false"
          resources:
            limits:
              memory: "1000Mi"
              cpu: "250m"
              ephemeral-storage: "4Gi"
            requests:
              memory: "500Mi"
              cpu: "125m"
              ephemeral-storage: "4Gi"
          ports:
            - name: httpport
              containerPort: 8080
            - name: jnlpport
              containerPort: 50000
          livenessProbe:
            httpGet:
              path: "/login"
              port: 8080
            initialDelaySeconds: 90
            periodSeconds: 10
            timeoutSeconds: 5
            failureThreshold: 5
          readinessProbe:
            httpGet:
              path: "/login"
              port: 8080
            initialDelaySeconds: 60
            periodSeconds: 10
            timeoutSeconds: 5
            failureThreshold: 3

```

However, that didn’t fix it either. It’s not just the space, the fact that it’s also displaying the operating system of Kubernetes node as built-in node’s architectue tells me that there is a place in the code that connects the Node system information to this.

---

<div class="post-metadata">

**Author:** ![longkang](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@longkang](https://community.jenkins.io/u/longkang)\
**Post date:** [August 25, 2023, 2:59am UTC](https://community.jenkins.io/t/incorrect-space-size-for-built-in-node-on-kubernetes/9197/6 "2023-08-25T02:59:12Z")

</div>

I think ur doing the right thing using `ephemeral` cause `if you're using the local PV type in Kubernetes, it will effectively use all available local storage on the node without being constrained by the specified size in the PV definition.`. However, I am not sure what u r trying to explain here.

> [@hat3ck](#):
>
> However, that didn’t fix it either. It’s not just the space, the fact that it’s also displaying the operating system of Kubernetes node as built-in node’s architectue tells me that there is a place in the code that connects the Node system information to this.

Are u saying that even if u used `ephemeral`, u still got 306G storage shows on ur `jenkins`?

Also, is it ok to set `memory and CPU` with `ephemeral-storage` at the same time? maybe try to leave the `ephemeral-storage` only?(I am not sure about this cause I did not used ephemeral before, just googled and all examples have only `ephemeral-storage`)

---

<div class="post-metadata">

**Author:** ![hat3ck](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/hat3ck/32/5289_2.png) [@hat3ck](https://community.jenkins.io/u/hat3ck)\
**Post date:** [August 25, 2023, 3:14am UTC](https://community.jenkins.io/t/incorrect-space-size-for-built-in-node-on-kubernetes/9197/7 "2023-08-25T03:14:26Z")

</div>

The initial problem still persists.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/3/389af6dad1615e9f010e38b44f0424ab32120ccb.png)

Even when using ephemeral storage, the Built-In Node is reporting Kubernetes node’s information rather than Jenkins pod’s. I do not want the user to see how much free space I have in Kubernetes node because I have already assigned 4GB space to the Jenkins pod and it’s supposed to be running in a container.

I have even tried assigning the ephemeral storage based on the official instructions [here](https://kubernetes.io/docs/concepts/storage/ephemeral-volumes/#generic-ephemeral-volumes#generic-ephemeral-volumes).

```auto
          volumeMounts:
            - name: test-hello-jenkins-data
              mountPath: /var/jenkins_home
      volumes:
      - name: test-hello-jenkins-data
        ephemeral:
          volumeClaimTemplate:
            metadata:
              labels:
                type: testing-jenkins-volume
            spec:
              accessModes: ["ReadWriteOnce"]
              storageClassName: "testing-jenkins-sc"
              resources:
                requests:
                  storage: 4Gi

```

still no luck!
