forked from nagenn/SimplilearnAssist
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMaster-Slave on AWSEC2
69 lines (61 loc) · 2.22 KB
/
Master-Slave on AWSEC2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Video of the steps at : vimeo.com/485164578
Log in to AWS Console
Search for EC2
Setting up Jenkins Master
-------------------------
Create new instance
- in security group, choose all & any for inbound connections
download new keypair and change its permissions chmod 400 JenkTest.pem
Connect via ssh:
- ssh -i "JenkTest.pem" ubuntu@ec2-54-91-219-70.compute-1.amazonaws.com
Once connected to EC2 via SSH
sudo apt-get update
sudo apt install openjdk-8-jre (install Java)
Steps to install Jenkins https://pkg.jenkins.io/debian-stable/
sudo service jenkins start
<externalipofec2instance>:8080
Set up Jenkins
Setting up Slave
-------------------------
Create new instance
- in security group, choose all & any for inbound connections
use same key pair as before
Connect via ssh:
- ssh -i "JenkTest.pem" ubuntu@ec2-54-81-212-70.compute-1.amazonaws.com
Once connected to EC2 via SSH
- sudo apt-get update
- sudo apt install openjdk-8-jre (install Java)
- create a ssh key using ssh-keygen -t rsa -N "" -f /home/ubuntu/.ssh/id_rsa
- cd .ssh
- cat id_rsa.pub > authorized_keys
- chmod 700 authorized_keys
- run cat id_rsa -> copy output in a plain text editor
In Jenkins-Master
On Master Node
- mkdir -p /var/lib/jenkins/.ssh
- cd /var/lib/jenkins/.ssh
- sudo touch known_hosts
- vi known_hosts
- ssh-keyscan -H <PVT-IP-OF-SLAVENODE>
- copy output of above command and past it into vi (where you have opened known_hosts). Save and close
- sudo chown jenkins:jenkins known_hosts
- sudo chmod 700 known_hosts
in Jenkins: Manage Jenkins-Nodes & Cloud -New Node
- give it a name
- Choose permanent
- give a description
- remote root dir: /home/ubuntu
- give a label
- launch method - USe SSH
- Host - Slave node's private IP
- Credentials: Add Jenkins Credential
- Kind: SSH Username & private key
- user: ubuntu
- private key: select enter directly
- copy & paste output from line 35 here
- click on add
- now you can select this newly added credential back in the previous screen
- save
- click on node and make sure it is running
on master create a freestyle job and choose "restrict where this project can be run" and enter slave node name
build now