Welcome! This project is for learning Kubernetes (k8s) by doing everything manually. Below you'll find essential concepts and the most useful kubectl
commands for hands-on learning.
- Cluster: The whole Kubernetes system, made up of nodes.
- Node: A machine (virtual or physical) that runs your application workloads. A cluster has at least one node (often many).
- Pod: The smallest deployable unit in Kubernetes. A pod can hold one or more containers (usually one), and runs on a node.
- Deployment: Manages pods and ensures the right number are running at all times.
- Service: Exposes your pods to the network (internal or external), acting as a load balancer or gateway.
-
Create a new cluster:
k3d cluster create cluster-1 -p "8081:80@loadbalancer"
Uses your custom kind config to set up the cluster.
-
Install the metrics server (for HPA):
kubectl apply -f metrics-server.yaml
Enables resource metrics required for autoscaling.
-
Deploy your app and service:
kubectl apply -f deployment.yaml
Deploys the sample-app Deployment and Service.
-
Enable autoscaling with HPA:
kubectl apply -f hpa.yaml
Sets up the Horizontal Pod Autoscaler for your app.
-
(Optional) Deploy the load generator:
kubectl apply -f load-generator.yaml
Creates a pod that continuously sends requests to your app to trigger scaling.
-
(Optional) Deploy the Kubernetes Dashboard:
kubectl apply -f kubernetes-dashboard.yaml
Installs a web UI to view and manage your cluster.
kubectl proxy
kubectl port-forward -n kubernetes-dashboard service/kubernetes-dashboard 8001:443
Starts a proxy server to access the dashboard.
kubectl apply -f dashboard-admin.yaml
Grants admin permissions to the dashboard.
- (Optional) Deploy the Ingress:
kubectl apply -f ingress.yaml
Creates an Ingress resource to expose your app.
kubectl get nodes
— List all nodes in your clusterkubectl get pods
— List all pods in your clusterkubectl get deployments
— List all deploymentskubectl get services
— List all serviceskubectl get hpa
— List all Horizontal Pod Autoscalerskubectl describe pod <pod-name>
— Detailed info about a podkubectl logs <pod-name>
— Show logs from a podkubectl exec -it <pod-name> -- /bin/sh
— Open a shell inside a running podkubectl get all
— List all resources (pods, services, deployments, etc.)kubectl delete -f <file.yaml>
— Delete resources defined in a YAML filekubectl delete pod <pod-name>
— Delete a specific pod
kubectl apply -f load-generator.yaml
— Apply the load generator podkubectl exec -it load-generator -- /bin/sh
— Open a shell inside the load generator podkubectl delete -f load-generator.yaml
— Delete the load generator pod
kind delete cluster
— Delete the entire cluster and all resources
Happy learning! Add more commands or notes here as you progress.
- Always check the status of your resources with
kubectl get ...
. - Use
kubectl describe ...
for detailed troubleshooting. - Clean up with
kubectl delete ...
to avoid resource clutter.
- Access the dashboard at
https://localhost:8001
- Use the token from
kubectl -n kubernetes-dashboard create token admin-user