【发布时间】:2019-12-14 19:52:05
【问题描述】:
为了自己的兴趣,我正在学习 kubernetes,我正在尝试创建 jenkins 工作来部署我们的应用程序。我有一台主机和一台工作机器,两台机器都已启动并正在运行,我可以将两台机器从一台机器ping通到另一台机器。
到目前为止,我的集群没有任何 Pod 和部署服务,它是全新的设置环境。 现在 jenkins 文件包含用于 nodejs 和 docker 的 Pod 模板,单阶段安装 NPM 模块。
def label = "worker-${UUID.randomUUID().toString()}"
podTemplate(
cloud: 'kubernetes',
namespace: 'test',
imagePullSecrets: ['regcred'],
label: label,
containers: [
containerTemplate(name: 'nodejs', image: 'nodejscn/node:latest', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'docker', image: 'nodejscn/node:latest', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'kubectl', image: 'k8spoc1/kubctl:latest', ttyEnabled: true, command: 'cat')
],
volumes: [
hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock'),
hostPathVolume(hostPath: '/root/.m2/repository', mountPath: '/root/.m2/repository')
]
) {
node(label) {
def scmInfo = checkout scm
def image_tag
def image_name
sh 'pwd'
def gitCommit = scmInfo.GIT_COMMIT
def gitBranch = scmInfo.GIT_BRANCH
def commitId
commitId= scmInfo.GIT_COMMIT[0..7]
image_tag = "${scmInfo.GIT_BRANCH}-${scmInfo.GIT_COMMIT[0..7]}"
stage('NPM Install') {
container ('nodejs') {
withEnv(["NPM_CONFIG_LOGLEVEL=warn"]) {
sh 'npm install'
}
}
}
}
}
现在的问题是,如果使用上面的代码运行 jenkins 作业,上面提到的 docker 和 nodejs 图像将从 docker 注册表下载,这将保存到我的本地机器中吗?这将如何工作,你能请人解释一下吗?
【问题讨论】:
标签: jenkins kubernetes