1 00:00:00,980 --> 00:00:05,510 In this video we're gonna start to set up a routing rules for all the other micro services inside of 2 00:00:05,510 --> 00:00:06,620 our cluster. 3 00:00:06,720 --> 00:00:11,240 I'm inside of our ingress SRB file inside of our infra K Cade's directory. 4 00:00:11,240 --> 00:00:16,670 Right now we only have a route mapping for slashed posts which means in theory we can only attempt to 5 00:00:16,700 --> 00:00:21,650 fetch or retrieve posts is that is the only thing we're doing with our post cluster IP service. 6 00:00:21,650 --> 00:00:26,030 So we need to add in some additional parts to this thing to make sure we map of all the different incoming 7 00:00:26,030 --> 00:00:27,540 requests that might come in. 8 00:00:27,800 --> 00:00:32,150 Now I went through all of our different micro services and the react application and put together a 9 00:00:32,150 --> 00:00:37,000 quick diagram to help you remember all the different routes that we need to service. 10 00:00:37,090 --> 00:00:37,390 All right. 11 00:00:37,420 --> 00:00:42,000 So in this diagram we have some number of requests coming in from our ReACT application. 12 00:00:42,010 --> 00:00:44,300 These are all the different requests we expect to receive. 13 00:00:44,890 --> 00:00:50,530 So we're going to get a post to slash post if that occurs it should go to the post pod. 14 00:00:50,530 --> 00:00:54,470 We're also gonna have a post to slash post slashed ideas slash comments. 15 00:00:54,610 --> 00:01:01,030 That request should go to the common service a get to slash post should go to query and then finally 16 00:01:01,030 --> 00:01:04,940 a get to just slashed by itself is attempting to load up the react application. 17 00:01:04,980 --> 00:01:06,960 So we need to make sure that gets sent to the reactor. 18 00:01:08,040 --> 00:01:12,190 So we need to write out all these different routing rules inside that ingress config file. 19 00:01:12,240 --> 00:01:14,660 Now I got some bad news. 20 00:01:14,760 --> 00:01:19,390 This is something that I knew about ahead of time and I wanted you to have to go through this as well 21 00:01:19,650 --> 00:01:22,820 because I've had to deal with this on a real project too. 22 00:01:22,860 --> 00:01:27,430 The bad news here is that we have two routes right now of slash posts. 23 00:01:27,600 --> 00:01:32,850 If a request comes in with a method of post then that should go to the postal service. 24 00:01:32,850 --> 00:01:35,480 Otherwise if it is a get issue go to query. 25 00:01:35,760 --> 00:01:42,300 The bad news here is that our ingress engine X module can not do routing based upon the method of the 26 00:01:42,300 --> 00:01:43,300 request. 27 00:01:43,470 --> 00:01:49,970 So all the methods I have list on here the ingress controller has no idea that these methods exist. 28 00:01:50,190 --> 00:01:56,890 So the only thing we can really root on effectively is a route early a path so for all these things 29 00:01:56,900 --> 00:02:00,430 it really goes down to just this. 30 00:02:00,550 --> 00:02:01,500 This is all we get. 31 00:02:01,500 --> 00:02:06,190 This is what we have to route based on. 32 00:02:06,320 --> 00:02:11,090 Now the reason this is bad is that now when we look at this you'll notice that if we have a request 33 00:02:11,090 --> 00:02:15,830 coming into a slash posts we're saying it should go to this post pod but there's another one down here 34 00:02:15,830 --> 00:02:19,900 that says if a request comes in to slash post it should go to the query pod. 35 00:02:20,210 --> 00:02:23,970 We can no longer differentiate on the method of the incoming request. 36 00:02:24,020 --> 00:02:28,730 So now we don't have enough information with these requests to figure out whether or not one should 37 00:02:28,730 --> 00:02:33,390 go to the post pod or query so that's the bad news here. 38 00:02:33,390 --> 00:02:38,930 To fix this we need to make sure that we have some unique path or request that should go to posts and 39 00:02:38,940 --> 00:02:41,940 a unique path for one it should go to query. 40 00:02:41,970 --> 00:02:44,910 In other words we really just need to change the name of one of these parts. 41 00:02:44,940 --> 00:02:50,550 So maybe this right here instead of being slash post it should be something like those slash create 42 00:02:50,610 --> 00:02:52,000 or something like that. 43 00:02:52,140 --> 00:02:56,160 If we put that in now we can distinguish between requests that's going to go to the post pod and the 44 00:02:56,160 --> 00:03:00,090 query pod that actually make this reality. 45 00:03:00,110 --> 00:03:05,660 Well we need to make sure that we not only update our ReACT application to make a request to slash create 46 00:03:05,960 --> 00:03:12,150 we need to make sure we also update the post pod itself so that it should expect requests to come in 47 00:03:12,150 --> 00:03:14,260 to slash post slash create. 48 00:03:14,290 --> 00:03:19,250 So in other words we need to change two different images right now just to solve this image or this 49 00:03:19,250 --> 00:03:21,230 issue that we are running into. 50 00:03:21,230 --> 00:03:25,940 Let's take care of that right now because we're going to have to edit those two code bases and then 51 00:03:25,940 --> 00:03:28,880 rebuild the images and post them back up to Docker Hub. 52 00:03:29,330 --> 00:03:32,970 So I can first get started inside of by react application. 53 00:03:33,060 --> 00:03:38,610 I'm going to find my post create file that is where we are making a post request to slash post so I'm 54 00:03:38,610 --> 00:03:45,270 gonna change that route to post slash create again so that we can differentiate between a request that 55 00:03:45,270 --> 00:03:49,050 is supposed to go to the post pod versus the query pod. 56 00:03:49,260 --> 00:03:50,150 There's the change right there. 57 00:03:50,190 --> 00:03:58,000 I can save this file then after that I'm gonna go to my post project find the next J S file inside there. 58 00:03:58,180 --> 00:04:01,910 Here's the post request handler so post flash. 59 00:04:02,110 --> 00:04:08,580 Create you will recall that we do have a getter or a get request handler for Slash post right here. 60 00:04:08,680 --> 00:04:13,000 That was in the previous initial version of our application before we implemented that query. 61 00:04:13,030 --> 00:04:16,790 So this thing is technically unused right now and we don't really care about that handler at all. 62 00:04:16,810 --> 00:04:18,520 We can actually delete it if we want to. 63 00:04:18,520 --> 00:04:23,050 I only left it in here so we could test out our post end point once we initially set up all that ingress 64 00:04:23,080 --> 00:04:25,440 engine X stuff okay. 65 00:04:25,470 --> 00:04:34,970 So I'll say this file as well and I'll go back to my terminal I'm gonna go to my client folder and I'll 66 00:04:34,970 --> 00:04:39,930 do a docker build client Dot. 67 00:04:40,010 --> 00:04:40,400 There we go. 68 00:04:41,680 --> 00:04:45,950 And a docker push. 69 00:04:45,970 --> 00:04:51,240 There we go and we're going to repeat that same process for post as well. 70 00:04:51,260 --> 00:04:55,220 Now this one time you're probably sitting there saying wait a minute Steven wait wait wait wait. 71 00:04:55,220 --> 00:05:00,200 We have to rebuild the image manually and push it up to Docker Hub every single time we make a change 72 00:05:00,200 --> 00:05:04,680 or a code Hey wait a minute that seems a really really awkward. 73 00:05:04,750 --> 00:05:06,540 I know it is really awkward. 74 00:05:06,570 --> 00:05:09,040 This is something else we're gonna fix up very quickly. 75 00:05:09,070 --> 00:05:13,630 I really just want us to have to go through this problem distinctly one more time because very quickly 76 00:05:13,630 --> 00:05:17,320 like in the next come coming videos we're gonna take a look at a tool that's going to automate all this 77 00:05:17,320 --> 00:05:20,740 change process for us and so I just want to give you a quick reminder that yeah. 78 00:05:20,790 --> 00:05:24,910 Sound right now they want to make a change to our code we have to rebuild image push it and then update 79 00:05:24,910 --> 00:05:26,350 the deployment manually. 80 00:05:26,350 --> 00:05:28,480 All very painful. 81 00:05:28,500 --> 00:05:28,700 All right. 82 00:05:28,710 --> 00:05:30,360 Well the client is all done. 83 00:05:30,360 --> 00:05:33,690 I'm going to restart that deployment. 84 00:05:33,750 --> 00:05:38,170 They'll do a cube C.T. El. 85 00:05:38,270 --> 00:05:48,470 What is it rollout restart deployment client Client dash devil. 86 00:05:48,470 --> 00:05:49,230 There we go. 87 00:05:49,460 --> 00:05:53,480 That will restart our client deployment and we're going to go through all those same steps for our postal 88 00:05:53,480 --> 00:05:54,770 service as well. 89 00:05:54,860 --> 00:06:02,920 So I will go back to post I'll do a docker Bill dash t even greater post dot. 90 00:06:03,110 --> 00:06:07,010 I'll do a docker push even greater post 91 00:06:12,220 --> 00:06:16,540 and then once this is all done we'll go ahead and restart the post deployment as well 92 00:06:21,270 --> 00:06:21,960 quick upload. 93 00:06:21,960 --> 00:06:29,070 Come on come on it this apple it always takes slightly longer than you hope I'll. 94 00:06:29,080 --> 00:06:40,180 There you go so we'll do a cube GTL rollout restart deployment those dash double OK. 95 00:06:40,210 --> 00:06:45,250 So we've now got that new version of code or posts and for the rack client. 96 00:06:45,250 --> 00:06:49,600 So now we've got unique routes that we're going to access each of our different pods. 97 00:06:49,790 --> 00:06:51,000 So now quick pause right here. 98 00:06:51,000 --> 00:06:54,730 When come back the next video we can start to actually write out the routing configuration that we need.