This guide provides a step-by-step overview of setting up Kubernetes. Whether you are a beginner or an experienced user, this guide will help you get started with Kubernetes.
Prerequisites
- A Linux machine or a virtual machine running Linux.
- Docker installed on your machine.
- Basic knowledge of Linux commands.
Install Kubernetes
Install Minikube: Minikube is a tool that makes it easy to run Kubernetes locally. You can install Minikube by following the instructions here.
Start Minikube: Once Minikube is installed, you can start it with the following command:
minikube start
Verify Installation: To verify that Kubernetes is running, use the following command:
kubectl version
Deploy an Application
Create a Deployment: Create a new deployment file named
myapp-deployment.yaml
with the following content:apiVersion: apps/v1 kind: Deployment metadata: name: myapp spec: replicas: 2 selector: matchLabels: app: myapp template: metadata: labels: app: myapp spec: containers: - name: myapp image: nginx:latest
Apply the Deployment: Apply the deployment to your cluster with the following command:
kubectl apply -f myapp-deployment.yaml
Verify Deployment: To verify that the deployment was created successfully, use the following command:
kubectl get deployments
Access the Application
Get the Service IP: Get the IP address of the service associated with the deployment with the following command:
kubectl get svc
Access the Application: Open your web browser and enter the service IP address. You should see the Nginx default page.
Conclusion
Congratulations! You have successfully set up Kubernetes and deployed an application. For more information on Kubernetes, visit the official Kubernetes documentation.