更新dockerfile后,如何在kubernetes中重新部署所有内容? [英] How do I redeploy everything in kubernetes after updating a dockerfile?

查看:1043
本文介绍了更新dockerfile后,如何在kubernetes中重新部署所有内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对kubernetes非常陌生,现在我想要做的就是重启我的集群并让它运行更新的dockerfile。顺便说一句,我在google-cloud-platform中运行kubernetes。

解决方案

您可以使用滚动更新机制更新服务而不中断,一次更新一个窗格,直到所需的状态匹配,并且服务仍在运行。当然,我们必须更新容器内的容器以保护我们的数据并获取最新功能。 Kubernetes通过修改部署并管理它们,可以轻松地将更新发布到您的应用程序。这是主要的更新时间,我们将使用简单的方法来调整它们。



假设您有前端,auth和后端部署,并且auth或更新的版本,所以你想更新auth部署配置文件,在这个文件中你可以在构建新的docker镜像之后将其相应的auth容器镜像更改为更新的版本,并简单地更改.yaml文件中的镜像版本并应用如下


$ b $

  $ kubectl apply -f deployments / auth.yaml 

使用部署describe命令检查它是否成功,您可以看到滚动更新策略并找出始终可用的正确数量的Pod。这使用新的副本集来确保我们运行的是最新版本的auth容器。

  $ kubectl describe deployments auth 

一旦滚动更新完成,我们可以查看auth服务的运行窗格。

  $ kubectl get pod 

检查它正在运行的时间范围。新版本的验证吊舱取代了之前的版本。再次检查新的认证吊舱的ID并验证。通过这种方式更新部署,我们可以用一种干净的声明式方法来推出对单个或数千个豆荚运行的应用程序天气的更改。

I'm very new to kubernetes and all I want to do at this point is restart my cluster and have it run an updated dockerfile. I'm running kubernetes in google-cloud-platform by the way.

解决方案

You can use rolling update mechanism to update the service without outage which will update one pod at a time until the desired state match, and still your services are up and running. Of course we must have to update our containers inside the pod to protect our data and to get latest features out. Kubernetes makes it easy to roll out updates to your applications by modifying the deployments and managing them. It's major update time and we'll use easy way to tweak them.

Suppose you have front end, auth and back-end deployments and there is change into the auth or newer version, so you want to update auth deployment configuration file in which you could change its respective auth container image to newer version after building the new docker image and simply changing the image version in your .yaml file and apply as below

$ kubectl apply -f deployments/auth.yaml

Check that it succeed with the deployment describe command, you could see the rolling update strategy and figure out that right number of pods are always available. That uses the new replica set to ensure that we are running the latest version of auth container.

$ kubectl describe deployments auth

Once, the rolling update is complete, we can view the running pods for the auth service.

$ kubectl get pods

Check the time frame for which it is running. The new version of the auth pod has replaced the previous one. Once again check with the id of the new auth pod and verify. Updating deployment this way keeps us with a clean declarative approach to roll out changes to our application weather you have single or thousands of pods running.

这篇关于更新dockerfile后,如何在kubernetes中重新部署所有内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆