Question: The Nautilus development team had a meeting with the DevOps team where they discussed automating the deployment of one of their apps using Jenkins (the one in Stratos Datacenter). They want to auto deploy the new changes in case any developer pushes to the repository. Per the requirements mentioned below configure the required Jenkins job.
Click on the + button in the top left corner and select option Select port to view on Host 1, enter port 8081 and click on Display Port. You should be able to access the Jenkins login page. Login using username theadmin and Adm!n321 password.
In the same way you can access Gitea UI on port 8000; username and password for Git is sarah and Sarah_pass123 respectively. There under user sarah you will find a repository named web that is already cloned on Storage server under sarah's home. sarah is a developer who is working on this repository.
Install httpd (whatever version is available in the yum repo by default) and configure it to serve on port 3004 on All App servers. You can make it part of your Jenkins job or you can do this step manually on all app servers.
Create a Jenkins job named nautilus-app-deployment and configure it in a way that if anyone pushes any new change to the origin repository on master branch the job should auto build and deploy the latest code on Storage server under /data directory. Since /data on Storage server is a NFS mount, changes should auto reflect on all apps.
SSH into Storage Server using sarah user credentials mentioned above. Under sarah user's home you will find a cloned Git repository named web. Under this repository there is an index.html file, update its content to Welcome to the xFusionCorp Industries and then push the changes to the origin into master branch. This push must trigger your Jenkins job and the latest changes must be deployed also make sure it deploys the entire repository content not only index.html file.
LB server is already configured. Click on the + button in the top left corner and select option Select port to view on Host 1, enter port 80 and click on Display Port. You should be able to see the latest changes you made. Please make sure the required content is loading on the main URL https://<LBR-URL> i.e there should not be a sub-directory like https://<LBR-URL>/web etc.
Note:
You might need to install some plugins and restart Jenkins service. So, we recommend clicking on Restart Jenkins when installation is complete and no jobs are running on plugin installation/update page i.e update centre. Also some times Jenkins UI gets stuck when Jenkins service restarts in the back end so in such case please make sure to refresh the UI page.
Make sure Jenkins job passes even on repetitive runs as validation may try to build the job multiple times.
Deployment related tasks should be done by sudo user on the destination server to avoid any permission issues so make sure to configure your Jenkins job accordingly.
For these kind of scenarios requiring changes to be done in a web UI, please take screenshots so that you can share it with us for review in case your task is marked incomplete. You may also consider using a screen recording software such as loom.com to record and share your work.
This task is based on web UI, you can refer below Video Solution for a better understanding
Solution:
1. Click on the + button in the top left corner and select option Select port to view on Host 1, enter port 8081 and click on Display Port. You should be able to access the Jenkins login page. Login using username theadmin and Adm!n321 password.
2. Click Jenkins > Manage Jenkins > Manage Plugins and click Available tab.
Search for Gitea, Build Authorization Token Root, SSH & publish over SSH plugin and click Download now and install after restart
3. Create credentials for Sarah, tony, steve, and banner as shown below
4. Create SSH remote hosts/ssh sites under configuration for all the app servers
5. Configure Publish Over SSH for storage server
6. Create a new Build Job to httpd server on all app server
echo Ir0nM@n |
sudo -S sudo yum install -y httpd echo Ir0nM@n |
sudo -S sed -i 's/^Listen 80$/Listen 3004/g' /etc/httpd/conf/httpd.conf echo Ir0nM@n |
sudo -S systemctl restart httpd && systemctl status httpd
echo Am3ric@ |
sudo -S sudo yum install -y httpd echo Am3ric@ |
sudo -S sed -i 's/^Listen 80$/Listen 3004/g' /etc/httpd/conf/httpd.conf echo Am3ric@ |
sudo -S systemctl restart httpd && systemctl status httpd
echo BigGr33n |
sudo -S sudo yum install -y httpd echo BigGr33n |
sudo -S sed -i 's/^Listen 80$/Listen 3004/g' /etc/httpd/conf/httpd.conf echo BigGr33n |
sudo -S systemctl restart httpd && systemctl status httpd |
Note down the Jenkins URL to create a Webhook in Gitea
https://2886795296-8081-kitek06o.environments.katacoda.com/buildByToken/build?job=nautilus-app-deployment&token=KODEKLOUDENGINEER
( https://2886795296-8081-kitek06o.environments.katacoda.com will be your Jenkins browser URL )
Refer Below Video for better clarity
or
Take online support on www.nbtechsupport.co.in
10. Configure the Below settings for Build Triggers
11. Build the Job & check the Console output for successful completion
12. If you get an error in Build then log in on the storage server and check the permission of /data
thor@jump_host
/$ ssh natasha@ststor01 The authenticity
of host 'ststor01 (172.16.238.15)' can't be established. ECDSA key
fingerprint is SHA256:SySamszyWhhLGFiybhGBqfrr8g55wS/3e37ZpBOvICs. ECDSA key
fingerprint is MD5:6d:31:18:2a:f9:07:f3:29:dd:0a:d3:1f:6e:04:0a:db. Are you sure you
want to continue connecting (yes/no)? yes Warning:
Permanently added 'ststor01,172.16.238.15' (ECDSA) to the list of known
hosts. natasha@ststor01's
password: [natasha@ststor01
~]$ sudo su - We trust you have received the usual lecture from the local System Administrator.
It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great
responsibility. [sudo] password for natasha: [root@ststor01
~]# [root@ststor01
~]# ll -lsd /data 4 drwxr-xr-x 2
root root 4096 Nov 16 2020 /data [root@ststor01
~]# [root@ststor01
~]# chmod 777 /data [root@ststor01
~]# [root@ststor01
~]# ll -lsd /data 4 drwxrwxrwx 2
root root 4096 Nov 16 2020 /data [root@ststor01
~]# |
13. Rebuild the job & check the status. Should be successful
15. Add Webook in Gitea the URL which generated in Jenkins Build Triggers
16. Click the webhook & Test delivery to check the hook works.
17. Switch user to Sarah & commit the index file
[root@ststor01
~]# su - sarah Last login: Thu
Jun 17 13:04:40 UTC 2021 on pts/0 [sarah@ststor01
~]$ [sarah@ststor01
~]$ cd /home/sarah/web/ [sarah@ststor01
web]$ [sarah@ststor01
web]$ cat index.html Welcome [sarah@ststor01
web]$ [sarah@ststor01
web]$ vi index.html [sarah@ststor01 web]$ cat index.html Welcome to the xFusionCorp Industries [sarah@ststor01
web]$ [sarah@ststor01
web]$ git add index.html [sarah@ststor01
web]$ [sarah@ststor01
web]$ git commit -m "update" [master 850d0de]
update 1 file changed, 1 insertion(+), 1
deletion(-) [sarah@ststor01
web]$ [sarah@ststor01
web]$ git push origin master Counting
objects: 5, done. Writing objects:
100% (3/3), 280 bytes | 0 bytes/s, done. Total 3 (delta
0), reused 0 (delta 0) remote: .
Processing 1 references remote:
Processed 1 references in total To
http://sarah:Sarah_pass123@git.stratos.xfusioncorp.com/sarah/web.git b6b79fc..850d0de master -> master [sarah@ststor01
web]$ |
19. Click on Finish & Confirm to complete the task successfully
Happy Learning!!!!
0 Comments