Based on when you watch this video, there's going to be 2 2
a slight different expectation of how to use the 3 3
run command. Starting in the Version 1.12, and 4 4
then at least through the current versions of Release 1.15, 5 5
and possibly in the next few, there's going to be different 6 6
messages based on how you use, or operate, the 7 7
run command. It's state, and it's uses, has 8 8
changed over the years. 9 9
The goal now with the run command is to 10 10
reduce it's functionality and deprecate many 11 11
of the generators that you just previously learned about. 12 12
Deprecate most of those. In fact, all of them but one, and 13 13
leave it as a single run command 14 14
that's designed to just start a pod. 15 15
One of the goals here is to reduce it's complexity so that 16 16
it's very similar and experienced to the docker 17 17
run command, only you're running it on top of Kubernetes. 18 18
We want to get rid of the generators that use deployments 19 19
and all these other types of generators because they're 20 20
now available in the kubectl create command. 21 21
So, when you think about, in the future, creating 22 22
objects from the one-liner command lines, think of the 23 23
create. Then the run is really just going to be left 24 24
to doing pods. The single use, really, that I 25 25
have for running pods really quickly is when I just want to 26 26
get something started. Maybe I'm on a machine that doesn't 27 27
have Docker because I'm using containerd or CRI-O, 28 28
or one of the other runtime engines, and I 29 29
don't have docker run convenience for me. 30 30
But, I do have Kubernetes installed, so I can do a kubectl 31 31
run which gives me a similar experience. 32 32
For me, the real reason, and only use case for 33 33
me to use run nowadays, now that we have this deprecated 34 34
stuff on a day-to-day basis, is for running one 35 35
shot containers, like troubleshooting, or network testing, 36 36
or something like that. Or, I just need to jump into a 37 37
container network, and I need to have a command line there 38 38
for some reason. That's when I use a run. 39 39
But, it's kind of important, still, at least for the next 40 40
few years, to understand the history of run. 41 41
Because, you're going to find all sorts of examples, 42 42
including in these videos that I'm giving you, on using 43 43
the run command because it's had a lot of history 44 44
with Kubernetes. So, when you're seeing examples, 45 45
you might have to translate on blogs, or different 46 46
documentation, that's going to be outdated in a few years. 47 47
You're going to see that stuff and you're going to have to 48 48
translate, OK, I used to do that with the run command. 49 49
Now, I've got to do that with a create command. 50 50
So, let me give you some examples of how the run command 51 51
used to work and still frankly, does today. 52 52
The version you're using to do this course because when 53 53
this stops working, I'm going to take this video out and 54 54
replace it with a sort of in memory 55 55
of the run command. 56 56
Let's talk about this thing we have that we no longer have 57 57
anymore. 58 58
Let's look at a few commands. 59 59
I'm just going to throw them in at the command line so that 60 60
you see what generators they were using based 61 61
on the type of run command you were using. 62 62
This is part of the confusion with run is it started to get 63 63
really complex in its use cases because of 64 64
various things you would do at the command line would 65 65
change the way it behaved when it created 66 66
your resources. With all of these, I'm just going to do a 67 67
dry run to show you what the object that was created 68 68
was. For this command, this is the standard one you learned 69 69
how to create Deployments earlier. 70 70
You'll notice that this default, I'm not specifying a 71 71
generator here, which I can do with a --generator. 72 72
But, I'm not going to use that because I want to show you 73 73
how the run command changes over time. 74 74
Without the generator today, 75 75
it's going to give you a Deployment. 76 76
In the future, when they finally make this change, the 77 77
default run will create a pod, not a Deployment, and it 78 78
will be expected that you use create or apply 79 79
to create Deployments, those commands, and 80 80
leave the run only for the pods. 81 81
Today, this is on 114. 82 82
You'll see that it creates a Deployment right there named 83 83
test. For these next few, you've not seen me give 84 84
you these examples because I didn't want you learning all 85 85
the different nuances of the run command if you weren't 86 86
going to be using them in a few years. 87 87
Here, you would see in this one, I added a port 88 88
and expose there, which in this case, 89 89
it will give me the warning, like normal, and it will then 90 90
create two, different things. 91 91
It'll create the Deployment and the service 92 92
resources without having to use two, different commands. 93 93
It's a really handy way to create and expose 94 94
a Deployment. Again, that's going away because you can use 95 95
the expose or the create commands separately, and it 96 96
turns out that the automation and complexity of this may 97 97
not be a good idea going forward. 98 98
So, they're going to get rid of that. 99 99
The next one here, I took out the expose part, and then 100 100
I added a restart on failure. 101 101
This will create a different type of resource. 102 102
It'll create the batch job or just the Job type. 103 103
That one there is essentially 104 104
for one-shot containers, things that you need to run. 105 105
Maybe you need to do at a schema update on your database. 106 106
Or maybe you want to do a quick database backup, 107 107
and you only want it to recreate the container if it 108 108
failed. Those were things you could do with run, but you 109 109
can also now do those with other ways. 110 110
The next one here is I set restart to never instead 111 111
of on failure. That will then change the resource 112 112
type to a pod, which will soon be 113 113
the default. 114 114
This is a little confusing. 115 115
You can force this behavior and you'll notice if we go back 116 116
to one of these previous commands like I just showed you, 117 117
when I do the restart on failure, the reason that line 118 118
is there is it's saying in the future, this 119 119
is what's going to happen, by default. 120 120
If you don't want that to happen, you can either force 121 121
a different generator, like I'm doing here, which is 122 122
using the Job V1, or use the create command. 123 123
Which they would prefer you use. 124 124
So, my course is designed for that future use. 125 125
I'm not teaching you all the different ways to run the 126 126
run command. I'm just going to focus on the create 127 127
and other options like apply. 128 128
Then the last one here, in case you just didn't know this 129 129
existed. Because we have cron job support in 130 130
Kubernetes, if I gave the same run command, but then 131 131
I gave it a schedule, it would change the generator 132 132
to use a cron job. 133 133
Which, a little bit different than a Job. 134 134
The cron job is designed to be reoccurring. 135 135
So, it will happen, in this case, it's once a 136 136
day. Hopefully, that makes sense in terms of the history of 137 137
the run command. Again, I think, really, the future for us 138 138
we should just start behaving as if it's only creating pods 139 139
because here soon, whether it's going to be in possibly 116 140 140
or 117, I'm not sure when they're going to force the real 141 141
change. All of these will be pulled out at some 142 142
point and won't even build to use these generators. 143 143
We'll be forced to use create and apply in other ways to 144 144
create the different types of resources.