Getting Started with Container Orchestration Using Kubernetes and Docker Desktop
- Sharon Rajendra Manmothe

- Sep 9
- 3 min read
Container orchestration has become essential in modern software development. It helps developers manage containerized applications effectively and ensures they run smoothly. One of the leading tools in this realm is Kubernetes, a powerful, open-source platform for orchestrating containers. In this guide, we will walk you through the process of getting started with Kubernetes using Docker Desktop, enabling you to deploy and manage your applications efficiently.
What is Kubernetes?
Kubernetes, often shortened to K8s, is a robust container orchestration tool. It automates tasks like deploying, scaling, and managing containerized applications. Kubernetes is designed to run distributed systems reliably, allowing developers to focus on coding rather than server management.
Some key features of Kubernetes include:
Self-Healing: Kubernetes automatically replaces or restarts containers that fail.
Load Balancing: It distributes traffic among multiple container instances for better performance.
Automated Rollouts and Rollbacks: Kubernetes can manage updates and scale back if needed.
For instance, companies like Spotify have successfully leveraged Kubernetes to manage container deployments, improving their resource usage by an impressive 30%.
Step 1: Enable Kubernetes in Docker Desktop
To start using Kubernetes, you need to enable it in Docker Desktop. Here’s how you can do that:
Open Docker Desktop.
Go to Settings → Kubernetes.
Check Enable Kubernetes.
Click Apply & Restart.
Wait for Docker Desktop to show that Kubernetes is running, indicated by a green status.
To confirm that Kubernetes has been set up correctly, enter the following commands in your terminal:
```bash
kubectl cluster-info
kubectl get nodes
```
You should see one node named `docker-desktop`.
Step 2: Build and Push Your Docker Image
Kubernetes requires a Docker image to deploy your application. To build and push your Docker image to Docker Hub, follow these steps:
Build your image, changing `my-flask-app` to your application name:
```bash
docker build -t my-flask-app:v1 .
```
Tag the image with your Docker Hub username:
```bash
docker tag my-flask-app:v1 your-dockerhub-username/my-flask-app:v1
```
Log in to Docker Hub and push your image:
```bash
docker login
docker push your-dockerhub-username/my-flask-app:v1
```
In the past year, Docker Hub reported over 13 billion pulls of container images, emphasizing the critical role of container images for developers.
Step 3: Create Deployment YAML
Next, create the deployment configuration file for your application. Set up a folder named `k8s-manifests/` and create a file called `web-deployment.yaml` with this content:
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-app-deployment
labels:
app: web-app
spec:
replicas: 2
selector:
matchLabels:
app: web-app
template:
metadata:
labels:
app: web-app
spec:
containers:
- name: web-app-container
image: your-dockerhub-username/my-flask-app:v1 # replace with your image
ports:
- containerPort: 5000 # replace with your app’s port
```
This configuration defines a deployment that runs two instances (replicas) of your application, enhancing availability and reliability.
Step 4: Create Service YAML
To access your application from a web browser, create a service. Inside the same folder, create a file named `web-service.yaml` with this content:
```yaml
apiVersion: v1
kind: Service
metadata:
name: web-app-service
spec:
selector:
app: web-app
ports:
- protocol: TCP
port: 80
targetPort: 5000 # must match containerPort
type: LoadBalancer
```
This service configuration allows external traffic to reach your application. With Kubernetes, you can simplify your networking complexities, avoiding issues that arise from managing multiple endpoints directly.
Step 5: Apply Deployment & Service
Now that your deployment and service configurations are ready, apply them using these commands:
```bash
kubectl apply -f k8s-manifests/web-deployment.yaml
kubectl apply -f k8s-manifests/web-service.yaml
```
To check the status of your deployment and service, run:
```bash
kubectl get pods
kubectl get svc
```
You should see two pods running from your deployment and a service of type LoadBalancer with a cluster IP.
Step 6: Access the App
Once your application is deployed, you can access it via the service you created. If you are using Docker Desktop, simply navigate to `http://localhost` in your web browser.

Wrapping Up
Kubernetes is an impressive tool for managing containerized applications, and with Docker Desktop, getting started is more accessible than ever. The steps outlined in this guide empower you to deploy applications swiftly and manage them effectively.
As you explore Kubernetes further, you can delve into features such as scaling applications up or down, monitoring resource usage, and managing stateful applications. Embracing container orchestration can significantly enhance your development workflow.

By starting with Kubernetes, you take a proactive step toward making your applications more resilient and scalable. Happy coding!


$50
Product Title
Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button

$50
Product Title
Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button.

$50
Product Title
Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button.



Comments