user3171689
user3171689

Reputation: 303

how to update kubernetes replication controller?

I run pods with replication controller, now i want to edit config like change value of environment and keep name of rc.

apiVersion: v1
kind: ReplicationController
metadata:
  name: backend
spec:
  replicas: 3
  template:
    spec:
      containers:
      - name: backend
        image: myproject/backend
        ports:
        - containerPort: 8080
        env:
        - name: USER_ENDPOINT
          value: "http://10.0.7.29:10000"

For example I move service to new server and just want change value of env USER_ENDPOINT to http://10.0.7.30:30100

Now I just know follow delete rc and recreate rc, but in production i don't stop it.

I try rolling-update but not work because i want keep name of replication controller.

What can i do ?

Please suggest a solution, thanks.

Upvotes: 2

Views: 1823

Answers (2)

Paul Morie
Paul Morie

Reputation: 15778

You can use kubectl edit to edit a resource:

Usage:
  kubectl edit (RESOURCE/NAME | -f FILENAME) [flags]

Examples:
  # Edit the service named 'docker-registry':
  $ kubectl edit svc/docker-registry

  # Use an alternative editor
  $ KUBE_EDITOR="nano" kubectl edit svc/docker-registry

  # Edit the service 'docker-registry' in JSON using the v1 API format:
  $ kubectl edit svc/docker-registry --output-version=v1 -o json

^^ from the kubectl help

Upvotes: 2

Michael Hausenblas
Michael Hausenblas

Reputation: 13941

You can partially update a RC using the HTTP PATCH method, like so (assuming your RC is in the default namespace):

PATCH /api/v1/namespaces/default/replicationcontrollers/backend

See also the API Reference.

Upvotes: 0

Related Questions