1 00:00:01,070 --> 00:00:04,750 We've now got some code put together to publish an event to our net streaming server. 2 00:00:04,850 --> 00:00:11,750 But if we go back over to our terminal inside of our nets test directory and run NPM run publish we'll 3 00:00:11,750 --> 00:00:15,270 see a nasty error saying that we cannot connect to the Napster server. 4 00:00:15,290 --> 00:00:16,760 So how are we going to fix this. 5 00:00:16,760 --> 00:00:21,770 Well the whole issue here is that we are trying to run our program right now and access some program 6 00:00:21,800 --> 00:00:26,330 that's running inside of a pod inside of our cluster to access something inside the cluster. 7 00:00:26,330 --> 00:00:31,940 There are a couple of different options available to us so we can use a very classic option that we 8 00:00:31,940 --> 00:00:34,090 are now very much familiar with. 9 00:00:34,190 --> 00:00:35,170 Option number one. 10 00:00:35,360 --> 00:00:36,590 Here's our Nats pod. 11 00:00:36,590 --> 00:00:42,380 We created a cluster IP service to govern access to that pod so we can very easily go into our ingress 12 00:00:42,380 --> 00:00:45,950 engine exe file and add in some routes inside there. 13 00:00:46,030 --> 00:00:50,920 That's going to expose the cluster IP service to the outside world so that we could tell our publisher 14 00:00:50,920 --> 00:00:54,580 program to just communicate directly with ingress engine X.. 15 00:00:54,820 --> 00:00:56,020 So this is option number one. 16 00:00:56,050 --> 00:00:58,000 And we could definitely make this work. 17 00:00:58,090 --> 00:01:02,680 However there's something kind of interesting about this test program that I want to put together. 18 00:01:02,890 --> 00:01:07,810 One of the very key things I want to show you is what happens if our publisher program or the listener 19 00:01:07,810 --> 00:01:12,970 program suddenly loses its connection with that Nats streaming server pod. 20 00:01:12,970 --> 00:01:18,280 So I want to very easily be able to essentially break that link and then very quickly toggle it back 21 00:01:18,280 --> 00:01:22,100 on without a lot of complicated commands or anything like that. 22 00:01:22,120 --> 00:01:24,030 So even though option number one would definitely work. 23 00:01:24,190 --> 00:01:26,800 It's a little bit too heavy weight for what we're trying to do right now. 24 00:01:28,540 --> 00:01:34,780 So option number two we could create a node port service to expose the Nats pod directly to the outside 25 00:01:34,780 --> 00:01:38,410 world or whatever is running outside of our Cuban that is cluster. 26 00:01:38,410 --> 00:01:42,010 So this would definitely work as well and we could definitely probably figure out how to easily write 27 00:01:42,040 --> 00:01:46,840 a command to very quickly delete that service that we could simulate breaking that connection and then 28 00:01:46,870 --> 00:01:48,880 repairing it very quickly. 29 00:01:48,880 --> 00:01:51,960 However this would still require us to write out a config file. 30 00:01:52,150 --> 00:01:52,830 That's OK. 31 00:01:52,840 --> 00:01:58,660 But right now we're just making a very small little test program and again creating a config file just 32 00:01:58,660 --> 00:01:59,810 a little bit heavyweight. 33 00:01:59,950 --> 00:02:04,570 So there actually is option number three to get access to running or something or running inside of 34 00:02:04,580 --> 00:02:10,130 a pod inside of our cluster very easily inside of a strictly development setting. 35 00:02:10,190 --> 00:02:16,710 So here's what we can do we can run a command at our terminal that tells our Cuban is cluster to port 36 00:02:16,710 --> 00:02:22,670 forward a port off of a very specific pod inside of our cluster when we use this port forwarding thing 37 00:02:22,830 --> 00:02:28,260 that's going to cause our cluster to essentially behave as though it has a node port service running 38 00:02:28,260 --> 00:02:28,990 inside of it. 39 00:02:29,130 --> 00:02:33,960 It's going to expose this pod or a very specific port on it to the outside world and allow us to connect 40 00:02:33,960 --> 00:02:36,620 to it directly from our local machine. 41 00:02:36,630 --> 00:02:42,390 So this is what we're going to do to get access to that and that's streaming server pod let me show 42 00:02:42,390 --> 00:02:48,170 you how to set up this port forwarding thing we're going to first go back to our terminal I'm going 43 00:02:48,180 --> 00:02:54,170 to close the NPM run publish by adding controls see I'm then going to get a list of all my different 44 00:02:54,170 --> 00:03:00,510 running pods with cubes GTL get pods I'll find the name of the pod that is running in mine that's streaming 45 00:03:00,510 --> 00:03:08,480 server I'm going to copy the name and then I will run cube GTL or it forward then the name of the pod 46 00:03:09,730 --> 00:03:15,550 and then the ports that I want to set up port forwarding to the first number right here is the ports 47 00:03:15,580 --> 00:03:20,950 on my local machine that I want to yield to access to get at this pod the second number is gonna be 48 00:03:20,950 --> 00:03:26,410 the port on the pod that I'm trying to actually access in this case we're going to just say connect 49 00:03:26,410 --> 00:03:34,760 directly through 4 2 2 to 4 2 2 so I gonna run that and we'll see a little prompt right here saying 50 00:03:34,790 --> 00:03:43,670 okay we are forwarding all traffic from local host port 4 2 2 2 2 4 2 2 2 on that actual pod sound we 51 00:03:43,670 --> 00:03:50,020 should be able to go back over to another terminal I said back over really we want to open another terminal 52 00:03:50,020 --> 00:03:56,130 window we want you to leave this thing running so I can open another terminal window and we will run 53 00:03:56,400 --> 00:04:04,040 NPM run publish in here and now we should see publisher connected to Nats OK. 54 00:04:04,070 --> 00:04:09,350 So this port forwarding command is not just restricted to using Nats or something like that we can use 55 00:04:09,350 --> 00:04:13,610 this for any different pod any kind of thing we create that we want to connect directly to if it is 56 00:04:13,610 --> 00:04:16,070 a very temporary little connection. 57 00:04:16,370 --> 00:04:20,630 The nice thing about using port forward is that as I mentioned we want to build to break the connection 58 00:04:20,630 --> 00:04:26,090 here very easily to do so all we have to do is stop that process running these port forward command 59 00:04:27,020 --> 00:04:28,110 we're not gonna do that just yet. 60 00:04:28,160 --> 00:04:31,140 I'll show you what happens we do it all a bit later on. 61 00:04:31,310 --> 00:04:35,260 So we are now connected between our publisher program and the Nats board. 62 00:04:35,300 --> 00:04:39,500 So another quick pause right here and we'll continue adding in some code to our publisher in the next 63 00:04:39,500 --> 00:04:39,860 video.