** Missing Kubernetes steps - Note taken on [2023-11-21 Tue 14:38] \\ On the new ec2 server Kubernetes (kubeadm init) was not running. The error messages indicated the following steps to fix the situation: 1. modprobe br_netfilter 2. sudo su -c 'br_netfilter' >> /etc/modules.load.d/k8s.conf 3. sudo su -c 'echo 1 > /proc/sys/net/ipv4/ip_forward' 4. cat < cat /var/jenkins_home/secrets/initialAdminPassword 14. Download CLI: curl localhost:32000/jnlpJars/jenkins-cli.jar > jenkins-cli.jar 15. yum install java-11-openjdk.x86_64 16. echo 'admin:' > /var/jenkins/.jenkins_cli 17. Status check: java -jar jenkins-cli.jar -s http://localhost:32000 -auth @/var/jenkins/.jenkins_cli version 18. Plugins, replace "PluginName" with the plugin names below, one by one. * java -jar jenkins-cli.jar -s http://localhost:32000 -auth @/var/jenkins/.jenkins_cli install-plugin "" -deploy * Plugin list: 1. dashboard-view 2. credentials 3. workflow-scm-step 4. git-client 5. git 6. workflow-basic-steps 7. pipeline-build-step 8. workflow-aggregator 9. timestamper 10. build-timeout 11. kubernetes 19. Open http://localhost:32000/configure - Manage Jenkins -> System -> Uncheck "Usage Statistics" 20. Open http://localhost:32000/configureSecurity and set "Agents:TCP port for JNLP agents" to "random" *** Setup Kubernetes Cloud 1. Open Jenkins in browser. 2. Open http://localhost:32000/manage/cloud/ -> New cloud 3. Enter Cloud name: "k8sLocal", Type: "Kubernetes" -> Create 4. Kubernetes cloud details, only fill the following details: - Kubernetes URL: 172.31.9.32:6443 (local IP of machine, run: `ip addr show`) - Kubernetes Namespace: devops-tools - Jenkins URL: 10.103.162.93:8080 (run: `kubectl get service -n devops-tools jenkins-service`) - Check "Web Socket Connection" 5. Click on "Save" 6. Click on "k8sLocal" -> Click on "Pod Templates" -> Create new 7. Pod template settings: - Name: jenkins-slave - Kubernetes URL: 172.31.9.32:6443 (local IP of machine) - Namespace: devops-tools - Labels: jenkins-slave - Usage: "Use this node as much as possible" - Containers -> "Add template" - Name: jenkins-slave - Docker image: jenkins/inbound-agent - Working directory: /home/jenkins - Command to run: /bin/sh -c - Arguments to pass to the command: cat - Service Account: jenkins-admin - Pod retention: Never - Workspace volume: Empty dir workspace *** Create project on Jenkins 1. New item -> Select "Pipeline", Name: "PipelineProject" 2. Check "Do not allow concurrent builds" 3. Build Triggers: - Poll SCM: - Schedule: "H/5 * * * *" 4. Modify pipeline.groovy to change values as needed and save the file. 5. Now copy-paste pipeline.groovy in "Pipeline Definition" section.