简体   繁体   English

使用Kubernetes部署Spring Boot

[英]Deploy the Spring boot with Kubernetes

I am starting the implementation in the project where I work, but I had some doubts. 我正在我工作的项目中开始实施,但是我有一些疑问。

  1. I have a project with several profiles spring, and for each I may want to have a replicated amount. 我有一个带有多个概要文件弹簧的项目,对于每个概要文件,我可能希望有一个重复的数量。

    Example: 例:

    • Dev and staging (1 replica) 开发和暂存(1个副本)
    • Production (3 replicas) 生产(3个副本)

    How should I handle this scenario, creating a deployment file for each profile? 我应该如何处理这种情况,为每个配置文件创建一个部署文件?

  2. Where do you usually keep Kubernetes .yml? 您通常将Kubernetes .yml保存在哪里? In a "kubenetes" folder within the project, or a repository just to store these files? 在项目内的“ kubenetes”文件夹中,还是仅用于存储这些文件的存储库中?

You should store them with your code in a build folder. 您应该将它们和代码一起存储在构建文件夹中。 If you are deploying on multiple platforms (AKS, EKS, GKE, OpenShift..) you could create a subfolder for each. 如果要在多个平台(AKS,EKS,GKE,OpenShift ..)上进行部署,则可以为每个平台创建一个子文件夹。

The amount of environment specific configuration should be kept to a bare minimum. 特定于环境的配置数量应保持最小。 So I would recommend using some templating for the files in your CI/CD pipeline. 因此,我建议对CI / CD管道中的文件使用一些模板。 (Helm for example) (例如头盔)

If you don't want to worry about these files you could look into Spinnaker. 如果您不想担心这些文件,可以查看Spinnaker。

I would look into using Helm charts to manage your deployments. 我将研究使用Helm图表来管理您的部署。 It's how we manage our Spring Boot apps (around 20 on my current project) and lets us inject different environment settings, including profiles, in each phase of deployment (dev, qa, production) using ConfigMaps . 这就是我们管理Spring Boot应用程序的方式(当前项目中约20个),并允许我们使用ConfigMaps在部署的每个阶段(开发,质量保证,生产)注入不同的环境设置,包括配置文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM