Rename deployment in Kubernetes

As others mentioned, kubernetes objects names are immutable, so technically rename is not possible.

A hacking approach to emulate some similar behavior would be to delete an object and create it with a different name. That is a bit dangerous as some conflicts can happen depending on your object. A command line approach could look like this:

    kubectl get deployment analytics-rethinkdb -o json \
        | jq '.metadata.name = "rethinkdb"' \
        | kubectl apply -f - && \
    kubectl delete deployment analytics-rethinkdb

Object names are immutable in Kubernetes. If you want to change a name, you can export/edit/recreate with a different name

Tags:

Kubernetes