1 00:00:02,630 --> 00:00:05,749 ‫Based on when you watch this video, there's going to be 2 00:00:05,750 --> 00:00:08,389 ‫a slight different expectation of how to use the 3 00:00:08,630 --> 00:00:10,918 ‫run command. Starting in the Version 1.12, and 4 00:00:11,990 --> 00:00:14,417 ‫then at least through the current versions of Release 1.15, 5 00:00:15,080 --> 00:00:17,959 ‫and possibly in the next few, there's going to be different 6 00:00:17,960 --> 00:00:20,869 ‫messages based on how you use, or operate, the 7 00:00:21,080 --> 00:00:23,187 ‫run command. It's state, and it's uses, has 8 00:00:24,110 --> 00:00:25,549 ‫changed over the years. 9 00:00:25,580 --> 00:00:27,491 ‫The goal now with the run command is to 10 00:00:28,640 --> 00:00:31,879 ‫reduce it's functionality and deprecate many 11 00:00:31,880 --> 00:00:34,219 ‫of the generators that you just previously learned about. 12 00:00:34,720 --> 00:00:36,899 ‫Deprecate most of those. In fact, all of them but one, and 13 00:00:36,900 --> 00:00:39,646 ‫leave it as a single run command 14 00:00:40,280 --> 00:00:41,990 ‫that's designed to just start a pod. 15 00:00:42,500 --> 00:00:45,289 ‫One of the goals here is to reduce it's complexity so that 16 00:00:45,290 --> 00:00:47,840 ‫it's very similar and experienced to the docker 17 00:00:48,080 --> 00:00:49,930 ‫run command, only you're running it on top of Kubernetes. 18 00:00:50,840 --> 00:00:54,590 ‫We want to get rid of the generators that use deployments 19 00:00:54,620 --> 00:00:57,799 ‫and all these other types of generators because they're 20 00:00:57,800 --> 00:01:00,590 ‫now available in the kubectl create command. 21 00:01:00,980 --> 00:01:03,381 ‫So, when you think about, in the future, creating 22 00:01:03,950 --> 00:01:06,469 ‫objects from the one-liner command lines, think of the 23 00:01:06,470 --> 00:01:09,709 ‫create. Then the run is really just going to be left 24 00:01:09,950 --> 00:01:12,155 ‫to doing pods. The single use, really, that I 25 00:01:13,010 --> 00:01:15,499 ‫have for running pods really quickly is when I just want to 26 00:01:15,500 --> 00:01:17,689 ‫get something started. Maybe I'm on a machine that doesn't 27 00:01:17,690 --> 00:01:20,387 ‫have Docker because I'm using containerd or CRI-O, 28 00:01:20,990 --> 00:01:23,959 ‫or one of the other runtime engines, and I 29 00:01:23,960 --> 00:01:26,419 ‫don't have docker run convenience for me. 30 00:01:26,810 --> 00:01:29,380 ‫But, I do have Kubernetes installed, so I can do a kubectl 31 00:01:29,630 --> 00:01:31,370 ‫run which gives me a similar experience. 32 00:01:31,790 --> 00:01:34,044 ‫For me, the real reason, and only use case for 33 00:01:34,760 --> 00:01:38,059 ‫me to use run nowadays, now that we have this deprecated 34 00:01:38,060 --> 00:01:41,329 ‫stuff on a day-to-day basis, is for running one 35 00:01:41,330 --> 00:01:44,172 ‫shot containers, like troubleshooting, or network testing, 36 00:01:44,750 --> 00:01:47,689 ‫or something like that. Or, I just need to jump into a 37 00:01:47,690 --> 00:01:49,909 ‫container network, and I need to have a command line there 38 00:01:49,910 --> 00:01:51,829 ‫for some reason. That's when I use a run. 39 00:01:52,090 --> 00:01:54,499 ‫But, it's kind of important, still, at least for the next 40 00:01:54,500 --> 00:01:56,749 ‫few years, to understand the history of run. 41 00:01:56,990 --> 00:01:59,179 ‫Because, you're going to find all sorts of examples, 42 00:01:59,180 --> 00:02:01,875 ‫including in these videos that I'm giving you, on using 43 00:02:02,330 --> 00:02:05,810 ‫the run command because it's had a lot of history 44 00:02:06,020 --> 00:02:09,259 ‫with Kubernetes. So, when you're seeing examples, 45 00:02:09,470 --> 00:02:12,169 ‫you might have to translate on blogs, or different 46 00:02:12,170 --> 00:02:14,599 ‫documentation, that's going to be outdated in a few years. 47 00:02:14,840 --> 00:02:16,339 ‫You're going to see that stuff and you're going to have to 48 00:02:16,340 --> 00:02:18,699 ‫translate, OK, I used to do that with the run command. 49 00:02:19,010 --> 00:02:21,139 ‫Now, I've got to do that with a create command. 50 00:02:21,470 --> 00:02:24,361 ‫So, let me give you some examples of how the run command 51 00:02:25,100 --> 00:02:27,860 ‫used to work and still frankly, does today. 52 00:02:27,920 --> 00:02:31,069 ‫The version you're using to do this course because when 53 00:02:31,190 --> 00:02:33,769 ‫this stops working, I'm going to take this video out and 54 00:02:33,770 --> 00:02:35,485 ‫replace it with a sort of in memory 55 00:02:36,740 --> 00:02:37,740 ‫of the run command. 56 00:02:38,150 --> 00:02:40,309 ‫Let's talk about this thing we have that we no longer have 57 00:02:40,310 --> 00:02:41,310 ‫anymore. 58 00:02:41,690 --> 00:02:44,330 ‫Let's look at a few commands. 59 00:02:44,360 --> 00:02:47,119 ‫I'm just going to throw them in at the command line so that 60 00:02:47,120 --> 00:02:50,629 ‫you see what generators they were using based 61 00:02:50,720 --> 00:02:52,003 ‫on the type of run command you were using. 62 00:02:52,760 --> 00:02:54,829 ‫This is part of the confusion with run is it started to get 63 00:02:54,830 --> 00:02:56,888 ‫really complex in its use cases because of 64 00:02:57,800 --> 00:02:59,599 ‫various things you would do at the command line would 65 00:02:59,600 --> 00:03:02,629 ‫change the way it behaved when it created 66 00:03:02,630 --> 00:03:04,939 ‫your resources. With all of these, I'm just going to do a 67 00:03:04,940 --> 00:03:07,488 ‫dry run to show you what the object that was created 68 00:03:08,000 --> 00:03:10,669 ‫was. For this command, this is the standard one you learned 69 00:03:10,670 --> 00:03:12,019 ‫how to create Deployments earlier. 70 00:03:12,020 --> 00:03:14,617 ‫You'll notice that this default, I'm not specifying a 71 00:03:14,720 --> 00:03:16,270 ‫generator here, which I can do with a --generator. 72 00:03:18,940 --> 00:03:21,069 ‫But, I'm not going to use that because I want to show you 73 00:03:21,070 --> 00:03:22,930 ‫how the run command changes over time. 74 00:03:23,350 --> 00:03:26,050 ‫Without the generator today, 75 00:03:26,350 --> 00:03:27,909 ‫it's going to give you a Deployment. 76 00:03:28,180 --> 00:03:30,826 ‫In the future, when they finally make this change, the 77 00:03:31,210 --> 00:03:33,916 ‫default run will create a pod, not a Deployment, and it 78 00:03:34,540 --> 00:03:37,780 ‫will be expected that you use create or apply 79 00:03:38,140 --> 00:03:41,229 ‫to create Deployments, those commands, and 80 00:03:41,230 --> 00:03:42,693 ‫leave the run only for the pods. 81 00:03:43,700 --> 00:03:45,610 ‫Today, this is on 114. 82 00:03:45,940 --> 00:03:48,789 ‫You'll see that it creates a Deployment right there named 83 00:03:48,790 --> 00:03:51,759 ‫test. For these next few, you've not seen me give 84 00:03:51,760 --> 00:03:54,729 ‫you these examples because I didn't want you learning all 85 00:03:54,730 --> 00:03:57,189 ‫the different nuances of the run command if you weren't 86 00:03:57,190 --> 00:03:58,689 ‫going to be using them in a few years. 87 00:03:58,840 --> 00:04:01,900 ‫Here, you would see in this one, I added a port 88 00:04:01,960 --> 00:04:04,719 ‫and expose there, which in this case, 89 00:04:05,080 --> 00:04:07,569 ‫it will give me the warning, like normal, and it will then 90 00:04:07,570 --> 00:04:09,689 ‫create two, different things. 91 00:04:09,720 --> 00:04:12,519 ‫It'll create the Deployment and the service 92 00:04:12,910 --> 00:04:16,079 ‫resources without having to use two, different commands. 93 00:04:16,120 --> 00:04:19,360 ‫It's a really handy way to create and expose 94 00:04:19,420 --> 00:04:22,660 ‫a Deployment. Again, that's going away because you can use 95 00:04:22,690 --> 00:04:25,314 ‫the expose or the create commands separately, and it 96 00:04:27,010 --> 00:04:29,529 ‫turns out that the automation and complexity of this may 97 00:04:29,530 --> 00:04:31,629 ‫not be a good idea going forward. 98 00:04:31,660 --> 00:04:32,709 ‫So, they're going to get rid of that. 99 00:04:33,040 --> 00:04:36,069 ‫The next one here, I took out the expose part, and then 100 00:04:36,070 --> 00:04:38,109 ‫I added a restart on failure. 101 00:04:38,500 --> 00:04:41,439 ‫This will create a different type of resource. 102 00:04:41,470 --> 00:04:44,589 ‫It'll create the batch job or just the Job type. 103 00:04:44,650 --> 00:04:47,620 ‫That one there is essentially 104 00:04:47,770 --> 00:04:50,649 ‫for one-shot containers, things that you need to run. 105 00:04:50,650 --> 00:04:52,839 ‫Maybe you need to do at a schema update on your database. 106 00:04:52,870 --> 00:04:55,750 ‫Or maybe you want to do a quick database backup, 107 00:04:56,020 --> 00:04:58,179 ‫and you only want it to recreate the container if it 108 00:04:58,180 --> 00:05:00,849 ‫failed. Those were things you could do with run, but you 109 00:05:00,850 --> 00:05:03,579 ‫can also now do those with other ways. 110 00:05:03,820 --> 00:05:06,208 ‫The next one here is I set restart to never instead 111 00:05:06,970 --> 00:05:09,371 ‫of on failure. That will then change the resource 112 00:05:09,970 --> 00:05:12,879 ‫type to a pod, which will soon be 113 00:05:12,940 --> 00:05:13,940 ‫the default. 114 00:05:14,200 --> 00:05:16,110 ‫This is a little confusing. 115 00:05:16,120 --> 00:05:18,429 ‫You can force this behavior and you'll notice if we go back 116 00:05:18,430 --> 00:05:20,470 ‫to one of these previous commands like I just showed you, 117 00:05:20,770 --> 00:05:23,416 ‫when I do the restart on failure, the reason that line 118 00:05:23,800 --> 00:05:26,829 ‫is there is it's saying in the future, this 119 00:05:26,830 --> 00:05:28,600 ‫is what's going to happen, by default. 120 00:05:28,870 --> 00:05:32,199 ‫If you don't want that to happen, you can either force 121 00:05:32,290 --> 00:05:35,199 ‫a different generator, like I'm doing here, which is 122 00:05:35,260 --> 00:05:38,319 ‫using the Job V1, or use the create command. 123 00:05:38,320 --> 00:05:39,640 ‫Which they would prefer you use. 124 00:05:39,910 --> 00:05:42,309 ‫So, my course is designed for that future use. 125 00:05:42,340 --> 00:05:45,040 ‫I'm not teaching you all the different ways to run the 126 00:05:45,220 --> 00:05:48,129 ‫run command. I'm just going to focus on the create 127 00:05:48,370 --> 00:05:49,929 ‫and other options like apply. 128 00:05:50,250 --> 00:05:52,689 ‫Then the last one here, in case you just didn't know this 129 00:05:52,690 --> 00:05:55,449 ‫existed. Because we have cron job support in 130 00:05:55,700 --> 00:05:58,248 ‫Kubernetes, if I gave the same run command, but then 131 00:05:58,870 --> 00:06:02,290 ‫I gave it a schedule, it would change the generator 132 00:06:02,590 --> 00:06:04,269 ‫to use a cron job. 133 00:06:04,560 --> 00:06:06,569 ‫Which, a little bit different than a Job. 134 00:06:06,580 --> 00:06:08,920 ‫The cron job is designed to be reoccurring. 135 00:06:09,130 --> 00:06:11,335 ‫So, it will happen, in this case, it's once a 136 00:06:12,160 --> 00:06:15,051 ‫day. Hopefully, that makes sense in terms of the history of 137 00:06:15,130 --> 00:06:17,972 ‫the run command. Again, I think, really, the future for us 138 00:06:17,980 --> 00:06:20,470 ‫we should just start behaving as if it's only creating pods 139 00:06:20,500 --> 00:06:23,869 ‫because here soon, whether it's going to be in possibly 116 140 00:06:23,890 --> 00:06:26,559 ‫or 117, I'm not sure when they're going to force the real 141 00:06:26,560 --> 00:06:29,709 ‫change. All of these will be pulled out at some 142 00:06:29,710 --> 00:06:31,660 ‫point and won't even build to use these generators. 143 00:06:31,870 --> 00:06:34,779 ‫We'll be forced to use create and apply in other ways to 144 00:06:34,780 --> 00:06:36,899 ‫create the different types of resources.