1 00:00:03,010 --> 00:00:04,480 ‫Kubernetes is a lot of things. 2 00:00:04,776 --> 00:00:07,719 ‫I want to definitely break down some of the 3 00:00:07,720 --> 00:00:09,043 ‫basic topology and parts of 4 00:00:10,900 --> 00:00:13,839 ‫the system before we get into installing an app 5 00:00:14,260 --> 00:00:17,410 ‫on Kubernetes. First up is Kubernetes itself. 6 00:00:17,800 --> 00:00:19,555 ‫That is essentially what I'm talking about. 7 00:00:19,556 --> 00:00:21,370 ‫The entire system. 8 00:00:21,430 --> 00:00:24,027 ‫Either a single server or multi server setup with all 9 00:00:24,430 --> 00:00:27,879 ‫the parts together that are there to run your apps. 10 00:00:28,030 --> 00:00:29,430 ‫We abbreviate that sometimes as K8s. 11 00:00:30,250 --> 00:00:33,189 ‫Normally when I'm talking about Kubernetes, I will just say 12 00:00:33,370 --> 00:00:35,722 ‫Kubernetes, but often in writing, or even in the 13 00:00:36,100 --> 00:00:38,244 ‫documentation, you'll see the K8s, 14 00:00:39,610 --> 00:00:42,430 ‫and that essentially is a short, abbreviated version of 15 00:00:42,730 --> 00:00:45,229 ‫Kubernetes. If you actually look at it, the 8 means 16 00:00:45,880 --> 00:00:48,629 ‫the 8 letters between the K and the S. 17 00:00:48,640 --> 00:00:51,630 ‫That's why they did it. The K, eight letters, and then S. 18 00:00:51,820 --> 00:00:52,960 ‫That's their abbreviation. 19 00:00:53,230 --> 00:00:54,820 ‫Sometimes people might call it Kube. 20 00:00:55,090 --> 00:00:57,219 ‫But, essentially here we're going to be talking about the 21 00:00:57,220 --> 00:00:58,740 ‫same thing when we say Kubernetes and K8s. 22 00:00:59,950 --> 00:01:02,596 ‫Now kubectl is the command line tool that you will use 23 00:01:03,310 --> 00:01:05,319 ‫to talk to the Kubernetes API. 24 00:01:05,560 --> 00:01:08,499 ‫The main way we talk to Kubernetes is through its API. 25 00:01:08,830 --> 00:01:10,939 ‫There's multiple tools out there that can do it. 26 00:01:10,960 --> 00:01:13,540 ‫In fact, there's lots of tools they can talk to the API. 27 00:01:13,780 --> 00:01:16,629 ‫The one that really comes officially from the project and 28 00:01:16,630 --> 00:01:18,650 ‫that we'll be using most of the time is kubectl. 29 00:01:19,300 --> 00:01:22,209 ‫Now you may see this being referred to in other 30 00:01:22,480 --> 00:01:24,244 ‫videos, or talks, as cube cuddle, or 31 00:01:25,430 --> 00:01:28,629 ‫kube cuddle, or kube control, all sorts of other 32 00:01:28,960 --> 00:01:31,749 ‫types or maybe even kubectl, but 33 00:01:31,990 --> 00:01:33,489 ‫those all are the same thing. 34 00:01:33,520 --> 00:01:35,979 ‫They're essentially different people saying it a different 35 00:01:35,980 --> 00:01:38,590 ‫way. In fact, just about a year ago or so 36 00:01:38,950 --> 00:01:41,620 ‫they decided to officially call this tool 37 00:01:42,130 --> 00:01:43,659 ‫kubectl in the documentation. 38 00:01:44,050 --> 00:01:45,610 ‫But, there really is no wrong way to say it. 39 00:01:46,610 --> 00:01:49,989 ‫Just like with Swarm, where we call nodes 40 00:01:50,080 --> 00:01:53,070 ‫the servers that are inside of that cluster, Kubernetes 41 00:01:53,290 --> 00:01:55,201 ‫also refers to things as nodes as well. 42 00:01:55,480 --> 00:01:58,089 ‫So, that terminology is at least the same between the two. 43 00:01:58,990 --> 00:02:01,989 ‫Kubelet is the container that will run a 44 00:02:01,990 --> 00:02:05,199 ‫small, little agent on each node to allow 45 00:02:05,200 --> 00:02:08,499 ‫that node to talk back to the Kubernetes master. 46 00:02:08,740 --> 00:02:11,740 ‫Remember, since Docker had Swarm built in, 47 00:02:11,980 --> 00:02:13,839 ‫it didn't really need the separate agent. 48 00:02:13,840 --> 00:02:16,260 ‫That was all built into the Docker Engine. 49 00:02:16,330 --> 00:02:18,878 ‫Now with Kubernetes running on top of that, it needs 50 00:02:19,330 --> 00:02:22,689 ‫its own engine API that talks to the local Docker, 51 00:02:22,960 --> 00:02:25,120 ‫or the local runtime, whichever that may be. 52 00:02:25,420 --> 00:02:28,719 ‫Then it talks back up to the control plane, 53 00:02:28,810 --> 00:02:31,470 ‫or master, which is in charge of running the Kubernetes 54 00:02:31,650 --> 00:02:32,650 ‫cluster. 55 00:02:32,950 --> 00:02:36,040 ‫The control plane, sometimes called the master, 56 00:02:36,400 --> 00:02:38,115 ‫is what's in charge of the cluster. 57 00:02:38,970 --> 00:02:40,565 ‫If you're familiar with Swarm. 58 00:02:41,290 --> 00:02:42,999 ‫In Swarm, we had the manager. 59 00:02:43,030 --> 00:02:44,490 ‫There could be one or more managers. 60 00:02:44,500 --> 00:02:46,269 ‫We wanted an odd number of managers. 61 00:02:46,570 --> 00:02:49,150 ‫Then there was workers that were doing all the work. 62 00:02:49,180 --> 00:02:52,479 ‫If you remember from Swarm, the managers could also 63 00:02:52,480 --> 00:02:54,609 ‫be workers because they could also run containers 64 00:02:54,610 --> 00:02:57,305 ‫themselves. So you could technically just have a single 65 00:02:57,340 --> 00:03:00,129 ‫server. You could have many servers and have the two roles 66 00:03:00,130 --> 00:03:02,910 ‫split out. A lot of that is very similar in Kubernetes. 67 00:03:03,460 --> 00:03:05,229 ‫We just have slightly different names for it. 68 00:03:05,650 --> 00:03:07,610 ‫The control plane, also something we ran 69 00:03:08,620 --> 00:03:11,409 ‫in Swarm, is the part where 70 00:03:11,740 --> 00:03:14,440 ‫the servers are running all of the stuff that's 71 00:03:14,860 --> 00:03:16,119 ‫in charge essentially. 72 00:03:16,180 --> 00:03:18,610 ‫It's more than one container. It's a group of containers. 73 00:03:18,970 --> 00:03:20,879 ‫They run individual things. 74 00:03:20,890 --> 00:03:24,189 ‫They take the Linux principle of do one 75 00:03:24,190 --> 00:03:26,979 ‫thing and do it well, and they take that and split 76 00:03:26,980 --> 00:03:29,409 ‫everything up. So, essentially each one of these parts is 77 00:03:29,410 --> 00:03:32,439 ‫doing one thing and doing it well, and it simplifies 78 00:03:32,440 --> 00:03:33,850 ‫the design in terms of the development. 79 00:03:33,851 --> 00:03:36,490 ‫But when you have to build this and run it, 80 00:03:36,820 --> 00:03:39,009 ‫it does make things a little harder to set up because 81 00:03:39,010 --> 00:03:42,069 ‫there's more to it. This control plane includes 82 00:03:42,070 --> 00:03:45,580 ‫containers that will be running the API, the scheduler, 83 00:03:45,850 --> 00:03:48,609 ‫you actually need a database backend that will be something 84 00:03:48,610 --> 00:03:49,610 ‫called etcd. 85 00:03:50,140 --> 00:03:51,849 ‫Then you have controller manager. 86 00:03:52,040 --> 00:03:54,609 ‫You'll probably need something called coreDNS to handle 87 00:03:54,610 --> 00:03:55,810 ‫your DNS, and so on. 88 00:03:56,500 --> 00:03:58,705 ‫We have a lot of parts here, but let's put it 89 00:03:59,500 --> 00:04:02,199 ‫on a diagram and see if this helps makes sense. 90 00:04:02,230 --> 00:04:04,780 ‫I'll compare it to Swarm since you've already learned that 91 00:04:04,840 --> 00:04:05,840 ‫in this course. 92 00:04:08,825 --> 00:04:10,999 ‫If you only had one machine, like we're going to do in a 93 00:04:11,000 --> 00:04:14,150 ‫minute for learning, all of the things I referred to 94 00:04:14,360 --> 00:04:17,089 ‫previously would all be in the same server. 95 00:04:17,140 --> 00:04:19,278 ‫There would be a bunch of running containers. That's what 96 00:04:19,279 --> 00:04:21,876 ‫you'll see on things like minikube and Docker Desktop 97 00:04:22,249 --> 00:04:23,700 ‫when you're running a single node Kubernetes. 98 00:04:23,701 --> 00:04:26,359 ‫In the real world when you get on servers, 99 00:04:26,810 --> 00:04:28,579 ‫you're going to break this stuff out. I thought I would 100 00:04:28,580 --> 00:04:31,471 ‫show you really quick, on a network diagram, how this might 101 00:04:31,490 --> 00:04:33,079 ‫look and explain the different parts. 102 00:04:34,260 --> 00:04:36,089 ‫First, let's assume you have a master. 103 00:04:38,625 --> 00:04:40,830 ‫In a multi master setup, you would have three 104 00:04:41,730 --> 00:04:44,310 ‫of those. Just like with Swarm, you need odd numbers 105 00:04:44,550 --> 00:04:47,558 ‫because it uses the same RAFT protocol to keep consensus 106 00:04:47,700 --> 00:04:48,700 ‫just like Swarm did. 107 00:04:51,160 --> 00:04:53,413 ‫In the documentation, these are all known as master. 108 00:04:53,414 --> 00:04:56,350 ‫But, it gets a little confusing when you have more than one 109 00:04:56,380 --> 00:04:59,079 ‫master because it's the same setup where you can only have 110 00:04:59,080 --> 00:05:01,302 ‫one that's really doing the job of writing the etcd. 111 00:05:02,200 --> 00:05:04,839 ‫These are also known as the control plane. 112 00:05:08,250 --> 00:05:10,824 ‫You'll recognize that term from Swarm, 113 00:05:11,250 --> 00:05:13,602 ‫which was referring specifically in Swarm to the 114 00:05:14,220 --> 00:05:17,579 ‫protocols over the network that were allowing 115 00:05:17,580 --> 00:05:20,373 ‫the masters and the nodes to all talk securely for giving 116 00:05:20,700 --> 00:05:22,739 ‫orders. But here, it's a little bit different. 117 00:05:22,740 --> 00:05:25,889 ‫The control plane is talking about the master nodes 118 00:05:25,920 --> 00:05:27,149 ‫that are all making decisions. 119 00:05:28,490 --> 00:05:30,739 ‫Just like with Swarm, we have worker nodes. 120 00:05:30,850 --> 00:05:33,319 ‫In the documentation, they'll really just be referred to as 121 00:05:33,320 --> 00:05:36,559 ‫nodes. Sometimes, you see the word worker mentioned. 122 00:05:36,950 --> 00:05:40,069 ‫We're going to call those nodes here just to be consistent. 123 00:05:41,680 --> 00:05:44,680 ‫Again, like before, all of these can run containers, 124 00:05:44,710 --> 00:05:47,050 ‫but generally you're going to keep your apps to the nodes 125 00:05:47,440 --> 00:05:50,439 ‫and the Kubernetes management systems to 126 00:05:50,440 --> 00:05:51,440 ‫the masters. 127 00:05:52,345 --> 00:05:54,338 ‫All of these are running on top of Docker or 128 00:05:56,950 --> 00:06:00,258 ‫some other container runtime like containerd 129 00:06:00,700 --> 00:06:01,700 ‫or crio. 130 00:06:02,140 --> 00:06:04,541 ‫Inside of each master, we're going to need to run 131 00:06:05,110 --> 00:06:06,825 ‫multiple containers to keep control 132 00:06:08,290 --> 00:06:10,664 ‫of the system. The first of that is etcd. 133 00:06:12,966 --> 00:06:16,009 ‫Etcd is a distributed storage system 134 00:06:16,070 --> 00:06:17,359 ‫for key values. 135 00:06:17,420 --> 00:06:20,420 ‫It's very similar to how Swarm works with its 136 00:06:20,480 --> 00:06:22,610 ‫RAFT algorithm system. 137 00:06:22,940 --> 00:06:25,819 ‫It's similar to etcd, but etcd is a separate product 138 00:06:26,180 --> 00:06:29,071 ‫and is something you can install without Kubernetes just to 139 00:06:29,150 --> 00:06:30,799 ‫store configuration data. 140 00:06:30,830 --> 00:06:33,799 ‫It uses the same RAFT protocol, so a lot of the same rules 141 00:06:33,800 --> 00:06:35,839 ‫apply. You need odd numbers. 142 00:06:35,990 --> 00:06:38,059 ‫You can start with one, but if you want true fault 143 00:06:38,060 --> 00:06:39,230 ‫tolerance, you need three. 144 00:06:39,530 --> 00:06:42,176 ‫And so on. On top of that, you'll need to run multiple 145 00:06:42,380 --> 00:06:45,470 ‫Kubernetes containers that will store data 146 00:06:45,500 --> 00:06:48,350 ‫inside etcd and manage the cluster. 147 00:06:49,070 --> 00:06:51,275 ‫First up is the API, which will be the way we 148 00:06:52,040 --> 00:06:54,369 ‫talk to this cluster and issue orders to it. 149 00:06:56,860 --> 00:07:00,310 ‫Next up is the scheduler container, which will control 150 00:07:00,610 --> 00:07:03,910 ‫how and where your containers are placed on the nodes 151 00:07:04,330 --> 00:07:05,769 ‫in objects called pods. 152 00:07:07,780 --> 00:07:11,139 ‫Next up is the controller manager, which looks at the state 153 00:07:11,140 --> 00:07:13,360 ‫of the whole cluster, and everything that's running in it, 154 00:07:13,750 --> 00:07:15,519 ‫and it uses the API to do that. 155 00:07:15,940 --> 00:07:18,999 ‫It takes the orders that are giving it, or the specs, 156 00:07:19,330 --> 00:07:22,079 ‫and determines the difference between what you're asking it 157 00:07:22,080 --> 00:07:23,649 ‫to do and what's actually going on. 158 00:07:24,250 --> 00:07:25,965 ‫It's basically a loop that's seeing 159 00:07:27,250 --> 00:07:29,994 ‫the whole system and figuring out how to make everything 160 00:07:30,130 --> 00:07:32,769 ‫that's currently happening the same as what you've asked it 161 00:07:32,770 --> 00:07:36,220 ‫to do. Then you'll need something to control DNS, 162 00:07:36,250 --> 00:07:38,842 ‫which isn't built in, and by default, that's coreDNS. 163 00:07:45,690 --> 00:07:48,630 ‫Depending on other add-ons that you 164 00:07:48,780 --> 00:07:51,810 ‫get later, like networking or storage, 165 00:07:52,140 --> 00:07:54,639 ‫web and other features, you'll have more containers 166 00:07:55,290 --> 00:07:56,290 ‫running here as well. 167 00:07:56,640 --> 00:07:59,336 ‫On all the nodes, they're going to need an agent running. 168 00:07:59,520 --> 00:08:00,520 ‫That's known as kubelet. 169 00:08:07,430 --> 00:08:09,782 ‫To start with, you'll need kube-proxy to control 170 00:08:10,430 --> 00:08:11,430 ‫the networking. 171 00:08:17,610 --> 00:08:20,354 ‫Just like with Docker, all of these will be repeated for 172 00:08:20,790 --> 00:08:23,159 ‫their role. The masters, if you were going to do multi 173 00:08:23,160 --> 00:08:25,740 ‫master, would have all those same containers set up. 174 00:08:26,040 --> 00:08:28,980 ‫Each node that you set for worker nodes will 175 00:08:29,010 --> 00:08:31,411 ‫also have those at least two containers there for 176 00:08:32,070 --> 00:08:34,619 ‫management. Kubernetes is designed to solve lots of 177 00:08:34,620 --> 00:08:35,909 ‫problems in lots of ways. 178 00:08:36,150 --> 00:08:39,209 ‫You'll find yourself possibly adding more things 179 00:08:39,210 --> 00:08:42,210 ‫to masters, more things to nodes, such as networking. 180 00:08:42,990 --> 00:08:46,019 ‫On the master side, there's lots of other optional tools 181 00:08:46,020 --> 00:08:47,340 ‫to add onto it as well. 182 00:08:47,640 --> 00:08:50,399 ‫Let's get to installing this on your local system for 183 00:08:50,400 --> 00:08:50,789 ‫learning.