这是我创建envoyfilter对象的json数据
al8-1@al8-1:~/kuber_test/pod_nginx$ cat park.json
{
"apiVersion": "networking.istio.io/v1alpha3",
"kind": "EnvoyFilter",
"metadata": {
"name": "myapp-pod",
"namespace": "default"
},
"spec": {
"workloadSelector": {
"labels": {
"app": "myapp"
}
},
"configPatches": [{
"applyTo": "HTTP_FILTER",
"match": {
"context": "SIDECAR_OUTBOUND",
"listener": {
"filterChain": {
"filter": {
"name": "envoy.http_connection_manager"
}
}
}
},
"patch": {
"operation": "ADD",
"value": {
"name" : "envoy.http_connection_manager",
"config": {
"id_1": "key_1"
}
}
}
}]
}
}
并使用创建的json,通过curl命令创建了envoyfilter。
下图显示了使用POST命令创建了envoyfilter,并且使用GET命令创建了相应的envoyfilter。
al8-1@al8-1:~/kuber_test/pod_nginx$ curl POST -H "Content-Type: application/json" -H "Authorization:
Bearer $token" --insecure
'https://192.xxx.xx.xx:6443/apis/networking.istio.io/v1alpha3/namespaces/default/envoyfilters' -
d@park.json
curl: (6) Could not resolve host: POST
{"apiVersion":"networking.istio.io/v1alpha3","kind":"EnvoyFilter","metadata":
{"creationTimestamp":"2020-04-17T06:38:54Z","generation":1,"name":"myapp-pod","namespace":"default","resourceVersion":"4304352","selfLink":"/apis/networking.istio.io/v1alpha3/namespaces/default/envoyfilters/myapp-pod","uid":"549cc0ea-45e5-4bc8-af2f-80aa56e15eef"},"spec":{"configPatches":[{"applyTo":"HTTP_FILTER","match":{"context":"SIDECAR_OUTBOUND","listener":{"filterChain":{"filter":{"name":"envoy.http_connection_manager"}}}},"patch":{"operation":"ADD","value":{"config":{"id_1":"key_1"},"name":"envoy.http_connection_manager"}}}],"workloadSelector":{"labels":{"app":"myapp"}}}}al8-1@al8-1:~/kuber_test/pod_nginx$
al8-1@al8-1:~/kuber_test/pod_nginx$ curl -X GET -H "Content-Type: application/json" -H
"Authorization: Bearer $token" --insecure
'https://192.xxx.xx.xx:6443/apis/networking.istio.io/v1alpha3/namespaces/default/envoyfilters'
{"apiVersion":"networking.istio.io/v1alpha3","items":[{"apiVersion":"networking.istio.io/v1alpha3","kind":"EnvoyFilter","metadata":{"creationTimestamp":"2020-04-17T06:38:54Z","generation":1,"name":"myapp-pod","namespace":"default","resourceVersion":"4304352","selfLink":"/apis/networking.istio.io/v1alpha3/namespaces/default/envoyfilters/myapp-pod","uid":"549cc0ea-45e5-4bc8-af2f-80aa56e15eef"},"spec":{"configPatches":[{"applyTo":"HTTP_FILTER","match":{"context":"SIDECAR_OUTBOUND","listener":{"filterChain":{"filter":{"name":"envoy.http_connection_manager"}}}},"patch":{"operation":"ADD","value":{"config":{"id_1":"key_1"},"name":"envoy.http_connection_manager"}}}],"workloadSelector":{"labels":{"app":"myapp"}}}}],"kind":"EnvoyFilterList","metadata":{"continue":"","resourceVersion":"4304378","selfLink":"/apis/networking.istio.io/v1alpha3/namespaces/default/envoyfilters"}}al8-1@al8-1:~/kuber_test/pod_nginx$
现在,要修改PATCH命令创建的某些envoyfilter对象,我们创建了以下patch.json
al8-1@al8-1:~/kuber_test/pod_nginx$ cat patch.json
[{"op":"replace","path":"/spec/configPatches/0/patch/operation/-","value":"MERGE"}]
但是patch命令给出了一个错误,我不知道该错误在哪里
al8-1@al8-1:~/kuber_test/pod_nginx$ curl PATCH -H "Content-Type: application/json-patch+json" -H
"Authorization: Bearer $token" --insecure
'https://192.xxx.xx.xx:6443/apis/networking.istio.io/v1alpha3/namespaces/default/envoyfilters/myapp-pod' -d@patch.json
curl: (6) Could not resolve host: PATCH
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {
},
"status": "Failure",
"message": "the body of the request was in an unknown format - accepted media types include:
application/json, application/yaml, application/vnd.kubernetes.protobuf",
"reason": "UnsupportedMediaType",
"code": 415
我尝试将其应用于多个字段以及操作字段,但是发生了相同的错误。如果您知道此错误的原因,请告诉我答案。