You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Go to Manage Jenkins | Bottom of Page | Cloud | Kubernetes (Add kubenretes cloud)
5
+
* Fill out plugin values
6
+
* Name: kubernetes
7
+
* Kubernetes URL: https://kubernetes.default:443
8
+
* Kubernetes Namespace: jenkins
9
+
* Credentials | Add | Jenkins (Choose Kubernetes service account option & Global + Save)
10
+
* Test Connection | Should be successful! If not, check RBAC permissions and fix it!
11
+
* Jenkins URL: http://jenkins
12
+
* Tunnel : jenkins:50000
13
+
* Apply cap only on alive pods : yes!
14
+
* Add Kubernetes Pod Template
15
+
* Name: jenkins-slave
16
+
* Namespace: jenkins
17
+
* Labels: jenkins-slave (you will need to use this label on all jobs)
18
+
* Containers | Add Template
19
+
* Name: jnlp
20
+
* Docker Image: aimvector/jenkins-slave
21
+
* Command to run : <Makethisblank>
22
+
* Arguments to pass to the command: <Makethisblank>
23
+
* Allocate pseudo-TTY: yes
24
+
* Add Volume
25
+
* HostPath type
26
+
* HostPath: /var/run/docker.sock
27
+
* Mount Path: /var/run/docker.sock
28
+
* Timeout in seconds for Jenkins connection: 300
29
+
* Save
30
+
31
+
# Test a build
32
+
33
+
To run docker commands inside a jenkins agent you will need a custom jenkins agent with docker-in-docker working.
34
+
Take a look and build the docker file in `./dockerfiles/jenkins-agent`
35
+
Push it to a registry and use it instead of above configured `* Docker Image: jenkins/jnlp-slave`
36
+
If you do not use the custom image, the below pipeline will not work because default `* Docker Image: jenkins/jnlp-slave` public image does not have docker ability.
37
+
38
+
* Add a Jenkins Pipeline
39
+
40
+
```
41
+
node('jenkins-slave') {
42
+
43
+
stage('unit-tests') {
44
+
sh(script: """
45
+
docker run --rm alpine /bin/sh -c "echo hello world"
0 commit comments