how to patch a route with an alternate backend

1.5k Views Asked by At

I have been trying to patch a route in openshift that has an alternate backend.

I have tried:

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

Error: 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: 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: Error from server: cannot restore struct from: string

I pulled the current spec of my route and it looks like:

"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"
    }

I have been trying to following the documentation but unsuccessful.

Openshift info:

$ 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
1

There are 1 best solutions below

0
On BEST ANSWER

How about this format ? If the changes are nothing, then the patch command finish with no changes.

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