1、用户相对目录cat ~/.kube/config
echo (certificate-authority-data的数据)| base64 > ca.crt
echo (client-certificate-data的数据) | base64 > client.crt
echo (client-key-data的数据) | base64 > client.key
2、Manage Jenkins->Manage nodes and clouds ->config clouds
3、选择X.509 client Certificate
4、
5、Jenkins 地址:填写kubectl get ep jenkins(服务)
6、Manage Jenkins->config global security->agents:
选择fix:50000,勾选Inbound TCP Agent Protocol/4
7、在pipeline中写入脚本:
def label = “mypod-${UUID.randomUUID().toString()}”
podTemplate(label: label, cloud: ‘kubernetes’) {
node(label) {
stage(‘Run shell’) {
sh ‘sleep 130s’
sh ‘echo hello world.’
}
}
}
8、运行脚本