gpt4 book ai didi

kubernetes - K8s : gets HTTP 415 for PATCH request to Kubernetes REST API server

转载 作者:行者123 更新时间:2023-12-02 11:51:31 26 4
gpt4 key购买 nike

我从以下链接看到 Kubernetes REST API 引用手册支持 PATCH 请求:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#patch-ingress-v1beta1-networking-k8s-io

HTTP Request
PATCH /apis/networking.k8s.io/v1beta1/namespaces/{namespace}/ingresses/{name}
但是,通过 Postman 中的 Kubernetes REST API 服务器向 Kubernetes 集群发送 PATCH 请求时,我收到 HTTP 415 Unsupported Media Type 错误。
我想在集群外部部分更新我们指定的入口。为此,我添加了试用版的快照。
Kubernetes REST API server Ingress PATCH Request
我们的 Kubernetes 版本是:
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.3", GitCommit:"2d3c76f9091b6bec110a5e63777c332469e0cba2", GitTreeState:"clean", BuildDate:"2019-08-19T11:13:54Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.3", GitCommit:"2d3c76f9091b6bec110a5e63777c332469e0cba2", GitTreeState:"clean", BuildDate:"2019-08-19T11:05:50Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
修补 JSON:
{
"apiVersion": "networking.k8s.io/v1beta1",
"kind": "Ingress",
"metadata": {
"name": "demo-ingress",
"annotations": {
"nginx.org/rewrites": "serviceName=demo-service-235 rewrite=/"
}
},
"spec": {
"rules": [
{
"host": "www.demodeployment.com",
"http": {
"paths": [
{
"path": "/235/",
"backend": {
"serviceName": "demo-service-235",
"servicePort": 8088
}
}
]
}
}
]
}
}
我可以成功使用 GET、POST、PUT 和 DELETE,在 PATCH 请求中我无法获得相同的结果。问题的根本原因可能是什么?你有什么想法?

最佳答案

我通过设置以下标题解决了同样的问题:

"Content-Type": "application/strategic-merge-patch+json"

关于kubernetes - K8s : gets HTTP 415 for PATCH request to Kubernetes REST API server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63087397/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com