I am newly studying kubernetes for my own interest, i am trying to create jenkins jobs to deploy our application. I have one master and worker machine and both are up and running i can able ping both machine from one to another.
As of now, i don't have any pods and deployment services my cluster its fresh setup environment. right now jenkins file contains Pod Template for nodejs and docker with single stage to install NPM modules.
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'
}
}
}
}
}
Now the question is if run the jenkins jobs with above code, above mentioned docker and nodejs image will download from docker registry and this will save into my local machine ? how this will work, can you please some one explain me ?
The above code is for jenkins plugin https://github.com/jenkinsci/kubernetes-plugin.
So the running the above jenkins would run job on a agent or on master. The images would be downloaded to that agent/master. The above plugin is used to setup jenkins agent, so if there are no agents, it would be run on master.