From aef66a9b58c220250a146c1e20e16a96870299f5 Mon Sep 17 00:00:00 2001
From: Benjamin Muschko
Date: Thu, 18 Jul 2019 09:03:14 -0600
Subject: [PATCH] Write up description and add images
---
09-rest-api.md | 2 -
10-distributed-builds.md | 49 ++++++++++++++++++
images/10-distributed-builds/agent-config.png | Bin 0 -> 1101809 bytes
.../agent-label-config.png | Bin 0 -> 1188541 bytes
.../10-distributed-builds/build-for-label.png | Bin 0 -> 1051778 bytes
.../job-label-config.png | Bin 0 -> 1029769 bytes
.../10-distributed-builds/master-config.png | Bin 0 -> 999601 bytes
.../10-distributed-builds/node-overview.png | Bin 0 -> 963461 bytes
images/10-distributed-builds/queued-job.png | Bin 0 -> 1081039 bytes
9 files changed, 49 insertions(+), 2 deletions(-)
create mode 100644 images/10-distributed-builds/agent-config.png
create mode 100644 images/10-distributed-builds/agent-label-config.png
create mode 100644 images/10-distributed-builds/build-for-label.png
create mode 100644 images/10-distributed-builds/job-label-config.png
create mode 100644 images/10-distributed-builds/master-config.png
create mode 100644 images/10-distributed-builds/node-overview.png
create mode 100644 images/10-distributed-builds/queued-job.png
diff --git a/09-rest-api.md b/09-rest-api.md
index 6231e8d..2b103fd 100644
--- a/09-rest-api.md
+++ b/09-rest-api.md
@@ -66,7 +66,5 @@ In the terminal, navigate to the directory that contains the Jenkins CLI JAR fil
$ java -jar jenkins-cli.jar -s http://localhost:8080 -auth buildbot:pwd build gradle-initializr
```
-
-
\ No newline at end of file
diff --git a/10-distributed-builds.md b/10-distributed-builds.md
index e69de29..ee42802 100644
--- a/10-distributed-builds.md
+++ b/10-distributed-builds.md
@@ -0,0 +1,49 @@
+# Key CI/CD/Jenkins Concepts and their Usage
+
+## Configuring and executing jobs in a distributed build
+
+1. Go to "Manage Jenkins" > "Manage Nodes". You should see a single `master` node.
+2. Configure the `master` node by setting the # of executor value to 0. That will take care of never using the `master` for job workload.
+3. Have other physical or virtual machines ready that can act as agent nodes. Log into the machine as `root` user and create a new user named `jenkins` with the command `useradd -d /var/lib/jenkins jenkins`. From the `master` node, copy the contents of the `id_rsa.key` file to the clipboard. Paste the contents of the clipboard to the file `/var/lib/jenkins/.ssh/authorized_keys`.
+4. Add new nodes by clicking "New Nodes". Enter an appropriate name and select the option "Permanent Agent". Use the remote directory `/home/jenkins/jenkins_slave` and set the # of executors to 2. Enter the host and provide credentials by selecting "SSH Username with private key". To keep things easy select "Non verifying Verification Strategy".
+4. Trigger a build. You should see that the build is only executed on the agent and not the `master` node.
+5. Add at least one more agent.
+6. Trigger a build. You should see that the build can be executed on any of the agents.
+7. Configure one of the agents to only build jobs with a specific label e.g. `java`. Change the "Usage" field to "Only build jobs with label expressions matching this node".
+8. Configure the `gradle-initializr` job and assign the label `java`.
+9. Trigger a build of the `gradle-initializr` job. It is only executed by the dedicated agent.
+10. Trigger other jobs that do not have the label `java` assigned to them. They are waiting for an agent that can execute the build.
+
+Show Solution
+
+
+Configure the `master` node.
+
+
+
+Add a new agent node.
+
+
+
+You will see that the `master` node isn't even listed anymore in the executor overview.
+
+
+
+Reconfigure the agent node to only build jobs with a specific label.
+
+
+
+Reconfigure the job to only use agents that can handle a specific label.
+
+
+
+A build of the job is now only handled by an agent with the assigned label.
+
+
+
+Other jobs sit in a queue waiting for an agent that can handle the execution criteria.
+
+
+
+
+
\ No newline at end of file
diff --git a/images/10-distributed-builds/agent-config.png b/images/10-distributed-builds/agent-config.png
new file mode 100644
index 0000000000000000000000000000000000000000..df42c4ac18936e662eb213458471a55528f6198e
GIT binary patch
literal 1101809
zcmeFZ2UHVV8#W3SP*9^%1tcg(iZqd4BO;=Lf?}ab)QCZ8BE1f%h;)@MB_JXe5RoPd
z1eGE+fJjpbJ#