-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Description
Describe the bug
Unable to patch a namespace deployment using java kubernetes library. Results in HTTP 415, issue being incorrect Content-Type header set by library.
Client Version
24.0.0
Kubernetes Version
1.33.5
Java Version
17
To Reproduce
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
AppsV1Api api = new AppsV1Api(client);
String timeNow = java.time.Instant.now().toString();
String patchJson = """
{
"spec": {
"template": {
"metadata": {
"annotations": {
"kubectl.kubernetes.io/restartedAt": "%s"
}
}
}
}
}
""".formatted(timeNow);
AppsV1Api.APIpatchNamespacedDeploymentRequest apIpatchNamespacedDeploymentRequest =
api.patchNamespacedDeployment(
"some-deployment-name",
"some-namespace",
new V1Patch(patchJson));
apIpatchNamespacedDeploymentRequest.execute();
Expected behavior
HTTP 200 resulting in deployment patch
KubeConfig
wont provide for now
Server (please complete the following information):
- OS: macOS Sequoia 15.5
- Environment: local
- Cloud ???
Additional context
it seems the fault lies at io.kubernetes.client.openapi.apis.AppsV1Api:9231
, it sets Content-Type
header value to application/json
where it should be application/strategic-merge-patch+json
according to docs here
This has a workaround but that shouldnt be the case
PatchUtils.patch(
V1Deployment.class,
() -> client.buildCall(
null,
String.format(
"/apis/apps/v1/namespaces/%s/deployments/%s",
namespaceParam,
deploymentParam),
"PATCH",
new ArrayList<>(),
new ArrayList<>(),
new V1Patch(PATCH_JSON.formatted(timeNow)),
HEADERS,
new HashMap<>(),
new HashMap<>(),
new String[] {"BearerToken"},
null),
"application/strategic-merge-patch+json");
Metadata
Metadata
Assignees
Labels
No labels