如何使用备用后端修补路由

how to patch a route with an alternate backend

我一直在尝试修补具有备用后端的 openshift 中的路由。

我试过:

  1. oc patch route/image-mirror-poc --patch '{"spec":{"alternateBackends": "kind:Service" "name:image-mirror-poc-blue" "weight:75"}}'

错误:Error from server: invalid character '"' after object key:value pair

  1. oc patch route/image-mirror-poc --patch '{"spec":{"alternateBackends": "kind:Service", "name:image-mirror-poc-blue", "weight:75"}}'

错误:Error from server: invalid character ',' after object key

  1. oc patch route/image-mirror-poc --patch '{"spec":{"alternateBackends": ["kind:Service", "name:image-mirror-poc-blue", "weight:75"]}}'

错误:Error from server: cannot restore struct from: string

我提取了我的路线的当前规范,它看起来像:

"spec": {
        "alternateBackends": [
            {
                "kind": "Service",
                "name": "image-mirror-poc-blue",
                "weight": 75
            }
        ],
        "host": "image-mirror-poc.sbx1apps.ocp.delta.com",
        "port": {
            "targetPort": "8080-tcp"
        },
        "to": {
            "kind": "Service",
            "name": "image-mirror-poc-green",
            "weight": 25
        },
        "wildcardPolicy": "None"
    }

我一直在尝试关注 documentation 但没有成功。

Openshift 信息:

$ oc version
oc v3.9.0+191fece
kubernetes v1.9.1+a0ce1bc657
features: Basic-Auth

Server https://mycluster.ocp.mycompany.com
openshift v3.7.23
kubernetes v1.7.6+a08f5eeb6

这种格式怎么样?如果没有任何更改,则 patch 命令结束时没有任何更改。

oc patch route/image-mirror-poc --patch'{"spec": {"alternateBackends": [{"kind": "Service","name": "image-mirror-poc-blue","weight": 75}]}}'