⎈ k8s knowledge compiler

Using kubectl to Create a Deployment [page]deterministic

tutorials

##

* Learn about application Deployments. * Deploy your first app on Kubernetes with kubectl.

##

The shell commands in this tutorial use POSIX shell syntax, which is supported by the default shells on most Linux and macOS systems (for example, bash, zsh, or sh). Windows users must use a POSIX-compatible shell such as [Windows Subsystem for Linux (WSL)](https://learn.microsoft.com/en-us/windows/wsl/install) or [Git Bash](https://gitforwindows.org/) to run the commands as written. Commands that use `export`, `$()`, and similar constructs are not compatible with PowerShell or the Windows Command Prompt.

## Kubernetes Deployments

_A Deployment is responsible for creating and updating instances of your application._

This tutorial uses a container that requires the AMD64 architecture. If you are using minikube on a computer with a different CPU architecture, you could try using minikube with a driver that can emulate AMD64. For example, the Docker Desktop driver can do this.

Once you have a [running Kubernetes cluster](/docs/tutorials/kubernetes-basics/create-cluster/cluster-intro/), you can deploy your containerized applications on top of it. To do so, you create a Kubernetes Deployment. The Deployment instructs Kubernetes how to create and update instances of your application. Once you've created a Deployment, the Kubernetes control plane schedules the application instances included in that Deployment to run on individual Nodes in the cluster.

Once the application instances are created, a Kubernetes Deployment controller continuously monitors those instances. If the Node hosting an instance goes down or is deleted, the Deployment controller replaces the instance with an instance on another Node in the cluster. **This provides a self-healing mechanism to address machine failure or maintenance.**

In a pre-orchestration world, installation scripts would often be used to start applications, but they did not allow recovery from machine failure. By both creating your application instances and keeping them running across Nodes, Kubernetes Deployments provide a fundamentally different approach to application management.

## Deploying your first app on Kubernetes

_Applications need to be packaged into one of the supported container formats in order to be deployed on Kubernetes._

![](/docs/tutorials/kubernetes-basics/public/images/module_02_first_app.svg)

You can create and manage a Deployment by using the Kubernetes command line interface, [kubectl](/docs/reference/kubectl/). `kubectl` uses the Kubernetes API to interact with the cluster. In this module, you'll learn the most common `kubectl` commands needed to create Deployments that run your applications on a Kubernetes cluster.

When you create a Deployment, you'll need to specify the container image for your application and the number of replicas that you want to run. You can change that information later by updating your Deployment; [Module 5](/docs/tutorials/kubernetes-basics/scale/scale-intro/) and [Module 6](/docs/tutorials/kubernetes-basics/update/update-intro/) of the bootcamp discuss how you can scale and update your Deployments.

For your first Deployment, you'll use a hello-node application packaged in a Docker container that uses NGINX to echo back all the requests. (If you didn't already try creating a hello-node application and deploying it using a container, you can do that first by following the instructions from the [Hello Minikube tutorial](/docs/tutorials/hello-minikube/).)

You will need to have installed kubectl as well. If you need to install it, visit [install tools](/docs/tasks/tools/#kubectl).

Now that you know what Deployments are, let's deploy our first app!

### kubectl basics

The common format of a kubectl command is: `kubectl action resource`.

This performs the specified _action_ (like `create`, `describe` or `delete`) on the specified _resource_ (like `node` or `deployment`. You can use `--help` after the subcommand to get …(trimmed)

Sources

tutorials/kubernetes-basics/deploy-app/deploy-intro.md · docUsing kubectl to Create a Deployment

Related (9)

part_of {{% heading "objectives" %}}describes conf=1
part_of {{% heading "prerequisites" %}}describes conf=1
part_of Kubernetes Deploymentsdescribes conf=1
part_of Deploying your first app on Kubernetesdescribes conf=1
part_of {{% heading "whatsnext" %}}describes conf=1
part_of kubectl basicsdescribes conf=1
part_of Deploy an appdescribes conf=1
part_of View the appdescribes conf=1
api_for Deploymentdocuments API object conf=1

← all Docs