We have a deployed API in Kubernetes. The API is deployed via replication controller to pods and a managing rc. I would like to update the configuration to the API pods using rolling-update. I can do that, however the only way I can get the rolling-update command to not error is by changing the name of the RC. But doing this breaks the link from my Service (exposed as a load balancer) to the RC and it cannot find my pods anymore. Does someone have an example config for updating a replication controller without changing the name?
apiVersion: v1
kind: ReplicationController
metadata:
name: my-api
labels:
name: my-api
spec:
replicas: 4
selector:
name: my-api
template:
metadata:
labels:
name: my-api
spec:
containers:
- name: my-api
image: docker-registry.example.com/mynamespace/my-api
command: [ "sh", "-c", "/do/the/thing/run"]
resources:
limits:
cpu: 0
ports:
- name: web
containerPort: 80
env:
- name: "HELLO"
value: "WORLD"
And I would like, for example to change the env var "HELLO" to "Bob" or something.
So I came up with a strategy that might work. Most of the documentation I was working off of had the Service selector based on the name of the pod. That doesn't work, because the name HAS to change when performing a rolling update. It's best to make the service.spec.selector something like "type=api-server" or some other metadata label then add type=api-server to your pods. (Remember services point at pods directly, not RCs)
Replication Controller:
Service:
Then if you want to update your pod's config, you just change {{randomDigits}} to something new and you can perform a rolling update without breaking the link from your Service to your Pods.