简体   繁体   English

如何通过 Jenkins 在 EKS 中部署 kubernetes 应用程序

[英]how to deploy kubernetes application in EKS through Jenkins

I'm trying to deploy Kubernetes application in AWS EKS through Jenkins.我正在尝试通过 Jenkins 在 AWS EKS 中部署 Kubernetes 应用程序。

I visited few of blogs, they mentioned Jenkins X. But JenkinsX need to be configured separately.我访问了一些博客,他们提到了 Jenkins X。但是 JenkinsX 需要单独配置。 But as per instruction, we need to use our existing Jenkins for K8S app deployment.但是按照说明,我们需要使用我们现有的 Jenkins 进行 K8S 应用程序部署。

Note: AWS EKS and Jenkins are Separate machine(We using our existing Jenkins).注意:AWS EKS 和 Jenkins 是独立的机器(我们使用我们现有的 Jenkins)。 I may need to create New EKS environment based on requirement.我可能需要根据要求创建新的 EKS 环境。

Please suggest if any AWS EKS plugin for Jenkins which can be used for deployment.请建议是否有任何适用于 Jenkins 的 AWS EKS 插件可用于部署。

Else别的

Is there any way to create custom Bash script(automation script) for deploying K8S application in AWS EKS?有什么方法可以创建自定义 Bash 脚本(自动化脚本)以在 AWS EKS 中部署 K8S 应用程序

My Research here is: Actually AWS is providing api/sdk support for only Creating/Managing Clusters but not deploying the application in k8s environment(using kubectl ).我的研究是:实际上 AWS 只为创建/管理集群提供 api/sdk 支持,而不是在 k8s 环境中部署应用程序(使用kubectl )。

Probably creating cluster we can do it through SDK.可能创建集群我们可以通过 SDK 来完成。 but How to deploy k8s application on remotely(because Jenkins is running in another machine).但是如何远程部署 k8s 应用程序(因为 Jenkins 正在另一台机器上运行)。

Look at kubernetes-cd plugin.查看 kubernetes-cd 插件。 Follow the link https://github.com/jenkinsci/kubernetes-cd-plugin按照链接https://github.com/jenkinsci/kubernetes-cd-plugin

Why not configuring kubectl for jenkins and deploy apps using kubectl apply deployment.yaml command?为什么不为 jenkins 配置kubectl并使用kubectl apply deployment.yaml命令部署应用程序?

Once you have kubectl config you can save it as secret text.一旦你有了 kubectl 配置,你可以将它保存为秘密文本。 I had an assignment for the interview and here is an example of such deployment: https://github.com/mtuktarov/hello我有一个面试任务,这里是这种部署的一个例子: https://github.com/mtuktarov/hello

It uses shared lib: https://github.com/mtuktarov/hello-jenkins-lib它使用共享库: https://github.com/mtuktarov/hello-jenkins-lib

Finally I'm done this exercise by creating Bash automation script , following these steps:最后,我按照以下步骤创建Bash 自动化脚本来完成此练习:

  1. Created Docker image with application binary.使用应用程序二进制文件创建 Docker 映像。

  2. Created EKS Cluster using eksctl create cluster <PARAM> , which creates EKS Control Plane and Worker nodes.使用eksctl create cluster <PARAM>创建了 EKS 集群,该集群创建了 EKS 控制平面和工作节点。

  3. Created Kubernetes Deployment File using Docker image and Deployed using kubectl apply <PARAM> commandline.使用 Docker 映像创建 Kubernetes 部署文件并使用kubectl apply <PARAM>命令行进行部署。

  4. Exposed the application using kubectl expose <PARAM> cli.使用kubectl expose <PARAM> cli 公开应用程序。

Latest Update From AWS EKS Service: AWS EKS 服务的最新更新:

AWS recently announced AWS EKS Worker node creation support using AWS SDK. AWS 最近宣布了使用 AWS SDK 创建 AWS EKS Worker 节点的支持。 So now Creating EKS environment can be done using SDK itself.所以现在可以使用 SDK 本身来创建 EKS 环境。

=================== ====================

Update:更新:

Now AWS has Supported Creating worker node thorugh UI and AWS SDK.现在 AWS 已经支持通过 UI 和 AWS SDK 创建工作节点。 https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EKS.html#createNodegroup-property https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EKS.html#createNodegroup-property

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

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