Skip to content
This repository has been archived by the owner on Nov 12, 2023. It is now read-only.

k8s-jenkins-slave-deploy

License

Notifications You must be signed in to change notification settings

cloutainer/k8s-jenkins-slave-deploy

Repository files navigation

‼️ DEPRECATED AND ARCHIVED

k8s-jenkins-slave-deploy

Kubernetes Docker image providing all the Deploy Tools.


 

Preinstalled Tools

tool version
cloudfoundry cli apt-get
kubernetes cli apt-get
docker cli* apt-get
git apt-get
curl, wget apt-get
zip, bzip2 apt-get
jq apt-get

* You need to mount the /var/run/docker.sock as volume.


 

Usage

Use with Kubernetes Jenkins Plugin like so:

podTemplate(
  name: 'deploy-v1',
  label: 'k8s-jenkins-slave-deploy-v1',
  cloud: 'mycloud',
  nodeSelector: 'failure-domain.beta.kubernetes.io/zone=eu-west-1a',
  containers: [
    containerTemplate(
      name: 'jnlp',
      image: 'cloutainer/k8s-jenkins-slave-deploy:v1',
      privileged: false,
      command: '/opt/docker-entrypoint.sh',
      args: '',
      alwaysPullImage: false,
      workingDir: '/home/jenkins',
      resourceRequestCpu: '500m',
      resourceLimitCpu: '1',
      resourceRequestMemory: '3000Mi',
      resourceLimitMemory: '3000Mi',
      volumes: [hostPathVolume(
        hostPath: '/var/run/docker.sock',
        mountPath: '/var/run/docker.sock'
        )]
    )
  ]
) {
  node('k8s-jenkins-slave-deploy-v1') {
    stage('docker') {
      sh 'docker ps'
    }
  }
}

Debug - Open a bash to e.g. check the tools

docker run -i -t -v /var/run/docker.sock:/var/run/docker.sock \
       --entrypoint "/bin/bash" cloutainer/k8s-jenkins-slave-deploy:v1
$> docker ps
...

Why does it run as root? - Well - Because of the docker.sock. Long Story: The docker.sock belongs to user root and group docker. But the GID of the docker group might vary on your k8s host system, so there is no (clean) way to add the jenkins user to that gid inside the container. Simply chmod 777 on the sock is a big security risk too. So for now, this particular pod runs as root user until I have figured out a cleaner solution.


 

License

MIT © Bernhard Grünewaldt