我应该如何使用kubernetes管理部署 [英] How should I manage deployments with kubernetes

查看:75
本文介绍了我应该如何使用kubernetes管理部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望找到一种很好的方法来自动化从代码到kubernetes集群上已部署的应用程序的过程.

I am hoping to find a good way to automate the process of going from code to a deployed application on my kubernetes cluster.

为了构建和部署我的应用程序,我需要首先构建docker映像,对其进行标记,然后将其推送到ECR.然后,我需要使用docker映像的新标签更新我的deployment.yaml,并使用kubectl apply -f deployment.yaml运行部署.

In order to build and deploy my app I need to first build the docker image, tag it, and then push it to ECR. I then need to update my deployment.yaml with the new tag for the docker image and run the deployment with kubectl apply -f deployment.yaml.

这将在kubernetes集群上执行滚动部署,将Pod更新到容器映像的新版本,一旦完成部署,我可能需要做其他特定于应用程序的事情,例如运行数据库迁移或清除缓存/warming,对于给定的部署可能不需要运行.

This will go and perform a rolling deployment on the kubernetes cluster updating the pods to the new version of the container image, once this deployment has completed I may need to do other application specific things such as running database migrations, or cache clear/warming which may or may not need to run for a given deployment.

我想我可以编写一个运行所有这些命令的shell脚本,并在我要启动新部署时运行它,但是我希望有一种更好/行业标准的方式来解决这些问题,已经错过了.

I suppose I could just write a shell script that runs all of these commands, and run it whenever I want to start up a new deployment, but I am hoping there is a better/industry standard way to solve these problems that I have missed.

在我撰写此问题时,我注意到stackoverflow推荐了以下问题: Kubernetes部署.它的答案之一似乎暗示至少我正在寻找的一些东西很快就会进入kubernetes,但是我想确保,如果有更好的解决方案,那么我至少现在已经知道了,我现在可以使用它.

As I was writing this question I noticed stackoverflow recommend this question: Kubernetes Deployments. One of the answers to it seems to imply at least some of what I am looking for is coming soon to kubernetes, but I want to make sure that if there is a better solution I could be using now that I at least know about it.

推荐答案

我的同事在此主题上有一篇不错的博客文章:

My colleague has a good blog post about this topic:

http://blog.jonparrott.com/building-a-paas-on-kubernetes/

基本上,Kubernetes并不是平台即服务,而是一个工具包,您可以在该工具包上构建自己的平台即服务.它在设计上不是很自以为是,而是专注于解决日程安排,联网和协调容器方面的一些棘手问题,并让您在此之上发表自己的意见.

Basically, Kubernetes is not a Platform-as-a-Service, it's a toolkit on which you can build your own Platform-a-as-Service. It's not very opinionated by design, instead it focuses on solving some tricky problems with scheduling, networking, and coordinating containers, and lets you layer in your opinions on top of it.

使描述的工作流程自动化的最简单方法之一是使用Makefile.

One of the simplest ways to automate the workflows you're describing is using a Makefile.

从此开始,您可以设计自己的微型PaaS,第一篇博客文章的作者在此处进行了设计:

A step up from that, you can design your own miniature PaaS, which the author of the first blog post did here:

https://github.com/jonparrott/noel

或者,您可以参与更复杂的工作,以在Kubernetes上构建开源PaaS,例如OpenShift:

Or, you could get involved in more sophisticated efforts to build an open source PaaS on Kubernetes, like OpenShift:

https://www.openshift.com/

或Deis,它正在Kubernetes上构建类似于Heroku的平台:

or Deis, which is building a Heroku-like platform on Kubernetes:

https://deis.com/

或Redspread,它正在构建"Git for Kubernetes集群":

or Redspread, which is building "Git for Kubernetes cluster":

https://redspread.com/

,还有许多其他人在Kubernetes上构建PaaS的例子.但是我认为,如果有的话,有很长的时间可以采用一种行业标准"的方式来部署到Kubernetes,因为一半的目的是为不同的用例启用多个部署工作流.

and there are many other examples of people building PaaS on top of Kubernetes. But I think it will be a long time, if ever, that there is an "industry standard" way to deploy to Kubernetes, since half the purpose is to enable multiple deployment workflows for different use cases.

我确实要注意,就构建容器映像而言, Google Cloud Container Builder 可以是有用的工具,因为您可以执行任何操作,例如在每次将其推送到可以进行部署的存储库时使用它来自动构建映像.另外,Jenkins是使用Kubernetes自动化CI/CD流的一种流行方法.

I do want to note that as far as building container images, Google Cloud Container Builder can be a useful tool, since you can do things like use it to automatically build an image any time you push to a repository which could then get deployed. Alternatively, Jenkins is a popular way to automate CI/CD flows with Kubernetes.

这篇关于我应该如何使用kubernetes管理部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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