首页 > 解决方案 > 在 Kubernetes 上自动部署

问题描述

我在 Github 上有一个分支,我确实从中提取请求并添加一些功能并创建一个新功能分支。所以我有主分支,功能 1 分支,功能 2 分支..等等。我想要的是自动构建它们的每个功能分支的每个图像的 docker 图像,然后将它们部署在 kubernetes 上并使用 url 公开它们的服务(kubernetes 在 AWS 上)。之后,如果我在拉取请求后批准功能分支到大师,删除其在k8s上的部署。提前致谢

标签: gitamazon-web-servicesgithubkubernetesgithub-actions

解决方案


如果您使用 GitHub,您可以使用GitHub 操作来实现此目的,如果您在 GitLab 上,您也可以使用GitLab CI pipeline来实现。

这是配置的完整示例:https ://about.gitlab.com/blog/2017/09/21/how-to-create-ci-cd-pipeline-with-autodeploy-to-kubernetes-using-gitlab-and -舵/

For feature branch you can keep different config name, service name, deployment name. 

in CI add the logic if branch name if staging 
apply the feature Yaml with command 

kubectl delete -f .....if branch name is feature apply the yaml with command

kubectl apply -f

这很简单,但是您可能必须使用更多详细信息更新问题。


推荐阅读