-
Notifications
You must be signed in to change notification settings - Fork 8
/
CI-CD-Automation
661 lines (411 loc) · 12.7 KB
/
CI-CD-Automation
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
smoke tests--QA tests---->
CI--- test cases (unit test cases) will be run--->package
CI-----grouping the code of --->make a package--->delivery---->deployment---
CD--delivery----package ready---stored at one location----artifactory
source code repository----github---integration---build --->package(zip/tar/tar/gz/tgz/war/ear/jar/msi/rpm...etc)
packages stored at one location--->artifactory(delivery storage location)----ready for delivery-----?deployment---
cD
Agile--->quick possible solutions
==============================
Scrum calls----scrum master---->
Sprint call meeting--->release--->2 weeks---->jira tickets---->how many days / time
ITIL--->
jira---2 weeks--->
website---static pages
1 page---->local system---->Dev environemnt--- basic functionality
2 page---->local system---->Dev environemnt--- basic functionality
CI tool -- Jenkins
Developers------------>Source Code Repository------------>pacakge------------>artifactory------------->deployment---->linux
what is CI ?
what is CD ?
production
CD---deployment---
20 - ppl
50----------github--------integration
50---------github------------integration
50---------github------------integration----zip-----app.zip------deployment---apache
developer----->html/php----->source code---->package---->zip
Github----project--mystaticcode--100 pages
dev-1---30 pages---unit cases----------mystaticcode---100 pages--->integration( test cases)--->package--->
dev-2--30 pages------unit--------mystaticcode
dev-3---40 pages------unit-------mystaticcode
junit test cases
QA testing
mystaticcode
===========
Dev-- 2 ec2-- apaache--docuemntroot--->tester/devlopment----functionality---
pre-prod---2 ec2 machines----->documentroot --->tester(perfromace testing)---->relase
Prod----4 ec2 machines---apache --Docuemntroot---->end user
======================================================================
Date:29/1/18
keywords:splunk/ssh login
/opt/acces_log
grep -w "500" /opt/access_log
awk '{print $7}' /opt/access_log | grep -w 500 | wc -l
source="access.log" host="sample3" index="sample3" sourcetype="access_combined_wcookie"
alert ---
dashboards(1=h/1d/1week)
=========================
crontab
pushing---------->github--------------job----------------success/failure--->
/opt/sf/system/xxxxxxx
SplunkForwarder---->output.conf
splunkmaster=ip
input.conf
source=/var/log/httpd/access_log
source=/opt/tomcat/logs/catalina.outbound
index="newserver"
lab:--- forwarding my apps logs into splunk----
=========================================================================
iis - windows servers
webservers
nginx
apache
ihs
ohs
jws
===============================================================
2 ls -ltr
3 vi authorized_keys
4 ls -ltr
5 exit
6 cd .ssh/
7 ls -ltr
8 ls -l authorized_keys
9 chmod 400 authorized_keys
10 exit
11 tail -50 /var/log/secure
12 sudo tail -50 /var/log/secure
13 history
[awsadmin@ip-172-31-67-11 ~]$ exit
logout
Connection to server1 closed.
[awsadmin@ip-172-31-69-2 .ssh]$ history
1 exit
2 ssh server1
3 ls -ltra .ssh/
4 cd .ssh/
5 cat authorized_keys
6 ls -ltr
7 ssh-keygen
8 ls -ltr
9 cat id_rsa.pub
10 ssh server1
11 history
ssh-copyid ---->
===========================================
jenkins(id_rsa.pub)
15 servers---->
useradd awsadmin
/home/awsadmin/.ssh/authrized_keys
=============================================
/var/log/secure
===================================================================
aws infra----console
aws infra-aws cli-----commands/cloudformation(json/cf)
aws infra---software-- software defined network / software defined computing/
Infra mgmt tools---->IAAC--->infra as a code--->provison= creating
resource/service--->ec2, security group
pem
access key and secret key---->pgmtic authenticationr
authorization--->IAM---role
IAAC---->AWS-- Cloudformation- aws
packer----->binary--->extract
spinnaker--Gui tool--CICD- Infra
teraform---->binary--->extact
ec2 instace--->yum --->httpd---ami
ec2 template--->requred s/w--------->ami--- base ami
client--->dns name--->alb end point url----->webserver----->mysql
alb---->target group---->instances
===============================================================================================
a/c--a-ec2---a.pem----user=awsadmin
ssh awsadmin@server
unable to connect ip ?
ping --------
allow ping packet
a/c--b-ec2---b.pem-----
/etc/hosts--->a pvt
user:awsadmin
ssh --->a-ec2-ec2-user----->jump----->b----->exit--->a-ec2-ec2-user-----whoami------su - awsadmin-->awsadmin
a----> ssh awsadmin@priavate-----?
ssh -i b.pem b-ec2-pubip
a/c---mumbai
a/c---virginia
100 accounts---->
internet-------->vpn------company------->network -------->aws(100)
Blue/Green deployment
dev---->source code repo---->zip---->
Green- create -2 instances--/var/www/html/index.php image.php-- Success
Blue- destroy--2 instances
aws environment-2 servers
2--index.php,image.php
dev---->push---->github(save)---------------->automatillcay---BLue/green deployment--->
======================================================================================
===================================================
s3 security topics
elb----->apache---->Tomcat
i am role
and only bucket policy
jenkins installation ways ( free or enterprise(cloudbees)---war
jenkins.jar
yum installation
rpm
ansbile installation
find
webserver---tomcat-webapps--jenkins
tomcat1
tomcat2
to configure extra repository= enable EPEL
yum----------------->/etc/yum.repos.d/*.repo(baseurl)
systemctl start jenkins
IamRole
qa-petclinic-app-----ec2--------->qa-petclinic-app1----->custompolicy(inline)
perf-petclinic-app----------->perf-petclinic-app1
pre-prod-petclinic-app-------->pre-prod-petclinic-app1
prod-prod-petclinic-app------->prod-petclinic-app1
Bucket polices and IamRoles--->
/opt/tomcat_latest
bin/startup.sh and shtdown.sh and setenv.sh(environment variable JAVA_HOME along with heap arguments, out of memory)
webapps(shoppingcart.war)
logs--catalina.out
conf---server.xml,context.xml(jdbc) (http=8080,ajp=8009, https=8443,suhtdown=8005)
lib(*.jar, servelet-api.jar , jasper.jar)
work---->
temp
a.java---->a.class--->execute
a.jsp--->a.java--->a.class
timely build/daily build
eclipse--->total code--->github--->build---->shopping.war
jenkins--->build--->shoppingcart.war -->nexus--->qal
qal
pre-prod
perf
prod
8005
8080
8009
8443--https--ssl
server.xml
<server>
<shutdown>
lister
<service>
connector--http=8080
connector---ajp--8009
connector--https--8443---commented
<Host name="localhost" appBase="/opt/apps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />------->LogFormat---
tomcat-1
8080
8005
8009
tomcat2
8180
8105
8109
/home/awsadmin/.jenkins/workspace/buildjob/webapp/target/webapp.war
mvn package
myapp=/home/awsadmin/.jenkins/workspace/buildjob/webapp/target/webapp.war
scp $myapp server1:/opt/tomcat_latest/webapps
scp $myapp server1:/opt/tomcat_latest2/webapps
run each manuall
build job
deployment
restart job
==================
build job--->poll scm--->* * * * *
postbuild--->deployment--->
===================================================
/opt/tomcat/bin/
QA---rds-www.petlinic-qa.com-endpoint url--6 ec2
perf-15--------------------www.petlinic-perf.com---300%----->performance testing--->virutal users--->jmeter
prod-15-----100%----500%----www.petlinic.com
environment plan==
shopping.war
QA-6
PERF-18
Prod-18
jenkins
1ec2(resouces ram/cpu/)--->all your apps build/deployent/stop/start/automation jobs
slaves-ec2
slaves-ec2
git conflicts
petclinic.war
dev(git client)cmd/eclipse/IDE------------------------------>github(central repo)--->
petclinic.war(local workspace)
pull/clone the code into your local system
git client--->
git clone githuburl
git status
vi data-access.properties--->jdbcurl=rds end point url
git add (local repo)
git commit -a (local repo)
git push branchname/url/---------------------------------------->rds url
dev-1---a.java(12)----------------------------->github(a.java)12
devops admin(data-access.properties)(a.java)-10---------->github
git pull --->
git push--->
master--->petclinic(raw)--latest bugs fixed/enahancement
masterbackup---intial code
architect
dev-release-1-petclinic-------------enahancement(bugs fixing/additional components)------->developer-->local system--->
github---->jenkins---build job(package)------------>nexus------------>url-->petlinc.war ----jenkins---->deployment
QA--->test -- code reviews/code coverage report/static code coverage tools/Junit test cases(jenkins)
PERF-->
Prod(no issues)
git checkout branchname
dev-release-20183103---master----10--------------->enahncement--->
================================================================================================
github--->petlinic--->release-1-----------nexus->release1.war--->http://<url>/release1.war
jenkins---build with parameters---
choice parameters---
string parameters---
extended choice plugin
dynamic choice parameter---------->groovy script-->
===========================================================
RAM--4gb
unix---30mb--30 commands-----dockerfile---
linux-50--20-----2gb----kernel--tomcat
aix-50--20--kernel
linux --kernal--
empty bowl----own service(tomcat/apache/jboss)-----docker--no kernel
Apache
===========
installation
logs files
deployment
ssl--https
main configuration file---how to customize
lamp
troubleshoot
Tomcat
=============
pre-req installation
installation
logs files
deployment
db connectivity--mysql
jdbc
WAR----
troubleshoot
10--servers----single system
server.xml----appBase="/opt/sharedapps" ----
cd /opt/tomcat1/
rm -rf webapps
ln -s /opt/sharedapp/ webapps
cd /opt/tomcat2/
rm -rf webapps
ln -s /opt/sharedapp/ webapps
cd /opt/tomcat3/
rm -rf webapps
ln -s /opt/sharedapp/ webapps
/opt/sharedapp/shoppingcart.war
JBoss
=============
pre-req installation
installation
logs files
deployment
db connectivity--mysql
jdbc
WAR/EAR----
troubleshoot
Clustering
NiceGUi
//comments
System.out.println("");
=================================================
343 git init
344 git pull https://github.com/gangireddydanam/CounterApp.git
345 git status
346 pwd
347 git add *
348 git commit -m "first"
349 git push https://github.com/gangireddydanam/CounterApp.git
350 git push --set-upstream https://github.com/gangireddydanam/CounterApp.git master
351 git status
352 history
adding nodes/slaves
source code installation
ssl
changing hostname
4 tomcat
https://gist.github.com/diegopacheco/56a0fd87626406337caea0ff15f49850
a----
b---/var/log/secure
=======================================================
Date:19/02/2019
debug aws------>
ansible setup
ssl
scratch installation
monitoring tools---nagios,wavefront,newrelic,appD,thousandeyes,CloudWatch(basic and detail)--metrics---event/alarm--
disc/fs alert
url
cpu
server reachable not
log monitoring
ssl
process
ram usage/swap usage
performance(deep dive)
db side
sla- p1-4hrs--->sla--->in prog/work in prog--SLA breach
p2-24 hours
p3- 3 days
p4- 1 week
agent--->db agent, app agent, OS agent,,,etc
thresolds
agent--->master--->notification-->ticketing---->email + slack notifcation
alb logging/elb logging
two types of tickets----
planned tickets(SR/CR)----jirs/snow/bmc ready
un-planned tickets(issues)---customer/monitoring tool)---priority
===============================================================================
Souce Code installation
IIS--->
apache--->source code
---->source code--->tgz-->extract
check os&process --->./configure --prefix=/opt/apache -----
compile-->make
execution -->make install
apache--apr , apr-uitl,pcre,
=========================================================================================
nagios scratch
CustomLog "/var/log/accesslog" common
https://www.tecmint.com/install-nagios-in-linux/
yum install -y httpd httpd-tools php gcc glibc glibc-common gd gd-devel make net-snmp
runlevels
0 -6
init 0
init 1- single user mode
init 2 - multi- no n/w--
init -3 -mult + n/w
init 4- none
init 5 - mult + network+ gui
init 6-reboot
chkconfig
1000 user-->ldap------------------->nagios
Windows AD--->
http://54.160.3.203/nagios--->
apache--->httpd.conf--->DocumentRoot-->htdocs/nagios/
awsadmin----->12345-------------------->/etc/passwd------------>/etc/shadow
1000 users--->
uid(ldap)----->linux(ldap client)-------------awsadmin
email/pwd
SAP--->
ldap portal(some one)--->ldap id --->emp/bprasad--->90--->
linux
windows
some one--->
admin/passwd--->first time login----->jenkins db(local os)
ldap
jenkins--->os--->user-->
linux(os)(ldap client)---->jenkins(ldap)
user--->
pbm matrix-->
systemconfiguration--->ldap---->url,bind user,passw