"Learn Kubernetes step-by-step, from installation to deploying your first application. This beginner-friendly guide simplifies Kubernetes concepts and processes."
By Abhishek Gupta
2024-12-25
Kubernetes (K8s) is a powerful open-source platform designed to automate deploying, scaling, and operating application containers. If you're new to Kubernetes, this blog will guide you step-by-step, from installation to deploying your first application.
Kubernetes is a container orchestration system that helps manage containerized applications in a clustered environment. It provides features like:
Before diving into setup, let’s understand why Kubernetes is so popular:
To use Kubernetes, you need a cluster—a set of machines (virtual or physical) where Kubernetes runs. Follow these steps:
Make sure you have the following installed:
Minikube creates a local Kubernetes cluster:
minikube start
This sets up a single-node cluster for testing and learning.
Check the cluster status:
kubectl cluster-info
kubectl get nodes
You should see your cluster and node running.
Let’s deploy a simple Nginx web server.
Create a file nginx-deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.17.10
ports:
- containerPort: 80
Apply the deployment:
kubectl apply -f nginx-deployment.yaml
Create a Service to expose Nginx:
kubectl expose deployment nginx-deployment --type=NodePort --port=80
Get the Service details:
kubectl get service
Access the application using your node’s IP and the assigned port.
Increase the number of replicas:
kubectl scale deployment nginx-deployment --replicas=4
kubectl get pods
kubectl logs <pod-name>
kubectl exec -it <pod-name> -- /bin/bash
Remove the deployment and service:
kubectl delete deployment nginx-deployment
kubectl delete service nginx-deployment
Stop Minikube:
minikube stop
Kubernetes may seem complex at first, but with practice, it becomes an indispensable tool for modern software development. Start experimenting and gradually dive into advanced topics like networking, storage, and security. Happy learning!