1. Prerequisites
- Linux System: This guide assumes you’re using a Linux distribution (Ubuntu/Debian examples are provided).
- Docker: Minikube uses a container runtime. Docker is a common choice—ensure it’s installed and running.
- Internet Connection: To download packages and container images.
2. Installing Kubernetes Tools
2.1 Install kubectl (Kubernetes CLI)
-
Download kubectl:
Use the following commands to download, make executable, and movekubectl
to your PATH: -
Verify Installation:
Check the client version:
2.2 Install Minikube (Local Kubernetes Cluster)
-
Download Minikube:
Download and install the latest Minikube binary: -
Verify Installation:
Check the Minikube version:
3. Starting Your Kubernetes Cluster with Minikube
-
Start the Cluster:
Launch Minikube which creates a single-node Kubernetes cluster:This command downloads necessary components and configures a local cluster.
-
Verify Cluster Status:
Check the cluster information and list nodes:
4. Deploying an Application
4.1 Create a Deployment
-
Deploy an Nginx Container:
Create a deployment that runs an Nginx container: -
Check the Deployment and Pods:
List deployments and pods to verify that your application is running:
4.2 Expose the Deployment as a Service
-
Create a Service:
Expose your deployment on port 80 by creating a NodePort service: -
List Services:
Verify the service is running: -
Access the Application:
Use Minikube’s service command to open your application in a browser:
5. Managing Your Deployment
5.1 Scaling the Deployment
- Scale Up or Down:
For example, to scale to 3 replicas:
5.2 Rolling Updates
-
Update the Deployment Image:
To update the Nginx image version: -
Monitor the Update:
Check the rollout status:
6. Using YAML Files for Declarative Configuration
6.1 Create a Deployment YAML File
-
Write a YAML File (deployment.yaml):
-
Apply the Configuration:
Create the deployment using the YAML file:
7. Monitoring and Debugging
7.1 Viewing Logs
- Check Pod Logs:
Replace<pod-name>
with the actual pod name:
7.2 Inspecting Resources
-
Describe a Pod:
Get detailed information on a pod: -
List All Resources:
See everything running in your namespace:
8. Cleaning Up
8.1 Deleting Resources
-
Remove a Deployment and Service:
Delete the Nginx deployment and its associated service: -
Stop the Minikube Cluster:
When finished, stop your local Kubernetes cluster:
Final Thoughts
-
Explore More:
Kubernetes offers many advanced features—look into ConfigMaps, Secrets, StatefulSets, DaemonSets, Ingress Controllers, and more. -
Documentation:
For a deeper dive into Kubernetes concepts and commands, visit the official Kubernetes documentation.
This tutorial covers the basics to help you get started with Kubernetes—from installation using Minikube and kubectl to deploying, scaling, and managing applications. Happy clustering!
Comments
Post a Comment