1 00:00:02,670 --> 00:00:05,699 ‫You've heard me say before in this part of 2 00:00:05,700 --> 00:00:08,060 ‫the course about Kubernetes that it's rather unopinionated. 3 00:00:09,120 --> 00:00:12,029 ‫Which means it gives us a set of tools and commands, 4 00:00:12,300 --> 00:00:15,330 ‫but it doesn't really prescribe one way to do things. 5 00:00:15,390 --> 00:00:18,449 ‫I guess the more ways you could do something, the more 6 00:00:18,450 --> 00:00:21,149 ‫you might say it's unopinionated because you can just 7 00:00:21,270 --> 00:00:22,769 ‫choose whichever path you'd like. 8 00:00:23,100 --> 00:00:25,902 ‫We've talked about, in the previous section, about 9 00:00:26,520 --> 00:00:29,820 ‫three major ways to do 10 00:00:30,190 --> 00:00:33,239 ‫Kubernetes or to manage your Kubernetes workloads, 11 00:00:33,530 --> 00:00:35,882 ‫right. The third one, the declarative, the fully 12 00:00:36,540 --> 00:00:39,539 ‫declarative way, is the one that I want this 13 00:00:39,540 --> 00:00:40,649 ‫whole section to be about. 14 00:00:41,040 --> 00:00:43,434 ‫Which means we're going to be mostly focusing on YAML 15 00:00:44,220 --> 00:00:46,300 ‫and how that works in Kubernetes. 16 00:00:46,920 --> 00:00:49,830 ‫The reason I want this whole section to be about 17 00:00:50,100 --> 00:00:52,207 ‫the declarative way is because it's more of 18 00:00:53,070 --> 00:00:54,270 ‫the DevOps style. 19 00:00:54,330 --> 00:00:57,329 ‫It's more conducive to the infrastructure as 20 00:00:57,330 --> 00:00:59,829 ‫code, and the new term on the block, git-ops, which 21 00:01:00,420 --> 00:01:03,239 ‫is all about storing your YAML and configurations 22 00:01:03,540 --> 00:01:06,039 ‫in git repositories and using git-commits to change 23 00:01:06,900 --> 00:01:09,500 ‫your infrastructure. I don't get too much into git-ops 24 00:01:09,870 --> 00:01:13,109 ‫here but really it's just about applying the automation 25 00:01:13,110 --> 00:01:16,379 ‫style of DevOps to your configurations. 26 00:01:16,620 --> 00:01:19,021 ‫What better way to do that in Kubernetes by using 27 00:01:19,650 --> 00:01:22,247 ‫YAML. The nice thing is there's very few commands you 28 00:01:22,410 --> 00:01:24,749 ‫have got to learn here. Really, all the focus is going to 29 00:01:24,750 --> 00:01:27,030 ‫be learning the different YAML formats. 30 00:01:27,510 --> 00:01:29,862 ‫Here, we're using the kubectl apply command with 31 00:01:30,540 --> 00:01:33,689 ‫a -f to tell it here's the file I want to give 32 00:01:33,690 --> 00:01:35,062 ‫you, and that's the command. 33 00:01:35,582 --> 00:01:37,469 ‫That's the command you use to create something. 34 00:01:37,470 --> 00:01:40,409 ‫That's the command you use to update something, or to edit 35 00:01:40,410 --> 00:01:42,959 ‫a configuration, or to change the image, or whatever you 36 00:01:42,960 --> 00:01:45,060 ‫want to do. That's the same command. 37 00:01:45,360 --> 00:01:48,112 ‫In that way, it's very much like stack deploy in Swarm 38 00:01:48,660 --> 00:01:50,999 ‫where you're just constantly giving it the same command 39 00:01:51,000 --> 00:01:52,000 ‫with updated YAML. 40 00:01:52,350 --> 00:01:55,139 ‫For this section, we're going to skip that middle 41 00:01:55,890 --> 00:01:59,459 ‫type of deployment which has the kubectl create, 42 00:01:59,640 --> 00:02:02,489 ‫and the edit, and the replace, and those commands 43 00:02:02,820 --> 00:02:04,780 ‫because they're not really a good way to 44 00:02:05,790 --> 00:02:07,470 ‫manage production infrastructure anymore. 45 00:02:07,890 --> 00:02:10,242 ‫They don't have a good solid DevOps structure to 46 00:02:11,039 --> 00:02:14,159 ‫them, and this course is all about DevOp style containers. 47 00:02:14,190 --> 00:02:15,840 ‫That's why we want to strive to. 48 00:02:16,230 --> 00:02:18,779 ‫So, do realize, as a disclaimer in this slide, that surely 49 00:02:18,810 --> 00:02:21,456 ‫you can use those commands if you want, but that's not 50 00:02:21,750 --> 00:02:24,200 ‫really the primary way I think you should be using 51 00:02:24,360 --> 00:02:25,360 ‫Kubernetes. 52 00:02:26,010 --> 00:02:28,319 ‫Just because this is the way I recommend it doesn't mean 53 00:02:28,320 --> 00:02:30,509 ‫that there isn't a lot of other possibilities out there. 54 00:02:30,810 --> 00:02:33,599 ‫Let me just throw you some quick examples of different ways 55 00:02:33,600 --> 00:02:34,740 ‫you can use the apply command. 56 00:02:35,130 --> 00:02:38,279 ‫You've seen that we can just tell it a YAML file 57 00:02:38,280 --> 00:02:40,319 ‫and it will apply something that's in there. 58 00:02:40,320 --> 00:02:42,368 ‫Maybe it's a deployment. Maybe it's just a pod. 59 00:02:42,462 --> 00:02:44,128 ‫Maybe it's a service, or a job, or 60 00:02:45,540 --> 00:02:47,610 ‫a cron job, or some other resource. 61 00:02:47,940 --> 00:02:49,949 ‫That -f will work on a whole directory so 62 00:02:51,000 --> 00:02:54,449 ‫you could have a bunch of different objects, or resources, 63 00:02:54,630 --> 00:02:57,689 ‫sort of spread out in different files, maybe one file 64 00:02:57,690 --> 00:03:00,210 ‫per resource. You could put all those in a directory. 65 00:03:00,420 --> 00:03:02,489 ‫You could just point it to that directory and it would 66 00:03:02,490 --> 00:03:03,719 ‫bring in all of those. 67 00:03:04,080 --> 00:03:07,409 ‫Of course, one YAML file can have multiple resources 68 00:03:07,440 --> 00:03:09,509 ‫in it, and I'll show you how that looks in a minute. 69 00:03:09,870 --> 00:03:12,869 ‫Another interesting option here is kubectl apply 70 00:03:12,930 --> 00:03:13,930 ‫with a URL. 71 00:03:14,370 --> 00:03:17,519 ‫We give it that -f, but the file is technically 72 00:03:17,760 --> 00:03:20,719 ‫a URL there. The way it knows that is through the HTTP 73 00:03:21,120 --> 00:03:22,884 ‫protocol. In my case, I've created a 74 00:03:24,180 --> 00:03:26,309 ‫domain that has a couple of examples. 75 00:03:26,610 --> 00:03:29,639 ‫There is a pod.yaml file there and so technically 76 00:03:29,640 --> 00:03:31,190 ‫if you ran that command, it would work. 77 00:03:31,290 --> 00:03:32,909 ‫It would deploy a single pod. 78 00:03:33,180 --> 00:03:35,924 ‫Just be careful of these files because you know it's one 79 00:03:36,090 --> 00:03:39,119 ‫thing to pull something down over the Internet and download 80 00:03:39,120 --> 00:03:42,419 ‫it. It's a whole other thing to one line run 81 00:03:42,750 --> 00:03:45,149 ‫a YAML file in Kubernetes. This is kind of the equivalent 82 00:03:45,540 --> 00:03:47,952 ‫of cURLing something into shell 83 00:03:48,570 --> 00:03:50,999 ‫and thus allowing it to run on your system without even 84 00:03:51,000 --> 00:03:52,739 ‫looking at the file, right. You really don't want to do 85 00:03:52,740 --> 00:03:55,319 ‫that. We don't want to be randomly running stuff and that's 86 00:03:55,320 --> 00:03:56,559 ‫kind of what Kubernetes does, right. 87 00:03:56,620 --> 00:03:59,390 ‫It runs stuff. You might want to cURL that if you have cURL 88 00:03:59,610 --> 00:04:02,660 ‫locally. If you're on a Windows PowerShell, then 89 00:04:02,850 --> 00:04:05,430 ‫you can use that command to open it up in your browser. 90 00:04:05,880 --> 00:04:08,720 ‫In the next lecture, let's start looking at YAML 91 00:04:09,180 --> 00:04:11,969 ‫formatting and how we're going to create these objects.