kubernetes-client / kubernetes-client/java

It's not possible to create a Pod, because of the default overhead value (empty map) in v20.0.0

Open
#3,076 32 comments 1 reaction 0 assignees View on GitHub
lifecycle/frozen
Dominant language
Java
Stars
4k
Forks
2.1k
Avg merge
2d 9h
Merged PRs (30d)
16

Description

**Describe the bug**

The default `overhead` value of Pod spec in version 20.0.0 is empty map which is causing the following error:
```java
java.lang.RuntimeException: io.kubernetes.client.openapi.ApiException: Message:
HTTP response code: 403
HTTP response body: {"kind":"Status","apiVersion":"((redacted))","metadata":{},"status":"Failure","message":"pods \"foo\" is forbidden: pod rejected: Pod Overhead set without corresponding RuntimeClass defined Overhead","reason":"Forbidden","details":{"name":"foo","kind":"pods"},"code":403}
```
As a workaround, one can set the `overhead` explicitly to null:
```java
V1Pod pod = new V1Pod()
.metadata(new V1ObjectMeta().name("foo"))
.spec(new V1PodSpec()
.overhead(null) // HERE: setting the overhead value to null, to avoid above error.
.addContainersItem(new V1ContainerBuilder()
// omitted
```

**Client Version**
e.g. `20.0.0`

**Kubernetes Version**
any version

**Java Version**
any version

**To Reproduce**
Create a simple Pod, without specifying anything for `overhead`:
```java
V1Pod pod = new V1Pod()
.metadata(new V1ObjectMeta().name("foo"))
.spec(new V1PodSpec()
.addContainersItem(new V1ContainerBuilder()
.withImage("any-image")
.withName("foo-image").build()));

coreV1Api.createNamespacedPod("default", pod).execute();
```
**Expected behavior**
Pod creation should be successful but it fails due to `overhead: {}` being present in the request payload.

I think, either the default value of `overhead` should be `null` or when serialising the request, the empty values should be omitted.
**KubeConfig**
N/A

**Server (please complete the following information):**
Any

**Additional context**
N/A

Contributor guide

Open the contributing guide

Research direction

Start with V1PodSpec and the request path used by CoreV1Api.createNamespacedPod; reproduce the example and inspect how an unset overhead is serialized. Compare the generated payload with the expected request, then verify that creating a Pod without specifying overhead no longer sends an empty map and succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kubernetes
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.