转【非容器化Jenkins连接Kubernetes】

一、环境说明

OS系统版本:Ubuntu 18.04 TLS

软件版本:Jenkins 2.121.2

Kubernetes plugin 1.10.2

Kubernetes集群 1.10.4

二、添加kubernetes plugin

系统管理->管理插件->可选插件,搜索kubernetes plugin并选择安装

三、配置kubernetes plugin连接kubernetes集群

1.点击系统管理->系统设置-添加一个云,在下拉菜单中选择kubernets并添加

2.填写云kubernetes配置内容

注:Name值任意添加,Kubernetes URL值添加K8S apiserver连接地址和端口,jenkins URL值添加jenkins UI访问地址和端口,

3.添加云kubernetes中添加pod template并配置

注:Docker image值jenkins/jnlp-slave:3.23-1-alpine,Arguments to pass to the command值${computer.jnlpmac} ${computer.name}

4.配置云kubernetes连接K8S集群的验证文件

1)获取K8S的/root/.kube/config文件

  1. # cat /root/.kube/config

  2.  

    apiVersion: v1

  3.  

    clusters:

  4.  

    - cluster:

  5.  

    certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUR2akNDQXFhZ0F3SUJBZ0lVYTdJRGZlOENZdmc0ZGpBR0cxQS81WHBLZVRNd0RRWUpLb1pJaHZjTkFRRUwKQlFBd1pURUxNQWtHQTFVRUJoTUNRMDR4RURBT0JnTlZCQWdUQjBKbGFVcHBibWN4RURBT0JnTlZCQWNUQjBKbAphVXBwYm1jeEREQUtCZ05WQkFvVEEyczRjekVQTUEwR0ExVUVDeE1HVTNsemRHVnRNUk13RVFZRFZRUURFd3ByCmRXSmxjbTVsZEdWek1CNFhEVEU0TURjeE9UQTBNVEl3TUZvWERUSXpNRGN4T0RBME1USXdNRm93WlRFTE1Ba0cKQTFVRUJoTUNRMDR4RURBT0JnTlZCQWdUQjBKbGFVcHBibWN4RURBT0JnTlZCQWNUQjBKbGFVcHBibWN4RERBSwpCZ05WQkFvVEEyczRjekVQTUEwR0ExVUVDeE1HVTNsemRHVnRNUk13RVFZRFZRUURFd3ByZFdKbGNtNWxkR1Z6Ck1JSUJJakFOQmdrcWhraUc5dz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OMnpOSEw5SUppWHVQUGViZGtSYVNnMGIvZzMKc3BNeFZTY05jNDR3MGFyQ0ZFU2Foa0tMbHJFRGNjbjcxSVpPb2dEMStaMHgycFB4RDc5OWNlQjlxMUtsNnhOWQp6T2s9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K

  6.  

    server: https://10.10.10.203:6443

  7.  

    name: kubernetes

  8.  

    contexts:

  9.  

    - context:

  10.  

    cluster: kubernetes

  11.  

    user: admin

  12.  

    name: kubernetes

  13.  

    current-context: kubernetes

  14.  

    kind: Config

  15.  

    preferences: {}

  16.  

    users:

  17.  

    - name: admin

  18.  

    user:

  19.  

    client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUQzVENDQXNXZ0F3SUJBZ0lVSkw2RzR5YjlsaGwvWlIyT01laENmbVBOK2s4d0RRWUpLb1pJaHZjTkFRRUwKQlFBd1pURUxNQWtHQTFVRUJoTUNRMDR4RURBT0JnTlZCQWdUQjBKbGFVcHBibWN4RURBT0JnTlZCQWNUQjBKbAphVXBwYm1jeEREQUtCZ05WQkFvVEEyczRjekVQTUEwR0ExVUVDeE1HVTNsemRHVnRNUk13RVFZRFZRUURFd3ByCmRXSmxjbTVsZEdWek1CNFhEVEU0TURjeE9UQTJORFF3TUZvWERUSTRNRGN4TmpBMk5EUXdNRm93YXpFTE1Ba0cKQTFVRUJoTUNRMDR4RURBT0JnTlZCQWdUQjBKbGFVcHBibWN4RURBT0JnTlZCQWNUQjBKbGFVcHBibWN4RnpBVgpCZ05WQkFvVERuTjVjM1JsYlRwdFlYTjBaWEp6TVE4d0RRWURWUVFMRXdaVGVYTjBaVzB4RGpBTUJnTlZCQU1UCkJXRmtiV2x1TUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUF2Ui9GZ2krKzJMdmUKU0ttNU11TG9DeVZ6aUVsOEVCVFhIS0tacWczMG5iOWgvUHAxZEV2a3JFbHF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jNraWVnSHYrOTZlN2oxUHNUTGdjZG9adXp6ejZZK0ZERGdITzk0ZWoKeXdndm12cW1aZmZ0cmdxK1BmOW54WmRGaHc1WmxjbDRtZTltalB6UFc5WFMyVHVsandGZytabDNrNjRESEo3VwpmM2VwOGIvSlpHTmFOWFQ3akF2ZnNhclhYNVQzNUJpS3J4Z0tFOTdvMStFbVhBVENaMXprCi0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg==

2)获取/root/.kube/config中certificate-authority-data的内容并转化成base64 encoded文件

# ecbo LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUR2akNDQXFhZ0F3SUJBZ0lVYTdJRGZlOENZdmc0ZGpBR0cxQS81WHBLZVRNd0RRWUpLb1pJaHZjTkFRRUwKQlFBd1pURUxNQWtHQTFVRUJoTUNRMDR4RURBT0JnTlZCQWdUQjBKbGFVcHBibWN4RURBT0JnTlZCQWNUQjBKbAphVXBwYm1jeEREQUtCZ05WQkFvVEEyczRjekVQTUEwR0ExVUVDeE1HVTNsemRHVnRNUk13RVFZRFZRUURFd3ByCmRXSmxjbTVsZEdWek1CNFhEVEU0TURjeE9UQTBNVEl3TUZvWERUSXpNRGN4T0RBME1USXdNRm93WlRFTE1Ba0cKQTFVRUJoTUNRMDR4RURBT0JnTlZCQWdUQjBKbGFVcHBibWN4RURBT0JnTlZCQWNUQjBKbGFVcHBibWN4RERBSwpCZ05WQkFvVEEyczRjekVQTUEwR0ExVUVDeE1HVTNsemRHVnRNUk13RVFZRFZRUURFd3ByZFdKbGNtNWxkR1Z6Ck1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBdTRxK1l2TDZMMjRZcEx3Y0cvMmoKdllFTTY5QmIxMmFzZFBtNXBLekMzc3o5Q2JnZ3llb2ZzZFNxSmFIVkNHRkFmNjBEN3J5elhPMVgxY1RGaGdYdQp5SGtrcnBLdGVyNm1aNXpRVGxrQXlyM1AyOXd0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crt的内容填写到jenkins kubernetes的Kubernetes server certificate key栏中

3)获取/root/.kube/config中client-certificate-data和client-key-data的内容并转化成base64 encoded文件

# echo LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUQzVENDQXNXZ0F3SUJBZ0lVSkw2RzR5YjlsaGwvWlIyT01laENmbVBOK2s4d0RRWUpLb1pJaHZjTkFRRUwKQlFBd1pURUxNQWtHQTFVRUJoTUNRMDR4RURBT0JnTlZCQWdUQjBKbGFVcHBibWN4RURBT0JnTlZCQWNUQjBKbAphVXBwYm1jeEREQUtCZ05WQkFvVEEyczRjekVQTUEwR0ExVUVDeE1HVTNsemRHVnRNUk13RVFZRFZRUURFd3ByCmRXSmxjbTVsZEdWek1CNFhEVEU0TURjeE9UQTJORFF3TUZvWERUSTRNRGN4TmpBMk5EUXdNRm93YXpFTE1Ba0cKQTFVRUJoTUNRMDR4RURBT0JnTlZCQWdUQjBKbGFVcHBibWN4RURBT0JnTlZCQWNUQjBKbGFVcHBibWN4RnpBVgpCZ05WQkFvVERuTjVjM1JsYlRwdFlYTjBaWEp6TVE4d0RRWURWUVFMRXdaVGVYTjBaVzB4RGpBTUJnTlZCQU1UCkJXRmtiV2x1TUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUF2Ui9GZ2krKzJMdmUKU0ttNU11TG9DeVZ6aUVsOEVCVFhIS0tacWczMG5iOWgvUHAxZEV2a3JFbHFtOFJHN3JOOGFFRkkyZi9mcHF4SwpMdFlTWmVYTjEybWFRQTBiV1JlSG1nYWxnTzBZbVpYV1psc0FOR0xLcEtJOEF4czVXeDB3WlNIdWlxeFlCOXlnCkdPR0dhMW41SmZPUDBRWFZNeTVDZlcweWtLRnZmbDJ6TENwSnRNTzJtdWZxR20zM2wrd0l0SlNKaEJUdUc0RDUKa0pnOFFSNUZzUDk1eXF2RWNnT1NrNUZpNFVKZkcwakY1Rnd3UGt1ekhnTmNFQ29YMVNrTlk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key

4)生产Client P12认证文件cert.pfx,并下载至本地

  1. # openssl pkcs12 -export -out /opt/crt/cert.pfx -inkey /opt/crt/client.key -in /opt/crt/client.crt -certfile /opt/crt/ca.crt

  2.  

    Enter Export Password:

  3.  

    Verifying - Enter Export Password:

  4.  

  5.  

    # sz /opt/crt/cert.pfx

注:自定义一个password并牢记

5)在云kubernetes中添加凭证

注:Upload certificate上次刚生成并下载至本地的cert.pfx文件,Password值添加生成cert.pfx文件时输入的密钥

6)测试连接kubernetes集群

注:Kubernetes Namespace值添加/root/.kube/config文件中cluster部分中name的内容

5.配置jenkins jnlp代理端口

系统管理->全局安全配置中的"代理"项,指定端口为50000

参考文档:https://illya-chekrygin.com/2017/08/26/configuring-certificates-for-jenkins-kubernetes-plugin-0-12/

--------------------- 本文来自 不倒翁Jason 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/mario_hao/article/details/81332546?utm_source=copy

原文地址:https://www.cnblogs.com/uglyliu/p/9712559.html

时间: 2024-11-08 11:14:07

转【非容器化Jenkins连接Kubernetes】的相关文章

配置 Jenkins 连接 Kubernetes 集群

需求:外部 Jenkins 需要连接 Rancher 中的 Kubernetes 集群. 1.集群 config 文件 Rancher 首页,"集群" --> 右上角"Kubeconfig 文件",后续需要用到该文件内容. apiVersion: v1 kind: Config clusters: - name: "cicd" cluster: server: "https://rancher.xxxxxx.com/k8s/clu

PPT下载 | 亿级用户万台服务器背后,vivo云服务容器化如何破茧化蝶?

2018年数人云Meetup第一站,联合vivo在深圳举办 Building Microservice 系列活动第一期.本次技术沙龙vivo.中兴通讯.华为.数人云共同派出技术大咖,为开发者们带来有关微服务.容器化.配置中心.服务网格等领域的实战与干货分享. 数人云Meetup每月一期,欢迎大家来面基.学习.本文为vivo云计算架构师袁乐林分享的"vivo云服务容器化实践"现场演讲实录. 今天讲的内容主要是介绍技术背景,产品的技术架构,我们关键技术的实践,前车之鉴,以及对下一代云服务架

亿级用户万台服务器背后,vivo云服务容器化如何破茧化蝶?

2018年数人云Meetup第一站,联合vivo在深圳举办 Building Microservice 系列活动第一期.本次技术沙龙vivo.中兴通讯.华为.数人云共同派出技术大咖,为开发者们带来有关微服务.容器化.配置中心.服务网格等领域的实战与干货分享. 数人云Meetup每月一期,欢迎大家来面基.学习.本文为vivo云计算架构师袁乐林分享的"vivo云服务容器化实践"现场演讲实录. 今天讲的内容主要是介绍技术背景,产品的技术架构,我们关键技术的实践,前车之鉴,以及对下一代云服务架

有容云:微服务容器化的挑战和解决之道

注: 本文根据6月是18日七牛云微服务课堂-微服务容器化的挑战和解决之道演讲内容整理而成,演讲者:有容云联合创始人兼首席架构师马洪喜,与大家一起探讨了如何通过容器技术将微服务和 DevOps 落地. 嘉宾介绍: 马洪喜,此前担任 Rancher Labs 中国区技术负责人.Citrix 公司资深架构师.Oracle 公司虚拟化产品开发经理等职务,在容器云.IaaS 云.桌面云建设方面拥有丰富的经验. 单体架构 VS 微服务架构 传统单体架构存在各种各样的问题,如加载编译耗时长.代码管理复杂.横向

微服务容器化的挑战和解决之道

注: 本文根据6月是18日七牛云微服务课堂-微服务容器化的挑战和解决之道演讲内容整理而成,演讲者:有容云联合创始人兼首席架构师马洪喜,与大家一起探讨了如何通过容器技术将微服务和 DevOps 落地. 嘉宾介绍: 马洪喜,此前担任 Rancher Labs 中国区技术负责人.Citrix 公司资深架构师.Oracle 公司虚拟化产品开发经理等职务,在容器云.IaaS 云.桌面云建设方面拥有丰富的经验. 单体架构 VS 微服务架构 传统单体架构存在各种各样的问题,如加载编译耗时长.代码管理复杂.横向

研发环境容器化实施过程(docker + docker-compose + jenkins)

目录 背景介绍 改造思路 容器构建 基础准备 中间件容器 外部依赖容器 业务应用容器 容器整合 自动构建容器 Maven相关 非Maven项目 总结 背景介绍 目前公司内部系统(代号GMS)研发团队,项目整体微服务规模大概是4+9+3的规模,4个内部业务微服务,9个是外部平台或者基础服务(文件资源/用户中心/网关/加密等),3个中间件服务(数据库/Redis/Nacos). 分为2个组,迭代周期为2周.需求和排期都是会有交叉,会保证每周都有迭代内容交付,另外技术部门也在进行性能优化以及代码规约的

jenkins的容器化部署以及k8s应用的CI/CD实现

1. 使用Helm安装Mysql: ??上一篇博文谈到了如何使用Helm安装Redis和RabbitMQ,下来我们来聊聊如何用Helm安装mysql. ??本人对于Mysql数据库不是非常熟悉,因为我们公司的分工比较明确,数据库这块的工作主要由DBA负责,运维同学只负责应用的维护. ??按照我们前面博文的描述,首先是在官方文档查看helm安装mysql的书名: https://github.com/helm/charts/tree/master/stable/mysql ??我根据官方文档的描述

Kubernetes 集群的两种部署过程(daemon部署和容器化部署)以及glusterfs的应用!

ClusterIp:通过VIP来访问, NodePort: 需要自己搭建负载据衡器 LoadBalancer:仅仅用于特定的云提供商 和 Google Container Engine https://www.nginx.com/blog/load-balancing-kubernetes-services-nginx-plus/ port:相当于服务端口(对及集群内客户访问) targetPort: 相当于pods端口 nodePort: 宿主机端口(也是服务端口,只不过是对集群外客户访问)

Docker+Kubernetes(k8s)微服务容器化实践

Docker+Kubernetes(k8s)微服务容器化实践网盘地址:https://pan.baidu.com/s/1uVkMsKgfzsJcShlnuLk3ZQ 密码:1i7q备用地址(腾讯微云):https://share.weiyun.com/5ZcsfIX 密码:udrifz Docker官方支持Kubernetes, Kubernetes是容器编排最大赢家,Kubernetes 以其高效.简便.高水平的可移植性等优势占领了绝大部分市场,江湖一哥地位毋庸置疑,脱胎于谷歌的成熟的Borg