在jenkins中连接kubernetes集群

微信公众号搜索 DevOps和k8s全栈技术 ,关注之后,在后台回复 k8s视频就可获取k8s相关视频和文档,也可扫描文章最后的二维码关注公众号。

配置kubernetes plugin连接kubernetes集群

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

2.填写云kubernetes配置内容

注:Name值任意添加,Kubernetes URL值添加K8S apiserver连接地址和端口
配置云kubernetes连接K8S集群的验证文件

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

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJd01EVXlPVEUwTlRnMU5Gb1hEVE13TURVeU56RTBOVGcxTkZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTWh6CmE5bkc5NFp1SVZNZEp0NGo1dGlYcEl2WmIvczFKMVNuTVhYREt0djVqQk4xU0NoMU1VU3dYWVNlLzdVWGtjUWwKTHlUTThQVmdtY0d5TFFiOGJxZDRvS3FRQW1ZR2UzNHRtN3FoYzExSEF5V2JvSWt4QmMyV21DNmwxc1U3MGlDNQpqY216ZGMrR3h2a0MyQmx2NE1Gam5YTmwxRkF2OTdhT0pIemh4UUJwanZhMUdrdkJoVWEvdDh6Mm5GVTlwVUVrClgzZGVoNWJmRi91WVVRRlJlUEVuZHdrdGxnd1V4VUN2ZDJNNFBsOWhQMDA0L3gvbGZOeEFBTGRpNkhMOCtoSFUKeWRSTjV5dEl2Wm5ib093MXEyUlJnWU9sVEVDUFRNYmFCZks0STBkVjFkYVZVK3l2OGo1QmVIWktabE1pbGxzNApuSWJFOXU4UlR0cjl5anNlbmRFQ0F3RUFBYU1qTUNFd0RnWURWUjBQQVFIL0JBUURBZ0trTUE4R0ExVWRFd0VCCi93UUZNQU1CQWY4d0RRWUpLb1pJaHZjTkFRRUxCUUFEZ2dFQkFKZml6SVNDMWJ5UkRBaHlPZTJsK051eHF6cGkKVURxRlZSWHMzTEIzeUpWeE9PMUhlSTYwbzgwWndsSFJybVA0Mmt2QVdvcURwd3BXK1FUUUptemFXa0JtUllWRApqZkNxVVpJS0FjTENIY3duL1I3NnkySlE0TTdXR3c4VGc5dnRuMmdXRktrOWZabTM2c0ZLMjdYQTFxWVBrOGJsClBFRUd3RXYwbnBSUjZialJEdjladXZydkJQU1NhdFo5TzFoZHZ2bVJLWk95dHR6THFVOVVPUnAxemJ6OGFOSTcKVmNhN3ZFMnV5SnJvWnNLRmxvb05neVhhRnBtSEpNdzM2Smx3SEozcFRvMWMvQVl6TTY1QU81d0JrS3M4YStOYgpOcDRsS3Jtem9aaEZqeTNLL2FTK3Y4S3ZWOEVpVVJ3MXVJV1R4U1dydE9JeE9rdEQ0THZLb2pwM255az0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
    server: https://192.168.0.6:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJY3FZaFRlSEh0eDR3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TURBMU1qa3hORFU0TlRSYUZ3MHlNVEExTWpreE5EVTROVGhhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOX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ExVWRFd0VCCi93UUZNQU1CQWY4d0RRWUpLb1pJaHZjTkFRRUxCUUFEZ2dFQkFKZml6SVNDMWJ5UkRBaHlPZTJsK051eHF6cGkKVURxRlZSWHMzTEIzeUpWeE9PMUhlSTYwbzgwWndsSFJybVA0Mmt2QVdvcURwd3BXK1FUUUptemFXa0JtUllWRApqZkNxVVpJS0FjTENIY3duL1I3NnkySlE0TTdXR3c4VGc5dnRuMmdXRktrOWZabTM2c0ZLMjdYQTFxWVBrOGJsClBFRUd3RXYwbnBSUjZialJEdjladXZydkJQU1NhdFo5TzFoZHZ2bVJLWk95dHR6THFVOVVPUnAxemJ6OGFOSTcKVmNhN3ZFMnV5SnJvWnNLRmxvb05neVhhRnBtSEpNdzM2Smx3SEozcFRvMWMvQVl6TTY1QU81d0JrS3M4YStOYgpOcDRsS3Jtem9aaEZqeTNLL2FTK3Y4S3ZWOEVpVVJ3MXVJV1R4U1dydE9JeE9rdEQ0THZLb2pwM255az0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo= | base64 -d > /opt/crt/ca.crt

将ca.crt的内容填写到jenkins kubernetes的Kubernetes server certificate key栏中

3.获取/root/.kube/config中client-certificate-data和client-key-data的内容并转化成base64 encoded文件
echo  LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJY3FZaFRlSEh0eDR3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TURBMU1qa3hORFU0TlRSYUZ3MHlNVEExTWpreE5EVTROVGhhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXZLTi96cFRhRzlXRUpLWnoKN0NndUJQZkdpODJYOWZ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T2lmd084a21STU5LR1VDWmNyTzJISEZadAo2dVA3QWdMSUg2dzdia3VkamZ1NktYRmhCMjBsRC9BWU1FYkpQM1F1MFMyTkFUVEZySEZnTXc9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo= | base64 -d > /opt/crt/client.key

4.生产Client P12认证文件cert.pfx,并下载至本地
openssl pkcs12 -export -out /opt/crt/cert.pfx  -inkey  /opt/crt/client.key  -in  /opt/crt/client.crt  -certfile /opt/crt/ca.crt
Enter Export Password:
Verifying - Enter Export Password:
sz /opt/crt/cert.pfx
注:自定义一个password并牢记

5.在云kubernetes中添加凭证

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

6.测试连接kubernetes集群

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

往期精彩文章回顾

kubernetes全栈技术+企业案例演示【带你快速掌握和使用k8s】

kubernetes面试题汇总

DevOps视频和资料免费领取

kubernetes技术分享-可用于企业内部培训

kubernetes系列文章第一篇-k8s基本介绍

kubernetes系列文章第二篇-kubectl

kubernetes集群中部署EFK日志管理系统

Kubernetes中部署MySQL高可用集群

Prometheus+Grafana+Alertmanager搭建全方位的监控告警系统-超详细文档

k8s1.18多master节点高可用集群安装-超详细中文官方文档

Kubernetes Pod健康检查-livenessProbe和readinessProbe

kubernetes pod生命周期管理-postStart和preStop

k8s中蓝绿部署、金丝雀发布、滚动更新汇总

运维常见问题汇总-tomcat篇

运维常见问题汇总-tomcat部署java项目大量close_wait解决方案

关于linux内核参数的调优,你需要知道

jenkins+kubernetes+harbor+gitlab构建企业级devops平台

                                                                                                                

技术交流群

                                       扫码加群????

微信:luckylucky421302

微信公众号

                                     长按指纹关注公众????

                                        点击在看少个bug????

 

你可能感兴趣的:(在jenkins中连接kubernetes集群)