1
00:00:00,005 --> 00:00:02,002
- [Instructor] With our POC implementation

2
00:00:02,002 --> 00:00:04,002
completed on dev side,

3
00:00:04,002 --> 00:00:08,003
we are all set to deploy our proof of concept to production,

4
00:00:08,003 --> 00:00:10,007
so let us take a look at what we have here.

5
00:00:10,007 --> 00:00:12,008
I have one EC2 instance

6
00:00:12,008 --> 00:00:16,009
which I have connected through remote desktop or RDB.

7
00:00:16,009 --> 00:00:20,008
Through this RDB I have installed Apache Tomcat

8
00:00:20,008 --> 00:00:24,008
and inside the folder I can go into bin

9
00:00:24,008 --> 00:00:27,000
and get this server started.

10
00:00:27,000 --> 00:00:29,008
You can see that the server is up and running.

11
00:00:29,008 --> 00:00:32,007
I can test that by going into browser

12
00:00:32,007 --> 00:00:36,001
and then getting into localhost 8080

13
00:00:36,001 --> 00:00:40,008
this webpage shows that my server is up and running.

14
00:00:40,008 --> 00:00:42,000
We should also test

15
00:00:42,000 --> 00:00:43,004
connecting to this Tomcat

16
00:00:43,004 --> 00:00:46,001
from some other machine outside the RDB

17
00:00:46,001 --> 00:00:47,003
just to make sure

18
00:00:47,003 --> 00:00:50,006
that we are able to access it from public domain.

19
00:00:50,006 --> 00:00:53,006
For that, I'll go back to my bank machine

20
00:00:53,006 --> 00:00:57,000
here you see my EC2 management console

21
00:00:57,000 --> 00:00:59,005
showing the EC2 instance

22
00:00:59,005 --> 00:01:04,000
and you can also see the public DNS, which I can copy.

23
00:01:04,000 --> 00:01:06,008
Go to my browser.

24
00:01:06,008 --> 00:01:08,009
Type in the port 8080

25
00:01:08,009 --> 00:01:10,005
and you will see once again

26
00:01:10,005 --> 00:01:13,003
the same web server up and running.

27
00:01:13,003 --> 00:01:15,000
Now to make this happen.

28
00:01:15,000 --> 00:01:19,003
Make sure that your EC2 instance has public access,

29
00:01:19,003 --> 00:01:22,000
it Security groups allow port 8080

30
00:01:22,000 --> 00:01:24,006
to be accessed through HTTP

31
00:01:24,006 --> 00:01:28,003
and optionally if needed HTTPS

32
00:01:28,003 --> 00:01:33,003
and also that EC2 firewall is not blocking port 8080.

33
00:01:33,003 --> 00:01:36,002
If it is you need to go into firewall settings

34
00:01:36,002 --> 00:01:38,009
and unblock 8080.

35
00:01:38,009 --> 00:01:41,008
Now going back to my remote desktop,

36
00:01:41,008 --> 00:01:46,005
I want to look at the configuration files for Apache Tomcat,

37
00:01:46,005 --> 00:01:48,008
which are important for our application.

38
00:01:48,008 --> 00:01:51,000
So I go into con folder.

39
00:01:51,000 --> 00:01:53,004
There are two files that we are interested in

40
00:01:53,004 --> 00:01:55,009
Tomcat users and context,

41
00:01:55,009 --> 00:01:59,003
so let's open that and in Tomcat users

42
00:01:59,003 --> 00:02:02,003
you see that I have included the deployer user

43
00:02:02,003 --> 00:02:04,004
that has managed a scriptural,

44
00:02:04,004 --> 00:02:06,007
this is the user that will use Jenkins

45
00:02:06,007 --> 00:02:08,007
to deploy the warfighter.

46
00:02:08,007 --> 00:02:10,006
Then in context XML,

47
00:02:10,006 --> 00:02:12,002
here is the resource.

48
00:02:12,002 --> 00:02:14,008
It has the data source red30db,

49
00:02:14,008 --> 00:02:16,009
that is our production database

50
00:02:16,009 --> 00:02:20,008
and you can see that it is pointing to the RDS.

51
00:02:20,008 --> 00:02:23,004
Where do I get this URL from?

52
00:02:23,004 --> 00:02:25,006
Let me go back to my dev machine.

53
00:02:25,006 --> 00:02:30,005
Now I am on my IDS management console in databases.

54
00:02:30,005 --> 00:02:32,007
Here is my production database

55
00:02:32,007 --> 00:02:34,001
and if I click there,

56
00:02:34,001 --> 00:02:36,008
I can see the URL along with the port

57
00:02:36,008 --> 00:02:38,008
where my production DB is running.

58
00:02:38,008 --> 00:02:41,001
I can connect to this database

59
00:02:41,001 --> 00:02:43,003
through my SQL workbench.

60
00:02:43,003 --> 00:02:45,007
You can see that I was connecting initially

61
00:02:45,007 --> 00:02:47,000
to my local instance,

62
00:02:47,000 --> 00:02:49,000
which was my dev server,

63
00:02:49,000 --> 00:02:51,005
and here is my production data server.

64
00:02:51,005 --> 00:02:52,008
If I click on it,

65
00:02:52,008 --> 00:02:55,000
I can get to the database

66
00:02:55,000 --> 00:02:58,003
and you can see that I am using the same four tables

67
00:02:58,003 --> 00:03:01,000
that we have been with so far.

68
00:03:01,000 --> 00:03:03,009
Now the only thing left is Jenkins,

69
00:03:03,009 --> 00:03:06,004
which is supposed to deploy the war file,

70
00:03:06,004 --> 00:03:08,000
but before we do that,

71
00:03:08,000 --> 00:03:10,005
how about let us deploy it manually

72
00:03:10,005 --> 00:03:12,002
just to see how it works

73
00:03:12,002 --> 00:03:15,006
and then deploy it later through Jenkins.

74
00:03:15,006 --> 00:03:18,003
So let me go back to eclipse

75
00:03:18,003 --> 00:03:22,009
and here on my project I say run as

76
00:03:22,009 --> 00:03:25,006
and maven build.

77
00:03:25,006 --> 00:03:29,007
Here I specify the goal as package,

78
00:03:29,007 --> 00:03:36,009
which will create the war package for me and then run.

79
00:03:36,009 --> 00:03:40,002
Now you can see that the build is successful,

80
00:03:40,002 --> 00:03:43,005
which means my war file has been created,

81
00:03:43,005 --> 00:03:46,005
which I can find in my target folder.

82
00:03:46,005 --> 00:03:53,004
I go into that folder right click show in system Explorer,

83
00:03:53,004 --> 00:03:59,000
copy the file so that I can copy it to my Tomcat server.

84
00:03:59,000 --> 00:04:03,003
Go back to my EC2 instance

85
00:04:03,003 --> 00:04:09,006
into file Explorer from Apache Tomcat go into web apps

86
00:04:09,006 --> 00:04:13,005
and paste the war file.

87
00:04:13,005 --> 00:04:14,006
As you do that,

88
00:04:14,006 --> 00:04:17,007
if you open up your Tomcat instance,

89
00:04:17,007 --> 00:04:20,002
you can see that the server could detect

90
00:04:20,002 --> 00:04:22,000
a new application war file.

91
00:04:22,000 --> 00:04:25,007
It exploded it and now is loading the data.

92
00:04:25,007 --> 00:04:26,008
This may take a while

93
00:04:26,008 --> 00:04:30,009
because it is pulling the data from Amazon cloud.

94
00:04:30,009 --> 00:04:35,000
Now you can see that the application has been uploaded.

95
00:04:35,000 --> 00:04:38,009
I go back to my browser on my local instance

96
00:04:38,009 --> 00:04:42,009
and say red30 run the POC

97
00:04:42,009 --> 00:04:46,002
and you can see that we are getting the desired result.

98
00:04:46,002 --> 00:04:49,002
I can also test this out on my dev machine.

99
00:04:49,002 --> 00:04:52,008
So let me go back there onto the browser,

100
00:04:52,008 --> 00:04:54,006
back to the page where we had

101
00:04:54,006 --> 00:04:56,009
our EC2 instance server running

102
00:04:56,009 --> 00:04:59,003
and say red30.

103
00:04:59,003 --> 00:05:03,003
Once again, POC and we see the desired result again.

104
00:05:03,003 --> 00:05:07,005
Now we need to do this entire cycle using Jenkins

105
00:05:07,005 --> 00:05:10,001
for that let me go back to eclipse

106
00:05:10,001 --> 00:05:11,006
and make a small change

107
00:05:11,006 --> 00:05:16,004
so that you can see the change going back to production.

108
00:05:16,004 --> 00:05:20,001
So let me open up the airbag folder inside

109
00:05:20,001 --> 00:05:22,005
which I have POC results

110
00:05:22,005 --> 00:05:24,005
and here I'll make a tiny change.

111
00:05:24,005 --> 00:05:30,002
I'll say, wow, I found save this.

112
00:05:30,002 --> 00:05:32,004
Now I'll go into get staging.

113
00:05:32,004 --> 00:05:34,002
You can see that all the files

114
00:05:34,002 --> 00:05:35,005
that we have been working on

115
00:05:35,005 --> 00:05:38,007
are showing up as onstage changes.

116
00:05:38,007 --> 00:05:43,004
I will stage them and then push them to get.

117
00:05:43,004 --> 00:05:45,007
So here I will put in my lesson number

118
00:05:45,007 --> 00:05:51,004
which is 02-07e

119
00:05:51,004 --> 00:05:56,004
and we can say POC completed as the comment,

120
00:05:56,004 --> 00:06:00,006
comment and push, here you see that it is

121
00:06:00,006 --> 00:06:05,003
pushing you to the master now to Jenkins.

122
00:06:05,003 --> 00:06:10,005
Now in Jenkins I have created a deploy red30 project

123
00:06:10,005 --> 00:06:12,006
as a freestyle project.

124
00:06:12,006 --> 00:06:14,006
If I go inside the project,

125
00:06:14,006 --> 00:06:17,004
I can see its configuration settings.

126
00:06:17,004 --> 00:06:20,000
Starting from here with a general description

127
00:06:20,000 --> 00:06:21,008
and source code management,

128
00:06:21,008 --> 00:06:23,008
it is pointing to my good report

129
00:06:23,008 --> 00:06:26,005
with the credentials in build.

130
00:06:26,005 --> 00:06:28,008
I have the Maven plugin

131
00:06:28,008 --> 00:06:31,005
and I'm giving the goal of clean package

132
00:06:31,005 --> 00:06:33,002
to create a war file,

133
00:06:33,002 --> 00:06:37,009
which will be deployed in the context red30

134
00:06:37,009 --> 00:06:40,005
add the URL specified here,

135
00:06:40,005 --> 00:06:43,004
which requires these credentials.

136
00:06:43,004 --> 00:06:48,006
So let me save this setting and go into build now.

137
00:06:48,006 --> 00:06:50,002
This takes a while because it has

138
00:06:50,002 --> 00:06:53,008
to pull all the code from get creative or file,

139
00:06:53,008 --> 00:06:57,003
and then deploy it on Amazon server.

140
00:06:57,003 --> 00:07:00,008
Excellent we see that our build has been successful,

141
00:07:00,008 --> 00:07:06,003
so I can go back to my URL and simply refresh,

142
00:07:06,003 --> 00:07:08,003
and you can see that the change is showing up

143
00:07:08,003 --> 00:07:10,001
on the production site.

144
00:07:10,001 --> 00:07:12,006
Now our dev ops pipeline is running

145
00:07:12,006 --> 00:07:16,000
and we can start delivering our product increments.

