Create a Kubernetes Deployment On Docker Desktop

This article will show you how to interact with the Kubernetes API by creating Kubernetes deployments using a YAML file and deploy it on the Docker Desktop Kubernetes engine.

Kubernetes API and YAML Refrence

The Kubernetes API is a REST API that can create, configure and manage Kubernetes clusters. It’s most commonly used by the Kubernetes client (kubectl), which interacts with your Kubernetes cluster.

The Kubernetes API  defines how to create containers or configure Kubernetes components like Kubernetes nodes. It uses various resources, like pods to deploy containers and replication controllers to run multiple instances of something (like a pod).

The Kubernetes API is the primary interface for Kubernetes clusters. This interface can be used by programs including kubectl, Kubernetes Dashboard and Kubernetes monitoring tools. Kubernetes can be used to deploy containers across a cluster of virtual machines or bare-metal deployments. Kubernetes manages the Kubernetes nodes that are running in your cluster.

YAML Deployment

An effective way to deploy an application into Kubernetes is using the Kubernetes YAML deployment. Below is an example of a deployment we use to deploy to our Docker desktop Kubernetes engine.

The YAML file configuration is taken from the Kubernetes API, which offers many configuration options. To add more configuration features, review the API and add settings as needed.

Below is a simple deployment that takes a Docker image I have built With a Dockerfile. You could also use a public image like nginx.

Update: To simplify things, I have added the ASP.NET Core image to the code so it can work on any machine,

apiVersion: apps/v1
kind: Deployment
  name: myapp
      run: myapp
  replicas: 2
        run: myapp
      - name: myapp
        - containerPort: 80

Save and Run

To deploy the deployment, save the file as deployment.yaml and, using a command terminal open the folder the file is located and run the following command to deploy.

kubectl apply -f deplyment.yaml

To check the deployment run and make sure it is running run.

kubectl describe deployment strong-pass-app

Clean up

To clean up and delete the deployment, run this command.

kubectl delete deployment strong-pass-app


The above example showed you how to get started and deploy a simple application to Kubernetes on Docker Desktop. Using Docker Desktop for testing Kubernetes compared to a public cloud deployment has a significant advantage, with the main one is cost.






One response to “Create a Kubernetes Deployment On Docker Desktop”

  1. […] blog post will continue from the previous post on this topic where we created a deployment, and now we will publish it and make it available from the Docker […]