我正在尝试使用Gradle和Fabric8 Java kubernetes-client在CI中自动部署测试构建。
我正在尝试找到正确的语法来使用新的Docker镜像标签(不是:latest)来更新RC。
就像..。
client.replacationControllers()
.inNamespace('default')
.withName('mycirc')
.edit()
.editSpec()
.editTemplate()
.editSpec()
.withContainer('mycontainername')
.withImage('myimage:newtag')
.endContainer() // <--- Not sure how to do this previous line
.endSpec()
.endTemplate()
.endSpec()
.done()我们可以在不完全删除和重建的情况下更新容器吗?
发布于 2016-02-02 15:21:04
// Update the RC - change the image to apache
client.replicationControllers().inNamespace("thisisatest").withName("nginx-controller").edit().editSpec().editTemplate().withNewSpec()
.addNewContainer().withName("nginx").withImage("httpd")
.addNewPort().withContainerPort(80).endPort()
.endContainer()
.endSpec()
.endTemplate()
.endSpec().done();尽管如评论中所指出的,这可能不会立即更新pod,除非客户端正在这样做。
看起来客户端也支持滚动更新,这将更新pods: client.replicationControllers().inNamespace("thisisatest").withName("nginx-controller").rolling().updateImage("nginx");
发布于 2018-06-05 15:30:54
您还可以通过以下代码在副本集上执行滚动更新
private static void updateRc(KubernetesClient client){
System.out.println("updating rollinh");
// client.replicationControllers().inNamespace("default").withName("my-nginx").rolling().updateImage("nginx:latest");
client.extensions().replicaSets().inNamespace("default").withName("fgrg-73-nginxcontainer1-74-97775d4d8").rolling().updateImage("nginx:latest");
System.out.println("done");
}
https://stackoverflow.com/questions/34076898
复制相似问题