In this video, we’ll talk about the Kubernetes CLI, which is called "kubectl." The internet is full of debates about how to pronounce this word. We’ve gone with the canonical pronunciation provided by the Cloud Native Computing Foundation, but know that you might hear a lot of different pronunciations. When you work with Kubernetes, one of the key tools you need to familiarize yourself with is the Kubernetes CLI, called "kubectl." This tool provides a wide range of functionality for working with Kubernetes clusters and managing the workloads that run in a cluster. It will become your best friend as you become a Kubernetes expert. There are many different types of commands available with kubectl, but let’s first discuss two key types of commands: "imperative" and "declarative." Imperative commands enable users to quickly create, update, and delete Kubernetes objects. Imperative commands are easiest to learn and therefore present the lowest barrier to entry. For example, to create a Pod that runs a specific container—in this case, "nginx"–, you can simply run the “kubectl run nginx --image nginx” command. This command is simple to write and understand because it only contains a name and the image that should be run as a container. However, it doesn’t provide an audit trail, which is important in clusters so that operators can know what changes are made. It's also not very flexible: the options are limited, and additional commands must be run to expose the Deployment as an externally available service, for example. So you could have one developer run a "kubectl run" command, which would create a Pod that runs an application. Another developer on the team might want to deploy that application again. But how does she know how to deploy the application? There is no configuration file stored in a repository anywhere. The second developer would need to ask the first developer for the exact command he ran, and she would need to ensure that she ran it in the exact same way. What we need is a template that both developers can use to deploy their application. And as a matter of fact, there are imperative commands that possess a template; this is known as "imperative object configuration." In this model, a file contains the configuration template, and the command specifies an operation such as create, replace, or delete. [Advance slide to show second kubectl command] For example, this second command specifies a YAML file that contains the object configuration, and it specifies that this object should be created. This is an improvement over basic imperative commands because the configuration template makes replicating the changes much simpler. All the configuration is available in the file, so it's easy to perform this operation multiple times or in multiple environments. Using our previous example, both developers can now refer to a configuration file to ensure that they are deploying the same thing into their respective environments. However, specifying the operation is a limitation of this model. If, for example, the first developer performs an update operation, that will manipulate the existing object. But if that update isn’t merged into the object’s configuration file, then the second developer won’t be able to use that new configuration when she subsequently deploys the application. She will instead use the old configuration. A better option is to define a desired state in that shared configuration file, and when that file is applied, have Kubernetes determine which operations need to occur. In fact, this is what declarative commands do. Declarative resource management is the most advanced and powerful form of command available in kubectl. In this model, configuration files are still used to hold the configuration for an object or several objects. But in this case, the operation is not specified by the user. Rather, the needed operations are detected by kubectl. Changes can be made to one file or set of files, and the "apply" command can be used to realize the necessary changes. Regardless of whether what's needed is to create new objects or update existing objects, the user doesn’t need to know. By applying the configuration files, Kubernetes takes care of the needed work to actualize the state specified in the files. In addition, declarative object configuration commands work better on directories, whereas imperative object configuration commands work better on files. In this case, the first developer can make several updates to the running application. But since he is storing the new configuration in the shared configuration file, there is still one source of truth for the configuration for this object. Now even if the second developer missed several of these updates, she only has to apply the current configuration file and she will be sure that the deployed object is as expected. Kubernetes will determine which operations must occur to take her cluster’s current state to the desired state, even though she might have missed several intermediate steps taken by the first developer along the way. Here you can see a basic "kubectl apply" command acting on a directory. All files in that directory will be applied, and all necessary changes will be realized in the system. The user doesn’t even need to know what those changes are. Do any nginx Deployments exist already? It doesn’t matter. Hopefully, an operations person will know the current state and the desired changes just so they're aware of what’s going on in the system they're administering. But the point is that those changes don’t need to be explicitly stated by the people creating the configuration objects. Performing an "apply" command will make the relevant changes automatically. This is the preferred method for production systems. Imperative commands can be useful during development, but they're not recommended for production systems. In the rest of this course, we will rely extensively on declarative commands. You should now be familiar with the kubectl CLI, one of the most important tools for interacting with a Kubernetes cluster. You should also know a few basic commands, but it's more important at this point to understand the different types of commands offered by kubectl—both imperative and declarative commands—and the relative benefits and shortcomings of each. In the next video, we’ll look at some specific kubectl commands and how to use them in practice.