1、jenkins 服务器安装 kubectl 命令行工具
2、配置 kubectl 命令行授权文件
复制 k8s 的 ./kube/config 到 jenkins 家目录 /var/lib/jenkins/.kube/config
3、创建流水线,部署 pod
4、配置 pipeline 内容
pipeline {
agent any
stages {
stage('deploy pod') {
steps {
sh """
kubectl run pod-whoami --image=containous/whoami
"""
}
}
}
}
5、运行任务
6、检测是否部署成功
kubectl get pods -o wide
curl 10.46.0.2