使用kubernetes进行本地开发的最佳实践是什么? [英] What is the best practice to use kubernetes for local development?

查看:57
本文介绍了使用kubernetes进行本地开发的最佳实践是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用docker容器,并且具有用于本地开发和生产环境的docker-compose文件.我想为我的新应用尝试Google Cloud Platform,尤其是Google Kubernetes Engine.我的工具是在本地计算机上具有Kubernetes的Docker for Mac.

I am using docker containers and have docker-compose files for both local development and production environment. I want to try Google Cloud Platform for my new app and specifically Google Kubernetes Engine. My tools is Docker for Mac with Kubernetes on local machine.

对于开发人员来说,能够更改代码并实时查看更改以进行本地开发非常重要.

It is super important for developers to be able to change code and to see changes live for local development.

用例:

  1. 后端开发人员对基本的Flask API(或您使用的任何内容)进行了更改,应该会立即在重新加载的应用程序上看到更改.

  1. Backend developer make changes to basic Flask API (or whatever you use) and should see changes on reloaded app immediately.

前端开发人员对HTML布局进行了更改,应该会立即在网页上看到更改.

Frontend developer make changes to HTML layout and should see changes on web page immediately.

此刻,我正在使用docker-compose文件将源代码挂载到本地容器.但是Kubernetes不支持安装源代码的相对路径.

At the moment i am using docker-compose files to mount source code to local containers. But Kubernetes does not support relative paths to mount the source code.

理想情况下,我应该能够设置变量

Ideally i should be able to set the variable

Deployment.spec.templates.spec.containers.volumes.hostPath

Deployment.spec.templates.spec.containers.volumes.hostPath

作为我的回购的相对路径.例如,在我们的团队中,开发人员将存储库克隆到以下文件夹:

as relative path to my repo. For example, in our team developers clone repo to this folders:

/用户/BACKEND_developer/code/project_repo

/User/BACKEND_developer/code/project_repo

/User/FRONTEND_developer/code/project_repo

/User/FRONTEND_developer/code/project_repo

显然,在对源代码进行很小的改动之后,您就无法提交和构建映像.

Obviously you can't commit and build the image after every little change to the source code.

那么,使用Kubernetes进行本地开发的最佳实践是什么?我是否需要其他工具来为每个开发人员修改.yaml文件?

So what is the best practice for local development with Kubernetes? Do i need some additional tools to modify .yaml files for every developer?

推荐答案

@tgogos是正确的. 实现目标的最佳方法是使用

@tgogos is right. The best way to achieve your goal is to use Skaffold

每当看到源代码中的更改,它将重新构建容器.

It will rebuild container whenever it sees changes in source code.

Skaffold具有可插拔的体系结构,可让您选择开发人员工作流程中最适合您的工具:

Skaffold has a pluggable architecture that allows you to choose the tools in developer workflow that work best for you:

这篇关于使用kubernetes进行本地开发的最佳实践是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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