- Basic understanding of Kubernetes
- Creating a local development environment for hands-on experience with Kubernetes
- Deploying an application to Kubernetes for the first time ever
- Playing with Kubernetes Pod autoscaling
- Docker Desktop
- minikube - For local development with Kubernetes (cross-platform)
- LENS - The Kubernetes IDE
- Helm - Kubernetes packages (charts) manager
- ab - Apache HTTP server benchmarking tool
- Windows -
choco install apache-httpd
- macOS - natively installed from BigSur 11+
- Windows -
-
Clone this repo
-
Create a Kubernetes cluster locally
minikube start --kubernetes-version=1.24.0
Note: For beginners, it's best to start from version
1.24.0
as version 1.25.0 includes breaking changes such as the removal of PSP which breaks a lot of Helm charts. -
Deploy nginx ingress controller to enable traffic from "the internet" to the cluster
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx && \ helm repo update && \ helm upgrade --namespace kube-system --install nginx ingress-nginx/ingress-nginx
-
To access the NGINX Ingress Controller from the Host machine (macOS/Windows), we need to map its domain name to
127.0.0.1
, which will listen to ports 80 and 443.- Edit the
hosts
file- macOS: Edit
/etc/hosts
with your favotire editor
sudo vim /etc/hosts
- Windows: Edit
C:\Windows\System32\drivers\etc\hosts
with Notepad or Notepad++ as Administrator
- macOS: Edit
- Add the following line
127.0.0.1 quickstart.kubemaster.me
- Edit the
-
Verify with
LENS
that the nginx-ingress-controller has an External IP127.0.0.1
- otherwise you won't be able to receive traffic from the host machine (your PC) -
Deploy the "quickstart" application - docker-cats
kubectl apply -f app.yml
-
Start minikube tunnel to allow traffic from the host machine to the Kubernetes cluster ingresses
# Execute in a separated terminal - keep it running sudo minikube tunnel
-
Test the deployment - Navigate to http://quickstart.kubemaster.me
-
(Optional) For further learning about HTTPS and authentication, see kubernetes-localdev
-
nginx-ingress-controller - deployed with Helm
-
docker-cats - deployed with kubectl
- Deployment - A Deployment provides declarative updates for Pods and ReplicaSets.
- Service - network abstraction to route traffic to the application and the ability to access the application internally in the cluster with the Service DNS record
quickstart.default.svc.local
- Ingress - An API object that manages external access to the services in a cluster, typically HTTP. Ingress may provide load balancing, SSL termination and name-based virtual hosting.
-
Deploy Kubernetes Metrics Server - need to collect metrics such as CPU and Memory of pods to autoscale
helm repo add metrics-server https://kubernetes-sigs.github.io/metrics-server/ && \ helm upgrade --namespace kube-system --install metrics-server metrics-server/metrics-server --values metrics-server-values.yml
-
Apply a Horizontal Pod Autoscaler object
kubectl apply -f hpa.yml
-
Test autoscaling with
ab
ab -k -v1 -n 100000 -c 100 -s 60 http://quickstart.kubemaster.me/
-k
- KeepAlive feature, performs multiple requests within one HTTP session. Default is no KeepAlive. If you skip this flag, you'll getTotal of 16314 requests completed
on macOS, see this Stackoverflow answer-v1
- Verbosity level-n
- Number of requests-c
- Number of parallel requests-s
- Timeout in seconds, the default is 30 seconds
-
View scaling up and down in LENS
Created and maintained by Meir Gabay
This project is licensed under the MIT License - see the LICENSE file for details