1 00:00:00,860 --> 00:00:05,700 In the last video we laid out the solution we're going to use to address this big USL problem. 2 00:00:05,810 --> 00:00:10,100 So if our code is running inside the browser what's going to let everything behave as it's currently 3 00:00:10,100 --> 00:00:10,980 working. 4 00:00:11,000 --> 00:00:14,990 We really only have to be concerned about the case in which we're trying to run some code inside this 5 00:00:14,990 --> 00:00:20,180 Next j ust application when we need to reach out to some other service and fetch some data. 6 00:00:20,180 --> 00:00:25,520 So we eventually decided to go with option number one whenever we need to fetch some data while we are 7 00:00:25,520 --> 00:00:31,030 doing some server side rendering we need to somehow reach out to ingress and 10x and allow ingress engine 8 00:00:31,030 --> 00:00:32,930 X to route off this request. 9 00:00:32,930 --> 00:00:37,950 The only issue was how do we actually make a request to ingress engine x. 10 00:00:38,300 --> 00:00:42,440 We can access ingress engine X on our local machine and the words inside of our browser. 11 00:00:42,560 --> 00:00:47,170 By navigating to a local host port 80 that's how we get to ingress engine x. 12 00:00:47,210 --> 00:00:51,740 If I were to open up my browser right now we're trying to make this request from a totally different 13 00:00:51,740 --> 00:00:52,550 environment. 14 00:00:52,580 --> 00:00:58,650 We're trying to make the request from inside of this next J.S. pod or the client pod if we tried to 15 00:00:58,650 --> 00:01:04,400 access local host inside this pod then we're going to access local hosts inside the pod or snoozing 16 00:01:04,410 --> 00:01:06,680 inside the container itself. 17 00:01:06,780 --> 00:01:10,380 That's what's happening right now and that's what's resulting in the nasty air that we're currently 18 00:01:10,380 --> 00:01:11,430 getting. 19 00:01:11,460 --> 00:01:17,200 So we want to instead figure out how we can tell the pod to reach out directly to ingress engine X.. 20 00:01:17,280 --> 00:01:19,590 So in short what do we type right there. 21 00:01:19,590 --> 00:01:20,850 What is our domain. 22 00:01:20,850 --> 00:01:25,980 What do we have to type in to get this entire system routing requests over to ingress engine x. 23 00:01:26,070 --> 00:01:30,610 So that's the big question we're going to try to solve in this video. 24 00:01:30,720 --> 00:01:33,510 So I want to give you first a very quick reminder. 25 00:01:33,510 --> 00:01:38,400 Whenever we have two pods that need to communicate with each other in a synchronized fashion we can 26 00:01:38,400 --> 00:01:41,140 do so by using those cluster IP services. 27 00:01:41,160 --> 00:01:47,190 So for example if we wanted our client to reach out directly to that pod we would write out the name 28 00:01:47,430 --> 00:01:54,130 of the cluster I.P. service so it would be something like a GDP off dash SRB now. 29 00:01:54,160 --> 00:02:00,880 Unfortunately this rule right here only works when these services are referring or assuming when we're 30 00:02:00,880 --> 00:02:05,220 trying to access a service that is inside in the same namespace. 31 00:02:05,260 --> 00:02:07,440 So what is a namespace. 32 00:02:07,450 --> 00:02:11,440 Well a namespace is something it exists in the world of Cuban entities all the different objects we 33 00:02:11,440 --> 00:02:14,710 create are created under a specific namespace. 34 00:02:14,740 --> 00:02:18,070 You can think of a namespace as being like a sandbox of sorts. 35 00:02:18,070 --> 00:02:21,260 We use name spaces for organizing different objects. 36 00:02:21,280 --> 00:02:25,060 Right now we've been working under a namespace called default. 37 00:02:25,150 --> 00:02:32,690 So if we go back over to our terminal and do a cube Seitel get namespace we'll print out all the different 38 00:02:32,690 --> 00:02:35,930 name spaces that currently exist inside of our communities cluster. 39 00:02:35,930 --> 00:02:36,290 You'll see. 40 00:02:36,290 --> 00:02:37,720 Default is listed right there. 41 00:02:37,820 --> 00:02:40,870 And again that's where all the objects we have been creating get created. 42 00:02:41,760 --> 00:02:47,430 There's another namespace called Ingress engine X and that's where all of our ingress engine next related 43 00:02:47,430 --> 00:02:48,860 stuff works. 44 00:02:48,870 --> 00:02:54,270 Now unfortunately we can not use this style of communication to reach out to a service that exists inside 45 00:02:54,300 --> 00:02:56,010 of another namespace. 46 00:02:56,010 --> 00:03:01,620 So in short we really can't use this very short form right here to reach out to ingress engine X directly. 47 00:03:01,620 --> 00:03:07,500 We can not just put in something like ingress engine X dash SRB. 48 00:03:07,830 --> 00:03:11,720 Unfortunately the domain we have to type out is a little bit more complicated. 49 00:03:11,730 --> 00:03:18,580 Let's take a look how we would get our client to communicate directly over to the ingress engine x service. 50 00:03:18,890 --> 00:03:24,620 So if we want to do some cross namespace communication to a service created in a different namespace 51 00:03:24,920 --> 00:03:29,350 we're still going to type out a domain but the domain is gonna be a little bit more complicated. 52 00:03:29,750 --> 00:03:40,160 The domain that we're gonna type out will be the name of service then a dot then the namespace then 53 00:03:40,250 --> 00:03:43,870 SBC dot cluster dot local. 54 00:03:43,930 --> 00:03:45,810 Let me give you a more practical example. 55 00:03:45,820 --> 00:03:48,130 So we can really understand what's going on there. 56 00:03:48,140 --> 00:03:50,920 The first we need to understand is what is the name of the namespace. 57 00:03:50,920 --> 00:03:52,400 We are trying to reach into. 58 00:03:52,590 --> 00:03:57,880 So in this case the name is ingress engine X then the second question is what is the name of the service 59 00:03:57,940 --> 00:04:00,190 inside there that we're trying to access. 60 00:04:00,200 --> 00:04:05,440 Well to figure out what that is we need to list out all the services that exist inside that namespace. 61 00:04:05,440 --> 00:04:08,590 Right now when we type out cutesy tail get services. 62 00:04:08,590 --> 00:04:11,850 This is only listing services from the default namespace. 63 00:04:11,890 --> 00:04:15,770 There are technically other services that exist in these other name spaces. 64 00:04:15,880 --> 00:04:20,470 So if you want to figure out what services exist inside of ingress and connects we have to customize 65 00:04:20,470 --> 00:04:25,990 the get services command and tell it to fetch services from inside of ingress and connect namespace. 66 00:04:26,050 --> 00:04:32,560 So you do that by writing cubes detail get services dash n and in the name of the namespace which in 67 00:04:32,560 --> 00:04:34,870 this case is ingress and connects 68 00:04:38,500 --> 00:04:41,570 I'll run that and there's the name of our service. 69 00:04:41,620 --> 00:04:46,090 That's the name of the service inside of this namespace that we're trying to reach out to. 70 00:04:46,110 --> 00:04:48,050 It's simply ingress engine. 71 00:04:48,330 --> 00:04:54,660 So in total to reach to the southern namespace and access the ingress engine x service inside there 72 00:04:55,080 --> 00:05:00,040 we would write out and let me do myself a little bit of space here as you can see as very easily. 73 00:05:00,040 --> 00:05:08,450 We would write out a TTP Poland slash slash the name of the service which is ingress dash engine X then 74 00:05:08,450 --> 00:05:17,490 a dot to the name of the namespace ingress engine X and then SBC bluster not local and that's it. 75 00:05:17,520 --> 00:05:23,070 That's how we reach from our client across the namespace over to this other one and access the service 76 00:05:23,100 --> 00:05:31,320 inside their so whenever we want to follow request option number one right here and somehow make a request 77 00:05:31,350 --> 00:05:37,250 over to the current user service without having to worry about reaching over to all service directly. 78 00:05:37,380 --> 00:05:41,490 We would make our request to zoom in on this in just a moment. 79 00:05:41,730 --> 00:05:55,170 Ingress engine X dot ingress engine X SBC bluster local and I will zoom in let's I would do it. 80 00:05:55,180 --> 00:05:58,030 And we just need to make sure that we pass along the cookie as well. 81 00:06:01,450 --> 00:06:01,720 All right. 82 00:06:01,880 --> 00:06:04,340 So that's how we're going to communicate across name spaces. 83 00:06:04,340 --> 00:06:09,740 Now very quickly having to memorize this kind of syntax right here kind of gets nasty really quickly. 84 00:06:09,740 --> 00:06:15,590 So there actually is a solution to this that will allow us to make a very similar looking request to 85 00:06:15,590 --> 00:06:16,310 this one right here. 86 00:06:16,310 --> 00:06:22,160 So a very simple kind of just ingress dash engine X dash SRB if we wanted to be able to make a request 87 00:06:22,160 --> 00:06:28,190 to something like this we can create something that's called an external name service so an external 88 00:06:28,190 --> 00:06:31,830 named service essentially just remapped the domain of a request. 89 00:06:31,970 --> 00:06:38,740 We can set up a external named service that will map requests from say ingress dash engine X dash SRB 90 00:06:39,140 --> 00:06:42,570 to this more complicated domain like the one you see right there. 91 00:06:42,650 --> 00:06:47,060 So if we did something like this we would not have to memorize this crazy syntax we would just follow 92 00:06:47,060 --> 00:06:50,700 that kind of short form that we are somewhat already used to. 93 00:06:50,750 --> 00:06:52,360 This is not at all necessary. 94 00:06:52,400 --> 00:06:56,340 It's just a nice to have thing it's just something that makes it a little bit easier to remember. 95 00:06:56,460 --> 00:07:01,170 Hey here's the url or here's a very short URL that I can make my request to. 96 00:07:01,310 --> 00:07:06,010 We are not going to create the external named service just because as you come back and references code 97 00:07:06,010 --> 00:07:11,530 in the future this really is a pretty big layer of indirection and I just do not want you chapter remember 98 00:07:11,530 --> 00:07:11,800 that. 99 00:07:11,800 --> 00:07:16,040 Oh yeah we created that external named service that's going to map this thing off. 100 00:07:16,120 --> 00:07:18,780 That's just an extra thing to remember in the future. 101 00:07:18,790 --> 00:07:21,940 So we are not going to go down this route but again it is an option. 102 00:07:21,940 --> 00:07:24,980 It is something you could do if you did not want to memorize that longer. 103 00:07:25,000 --> 00:07:28,760 Euro Oh all right. 104 00:07:28,760 --> 00:07:32,090 As I've said many times yeah this stuff is pretty crazy. 105 00:07:32,210 --> 00:07:35,570 That's why micro services are hard and that's why you get paid the big bucks. 106 00:07:35,570 --> 00:07:37,180 Once you start to learn this stuff. 107 00:07:37,370 --> 00:07:40,750 Now that we've got a good idea or these some idea of what's going on here. 108 00:07:40,790 --> 00:07:42,960 I think that's pretty much it for the lecturer in the theory. 109 00:07:42,980 --> 00:07:45,140 So we're gonna start to implement all the stuff in the next video.