You know how it is, you want to explain Kubernetes to someone and you need an application to play with.
K8sDisturber is such an application.
K8sDisturber is a simple application bases on .NET 8 and React. It includes the following functions:
- Demonstration of health check with livez and readyz endpoints
- The behavior when memory and cpu limits are set
- Load test example for the load balancer
- Access to the environment variables
- Postresql database
- PGAdmin support (UI for your database)
- Hostname, IP adresses, Instance name, UserId, ...
Never operate the K8sDisturber in a public cloud!
Access to this application is not protected.
We use default passwords for everything, a lot of role * and other nasty stuff.
The operation of the K8sDisturber is for demonstration purposes only.I warned you 🙈 🙉 🙊 ;-)
Deploy to Kubernetes:
kubectl apply -f https://raw.githubusercontent.com/marklechtermann/k8sdisturber/master/kubernetes/k8sdisturber.yaml
Access without Ingress Controller:
kubectl port-forward service/k8sdisturber -n k8sdisturber 8080:8080
Got to this URL:
http://localhost:8080/
Acces with a Ingress Controller:
Got to this URL:
http://disturber.127.0.0.1.nip.io/
If you want, then you can also use a database. On the route http://pdadmin.127.0.0.1.nip.io/ you can see how your backend communicates with a database.
For this, you need to load another Kubernetes manifest into your cluster.
kubectl apply -f https://raw.githubusercontent.com/marklechtermann/k8sdisturber/master/kubernetes/database.yaml
You can access the PGAdmin4 if your want:
http://pdadmin.127.0.0.1.nip.io/
User: admin@example.org
Pass: password
You can install a Kubernetes dashboard if you want:
kubectl apply -f https://raw.githubusercontent.com/marklechtermann/k8sdisturber/master/kubernetes/dashboard.yaml
curl -s https://raw.githubusercontent.com/marklechtermann/k8sdisturber/master/kubernetes/login.sh | sh
An easy way to install K8s is the WSL2.
https://docs.microsoft.com/en-us/windows/wsl/install
If you have Ubuntu installed, then you can very easily install Docker in minikube.
sudo apt-get remove docker docker-engine docker.io containerd runc && \
sudo apt-get update && \
sudo apt-get install ca-certificates curl gnupg lsb-release && \
sudo mkdir -p /etc/apt/keyrings && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --yes --dearmor -o /etc/apt/keyrings/docker.gpg && \
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null && \
sudo apt-get update && \
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin && \
sudo usermod -aG docker $USER && \
newgrp docker
The WSL did not start Docker automatically.
sudo service docker start
Check if Docker is running:
docker run hello-world
Now you can install minikube:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
kubectl get nodes
Enable the ingress controller addon:
minikube addons enable ingress
Enable a tunnel to your local cluster:
minikube tunnel
Do not close this terminal as this process must stay alive for the tunnel to be accessible The command "minikube tunnel" asks the user for a password. Unfortunately this is not always displayed correctly by minikube. So please pay attention to the output of the following text "[sudo] password for user:".
K9s is a terminal based UI to interact with your Kubernetes clusters. The aim of this project is to make it easier to navigate, observe and manage your deployed applications in the wild. K9s continually watches Kubernetes for changes and offers subsequent commands to interact with your observed resources.
mkdir k9s && \
curl -L -o k9s/k9s.tgz https://github.com/derailed/k9s/releases/download/$(curl -s https://api.github.com/repos/derailed/k9s/releases/latest | grep tag_name | cut -d '"' -f 4)/k9s_Linux_x86_64.tar.gz && \
tar -xzf k9s/k9s.tgz -C k9s && \
sudo install k9s/k9s /usr/local/bin && \
rm -rf k9s
READINESSDELAY
Sets the http://localhost/api/readyz
to true
after a defined time (milliseconds).
Default: 0
LIVENESSSDELAY
Sets the http://localhost/api/livez
to true
after a defined time (milliseconds).
Default: 0
DBHOSTNAME
The postgresql database hostname.
Default: postgresql
DBUSER
The postgresql database user.
Default: postgres
DBNAME
The postgresql database name.
Default: k8sdisturber
DBPASSWORD
The postgresql database name password.
Default: password
Here you can find information for developers.
scripts/start-local-database.sh
If you run the postgresql database in Kubernetes, you can forward the ports to localhost.
kubectl port-forward pod/postgresql-0 -n k8sdisturber 5432:5432
Connect to the database from your local machine with the psql client:
psql -h localhost -p 5432 -U postgres