1
votes

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

2
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.Graham Dumpleton

2 Answers

2
votes

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.

0
votes

Fwiw the replace command did not work (at least using OpenShift v4.8). Instead I had to delete the route, then re-create it:

oc delete route test
oc process -f test-route.yaml namespace=$NAMESPACE domain=$DOMAIN | oc apply -f -