简体   繁体   English

使用Jenkins在本地kubernetes集群中实现CD?

[英]Implementation of CD with Jenkins for on premise kubernetes cluster?

I have my on premise kubernetes cluster. 我有本地Kubernetes集群。 I want to setup CD with jenkins. 我想用詹金斯安装CD。 I have tried two plugins which are available for kubernetes deployment. 我尝试了两个可用于kubernetes部署的插件。

  1. Kubernetes Continuous Deploy Plugin Kubernetes Continuous Deploy插件
  2. Kubernetes plugin Kubernetes插件

The question here is, jenkins master will require the .kube/config file to connect to the kubernetes cluster for doing deployments. 这里的问题是,jenkins master将需要.kube / config文件连接到kubernetes集群以进行部署。

Is this the best practice to copy the .kube/config file of your kubernetes master to jenkins master to provide full acesss of your kubernetes cluster for deployment purpose. 这是将kubernetes主机的.kube / config文件复制到jenkins主机的最佳实践,以提供kubernetes集群的全部访问权限以进行部署。

Please do let me know if you have any other suggestions for my ON-PREM kubernetes cluster CD . 如果您对我的ON-PREM kubernetes集群CD有其他建议,请不要告诉我。

you have two options 1. put all kubeconfig files in a separate git repo, say, kubeVault .git, and name the files using cluster name. 您有两种选择:1.将所有kubeconfig文件放在单独的git存储库中,例如kubeVault .git,并使用群集名称命名文件。 Accept cluster as build paramter in jenkins. 在jenkins中接受cluster作为构建参数。 Lookup the respective kubeconfig from kubeVault repo and use it as target platform and deploy the container. 从kubeVault存储库中查找相应的kubeconfig并将其用作目标平台并部署容器。 We have used this approach in one of the project. 我们在一个项目中使用了这种方法。 you need to build some logic in the pipeline groovy code 您需要在管道常规代码中构建一些逻辑

  1. define build parameters and set them using the fields from kubeconfig file. 定义构建参数并使用kubeconfig文件中的字段进行设置。 post build generate actual kubeconfig file from build params and keep it in /tmp directory. 构建后会从构建参数生成实际的kubeconfig文件,并将其保存在/ tmp目录中。 pass the kubeconfig location to kubectl to deploy the k8s obejects/pod 将kubeconfig位置传递给kubectl以部署k8s对象/ pod

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

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