Rolling update image for multi container pod
See original GitHub issueIs there any way to do a rolling update on the Docker image for a multi-container pod?
I was looking at FullExample.java in the tests where it does a rolling update at https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/FullExample.java#L146-L153.
However, there is no way shown to do an update for a multi container pod. From my understanding, the way to do this would be to:
- Read the entire pod spec first (store it in an object)
- Update the spec with the new image (find container by name)
- Do a rolling update withNewSpec
PodSpec podSpec = client.replicationControllers().inNamespace("thisisatest").withName("nginx-controller").get().getSpec().getTemplate().getSpec();
List<Container> containers = podSpec.getContainers();
/* Logic to iterate, find container by name and update the image comes here.. */
client.replicationControllers().inNamespace("thisisatest").withName("nginx-controller")
.rolling()
.edit().
editSpec().
editTemplate().
withNewSpecLike(podSpec)
.endSpec()
.endTemplate()
.endSpec()
.done();
Is there a better way to do this? For example,
client.replicationControllers().inNamespace("thisisatest").withName("nginx-controller")
.rolling()
.updateImageForContainerName("nginx", "container-name");
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
How do I update container image in a multi container pod
I am running a pod that has three containers. need to update the image of one of the container without doing a rolling...
Read more >Performing a Rolling Update - Kubernetes
Rolling updates allow Deployments' update to take place with zero downtime by incrementally updating Pods instances with new ones.
Read more >Live Update Multiple Containers Per Pod - Tilt Blog
10.0, you can use Live Update on as many containers per pod as you want! This feature didn't change much on the surface...
Read more >Rolling Updates - Kubernetes
A rolling update applies changes to the configuration of pods being managed by a ... Specifying --image with multi-container pods returns an error....
Read more >Performing rolling updates | Google Kubernetes Engine (GKE)
You can perform a rolling update to update the images, configuration, labels, annotations, and resource limits/requests of the workloads in your clusters.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@parikhyash: a slightly more elegant yet powerful approach would be to use something like:
This is a pure visitor pattern implementation. The visit method will be called for every single nested visitor in the structure. In the example above we are explicit that we are interested in container builders, so it will be called just for the nested container builder.
If you have multiple containers in the structure, it will visit all of them, so you may want to wrap the statement in an if clause.
The benefit if not obvious, is that it allows you to write code that is decoupled from the internal structure and is also boilerplate free.
@parikhyash, may i please know , any blog posted on this issue? @iocanel,is the same can be done using client.extensions().replicaset()?