Openshift - rename route

7/20/2018

How can I rename route that has been created via web console? I go to Applications>Routes, selected route name, then Action>Edit YAML and I want to achieve the following change, from test.site into old.test.site

Current route yml config

...
metadata:
  name: test
  selfLink: /oapi/v1/namespaces/keycloak/routes/test
...
spec:
  host: test.site
...
status:
  ingress:
    - conditions:
        - lastTransitionTime: '2017-12-13T02:19:22Z'
          status: 'True'
          type: Admitted
      host: test.site

Attempt

...
metadata:
  name: test
  selfLink: /oapi/v1/namespaces/keycloak/routes/test
...
spec:
  host: old.test.site
...
status:
  ingress:
    - conditions:
        - lastTransitionTime: '2017-12-13T02:19:22Z'
          status: 'True'
          type: Admitted
      host: old.test.site

I get the following error messages:

Failed to process the resource. Reason: Route "test" is invalid: spec.host: Invalid value: "old.test.site": field is immutable

-- johntanquinco
kubernetes
openshift

1 Answer

7/20/2018

As Graham Dumpleton wrote:

As far as I know you can't edit the host in place for an existing route. From the command line try

oc get route test -o yaml > route.yaml

Then edit the route.yaml and run

oc replace route test -f route.yaml 

The replace action may allow you to do it. Else after editing local copy, try

oc delete route test

and

oc apply route test -f route.yaml

In doing this, when edit the file, you can delete the whole status section.

But keep in mind there are exist some fields which are required and you cannot delete them. That's why you had a problem with modification.

-- Nick Rak
Source: StackOverflow