Deploying workloads in Kubernetes is easy. We will use kubectl to specify the resources to be created and interact with kube-apiserver.
As mentioned earlier, we can use the command line to either use built-in generators or YAML files. Depending on the Kubernetes API version, some options may not be available, but we will assume Kubernetes 1.11 or higher.
In this chapter, all examples use Kubernetes 1.14 because it is the version available on the current Docker Enterprise release, 3.0, at the time of writing this book.
Let's start by creating a simple pod. We will review both options—imperative, using the command-line, and declarative, using YAML manifests.
Using the pod generator, we will run the kubectl run --generator=run-pod/v1 command:
$ kubectl run --generator=run-pod/v1 --image=nginx:alpine myfirstpod --labels=example=myfirstpod
pod/myfirstpod created
Using a YAML definition file, we will describe all of the required properties of the...