Practical Usage
Basic Cluster Management
Starting and Stopping Cluster
## Start Minikube cluster
minikube start
## Stop Minikube cluster
minikube stop
## Delete Minikube cluster
minikube delete
Kubernetes Cluster Interaction
Checking Cluster Status
## View cluster information
kubectl cluster-info
## List nodes
kubectl get nodes
## Check Minikube status
minikube status
Deployment Workflows
Creating a Simple Deployment
## Deploy nginx application
kubectl create deployment nginx-demo --image=nginx
## Expose deployment as a service
kubectl expose deployment nginx-demo --port=80 --type=NodePort
Service Management
Service Types
Service Type |
Description |
Use Case |
ClusterIP |
Internal access |
Microservices communication |
NodePort |
External access |
Development and testing |
LoadBalancer |
External access |
Production environments |
Advanced Networking
graph TD
A[Minikube Cluster] --> B[Internal Network]
B --> C[Pod Network]
B --> D[Service Network]
C --> E[Container Networking]
D --> F[Service Discovery]
Accessing Applications
## Get service URL
minikube service nginx-demo --url
## Open service in browser
minikube service nginx-demo
Resource Management
Scaling Deployments
## Scale deployment
kubectl scale deployment nginx-demo --replicas=3
## View deployment details
kubectl get deployments
Addon Management
## List available addons
minikube addons list
## Enable specific addon
minikube addons enable dashboard
## Disable addon
minikube addons disable dashboard
Persistent Storage
Creating Persistent Volumes
## Create persistent volume claim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: example-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
Debugging and Logging
## View pod logs
kubectl logs <pod-name>
## Execute commands in pod
kubectl exec -it <pod-name> -- /bin/bash
## Port forwarding
kubectl port-forward <pod-name> 8080:80
LabEx Practical Scenarios
LabEx provides comprehensive hands-on labs to practice Kubernetes concepts using Minikube, helping developers gain practical experience.
Best Practices
- Use declarative configuration
- Implement resource limits
- Practice continuous learning
- Utilize Minikube for local development
Common Use Cases
- Local development
- Continuous Integration testing
- Learning Kubernetes concepts
- Prototype application deployment
## Limit resource consumption
minikube start --cpus=2 --memory=4096
Monitoring and Observability
## Enable metrics server
minikube addons enable metrics-server
## View resource usage
kubectl top nodes
kubectl top pods