Jenkins集成阿里云Kubernetes

IT
IT
IT
405
文章
1
评论
2021年3月30日09:28:33 评论 4,172 7559字阅读25分11秒

安装插件

  • 外部Jenkins集成二进制k8s

Jenkins集成阿里云Kubernetes

制作Kubernetes证书

  • 进入集群服务器 .kube/config

Jenkins集成阿里云Kubernetes

  • 复制config文件中的certificate-authority-data内容,生成base64文件 ca.crt
reboot@localhost k8s % echo LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURIRENDQWdTZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREErTVNjd0ZBWURWUVFLRXcxaGJHbGkKWVdKaElHTnNiM1ZrTUE4R0ExVUVDaE1JYUdGdVozcG9iM1V4RXpBUkJnTlZCQU1UQ210MVltVnlibVYwWlhNdwpJQmNOTWpFd016TXdNVEUxTkRRd1doZ1BNakExTVRBek1qTXhNVFUwTkRCYU1ENHhKekFVQmdOVkJBb1REV0ZzCmFXSmhZbUVnWTJ4dmRXUXdEd1lEVlFRS0V3aG9ZVzVuZW1odmRURVRNQkVHQTFVRUF4TUthM1ZpWlhKdVpYUmwKY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTDRSNGFnbWt1djZGVUJEaVIxTgoyU3U4bzZPVmV6RE9xLzV1c1J1VTIzL29tUlJaMDMxQ01OMmppM1lMMmJ0ZjJyMDAwdlJrcGlWREY5WWJjTUZEClNBMDBWeFp3WE5KNk0rSnZ3d2NaNlk2ZEx6V1JNc2x3RXhvNGhFaXZWcXNJTFIwdGpaa0kvc0psa2NWWXg5VFgKVkMrZng4cklBbGFNUmxXVFZlTlJVdjhvNkk3Q1kya245RE5OY0J3UEllV0ZLYW1pbGdFY1BJN0ljZGxBdjVCSwpkMXlXYjBoWjFGU2NRYkt4c0g0akZCTlIyTEV0b3FSalMrYXpvUlRWT1ZwTTBKV2N1Wmp0NlhFNUFFWmsxTFdjCm8rZlZRTjhXbDE0VnpWdUJ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WG1oVlV4blFqSXFJODJKZlljd0lECkFRQUJvNEc2TUlHM01BNEdBMVVkRHdFQi93UUVBd0lDckRBUEJnTlZIUk1CQWY4RUJUQURBUUgvTUI4R0ExVWQKSXdRWU1CYUFGSVZhLzkwanpTVnZXRUZ2bm0xRk9adFlmWFgvTUR3R0NDc0dBUVVGQndFQkJEQXdMakFzQmdncgpCZ0VGQlFjd0FZWWdhSFIwY0RvdkwyTmxjblJ6TG1GamN5NWhiR2w1ZFc0dVkyOXRMMjlqYzNBd05RWURWUjBmCkJDNHdMREFxb0NpZ0pvWWthSFIwY0RvdkwyTmxjblJ6TG1GamN5NWhiR2w1ZFc0dVkyOXRMM0p2YjNRdVkzSnMKTUEwR0NTcUdTSWIzRFFFQkN3VUFBNEdCQUVKaXdvMWVJMkhuQ1dnQ1dqUk1neGVnZFZNMFR4MTBNZUFKSmhQRQo2cXhaWWhZNmFWV0tBbUFPME1qY21Fak5GbHRVaFBuYmJOaU55cWlOSjhxaDNFa1kwODdZMXo3SWdORDdwV2tPClFaN0lwditFUlp3dVI4V05oS1pyMUd2ZGhhUnVmNGRoa0RDelplM0lhNW9OdlNqYWorVFZlQWVvcy9OZHdraGgKNzlKRAotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==  | base64 -d > client.crt
  • 复制config文件中的client-key-data内容,生成base64文件 client.key
reboot@localhost k8s % echo LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFb2dJQkFBS0NBUUVBcmRkdmtxK3Q0cHI5VzlTUjNleEtxeEpjZ3pGVG5QcDUyQmFoUFpOZXo1MWdSV2J2CmRmdlg3WnBVMjRIWDNyeHFVUmVFdzdpRlVKZk0vdytEZHY2bm04cG5GZ1NDbDBFbXFnM2JVcXJWV09HazJuZEMKb2VnbWxsQytvMTQxcmhGUVhHUTB2bUlpeEdCTVhvMTVRNVNuWHR4RklOWGcyS2VidldXVDlrbitySytOVnphbQplMmtoN3RDT0phMzllT3o3OXU2UW1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0xJcU45WlRqV2lXRG8yd2F0a0xFCkY1NDNqRTRYN2xDOTJWdDhjWGY2RmVHRm8yTXFOejMzTUJydCtiMENnWUJDY0hGQnlsTnhwMUxqTVUxZU9PbGcKSmJSbk5KMk1QTHltV3FjdndLRlordGtZUEFOUU1BYUlBZWNzZllVVTNrVXNseU5pb1M4RTB5WW1MOWhFY0gvegpsTk1EZkVteSs3RU5oWmREUld5M2FHcnpqMmtudnUzR09NTHZYbFpNUExYVGZVMmF3c2FqSnBjSmVRM05EbWhICm5zcGZVWWkrNTRxYkFOaEdWY3RGRFFLQmdIQkNIbVpjMVVWRE85Qkp4a2d1d3FDcEc5VkpRVGNQWWhlWkZ3SmoKMnFoaWVmKys4WEVrNFpSUmhucEFQcGI2akdnNjc5TllCTUg4bU9ySWx5aWdtaFRrWEdDUXZxam1GQ25pRGczdQpDbjNrNlpMZGVjaGpJY0tmb0pXUUlvWkh0NlY5dWFMK1NubGNDQ3AvMDVyS3FGUUtCb0NnNVYzVUh0NG5IVlQrCjNkalpBb0dBUGNaa01jR2F4S21zVUQ4Tzgrd2tMKysySEFrbFo0TmJ1RXVNS2JsbHlGNEM4MzY5aFBPRWt4TS8KTll2M2lZVDF5WmVqdFRwZ0ZzdzdSQWlFbGtwTlBTVlV1ZTZRV2FYcXZxbjJhaFhDcEsvYjUzdkEvelFWb0pDUApKRmJRejVnMDd1eVpnSFRDQnRBb0k0M2s1SkMzUVpwS29ra2ZSb1dNYnZGdnZncFdhalU9Ci0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg== | base64 -d > client.key
  • 生成证书(会输入密码需要记住后面jenkins需要配置)
reboot@localhost k8s % ls

ca.crt client.crt client.key

reboot@localhost k8s % openssl pkcs12 -export -out cert.pfx -inkey client.key -in client.crt -certfile ca.crt

Enter Export Password:

Verifying - Enter Export Password:

reboot@localhost k8s % ls

ca.crt cert.pfx client.crt client.key
  • 下载证书 cert.pfx

Jenkins新建凭据

  • 新建凭据 证书类型 上传刚刚下载的证书。并输入证书密码

Jenkins集成阿里云Kubernetes

  • 将ca.crt 内容复制到 服务证书key 选择证书凭据 测试连接

Jenkins集成阿里云Kubernetes Jenkins集成阿里云Kubernetes

继续阅读
  • 我的QQ
  • QQ扫一扫
  • weinxin
  • 我的头条
  • 头条扫一扫
  • weinxin
IT
  • 本文由 发表于 2021年3月30日09:28:33
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
jenkinsfile集成阿里云镜像仓库 jenkins-ci/cd

jenkinsfile集成阿里云镜像仓库

创建Jenkins认证授权 ID也配置成aliyun-registry-admin 阿里云镜像库有个问题,在设置固定密码后,使用的是本账号名字。本账号的密码和镜像的密码也就不一样了。所以要么单独创建一...

您必须才能发表评论!