Create a Deployment on Kubernetes
Abisola Adesegun
Posted on September 26, 2024
Table of Contents
Step 1: Install Prerequisites
Step 2: Start Minikube
Step 3: Create an Nginx Deployment
Step 4: Expose the Deployment (Optional)
Step 5: View the Deployment in a Browser
Step 6: Access the Kubernetes Dashboard
Kubernetes also known as K8s, is an open source system for automating deployment, scaling, and management of containerized applications. Modern applications are increasingly built using containers, which are microservices packaged with their dependencies and configurations.
Kubernetes (pronounced “koo-ber-net-ees”) is open-source software for deploying and managing those containers at scale—and it’s also the Greek word for helmsmen of a ship or pilot. Build, deliver, and scale containerized apps faster with Kubernetes.
Here’s a step-by-step guide to create an Nginx deployment on Kubernetes using Minikube and Kubectl, and view it in your browser.
Step 1: Install Prerequisites
Install Docker Desktop:
Download the latest release of Docker Desktop from the official site.
Install Minikube:
Download the Minikube installer from the Minikube releases page.
Step 2: Start Minikube
Open a command prompt or PowerShell as an administrator.
To start Minikube:
Copy code
minikube start
This command starts a local Kubernetes cluster using Docker.
Step 3: Create an Nginx Deployment
Create a deployment using Kubectl
kubectl create deployment nginx --image=nginx
Verify the Deployment
- You can check the status of your deployment by running below code.
kubectl get deployments
- To view the running pods:
Copy code
kubectl get pods
You should see 3 pods for the NGINX deployment.
Step 4: Expose the Deployment (Optional)
If you want to expose your deployment via a service (e.g., to access it from outside the cluster), you can use the following command to create a service of type LoadBalancer or NodePort:
Copy code
kubectl expose deployment nginx --type=NodePort --port=80
- To view all services:
Copy code
kubectl get service
This will expose the deployment and allow traffic to reach your NGINX pods.
Step 5: View the Deployment in a Browser
- Get the URL for the service:
Copy code
minikube service nginx --url
- Open the provided URL in your web browser to see the Nginx welcome page.
Step 6: Access the Kubernetes Dashboard
- Start the Kubernetes dashboard:
Copy code
minikube dashboard
This command will open the Kubernetes dashboard in your default web browser, where you can explore your cluster and manage resources.
View pod
I just successfully set up a local Kubernetes cluster, deployed an Nginx application, and viewed it in my browser.
Posted on September 26, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.