mdsanima-lab / k3s-kube-demo

Deploy demo apps in Lightweight Kubernetes K3s cluster

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

K3s Kube Demo

Deploying Demo Apps in Lightweight Kubernetes K3s Cluster. Checkt the official documentation how to install and configure K3s Cluster.

The Linux docker images in this repository is builded for AMD 64-bit, ARM 32-bit, and ARM 64-bit architectures. Thats allow you to run this app inside K3s Cluster on Raspberry Pi 3 and 4 nodes, nVidia Jetson Nano nodes, Ampere ARM and AMD 64-bit server nodes.

Kube Demo Apps

There is a two different application on this monorepo:

Building Multi-Arch Images

This is a monorepo contains two different application. Each app is building for multi-arch images and pushing in hub.docker.com site.

First start Docker Desktop on Windows and check our builders, type in the WSL terminal:

docker buildx ls

We are currently using the default builder. Now create a new builder, which gives us access to new multi-arch features, type in the WSL terminal:

docker buildx create --name mybuilder
docker buildx use mybuilder
docker buildx inspect --bootstrap

Here is a new builder instance with the name mybilder, switched to it, and inspected it. Now you can build multi-arch images for each application.

Example Command

This is a example command, type in the WSL terminal:

docker buildx build --platform linux/amd64,linux/arm64 -t mdsanima/app --push .

This command create multi-arch images for linux/amd64 and linux/arm64 architecture then pushing to docker hub repository.

Do not execute this command this is a only example, for each application this command is available inside apps folder on README.md files.

Debug Application

This is a documentation how to troubleshooting your application.

Get a Shell to a Running Container

Create the simple nginx pod:

kubectl run nginx-shell-demo --image=nginx

Verify that the container is running:

kubectl get pod nginx-shell-demo

Get a shell to the running container:

kubectl exec --stdin --tty nginx-shell-demo -- /bin/bash

Now you are inside the pod.

Delete the demo pod:

kubectl delete pod nginx-shell-demo

Configure Hosts Name

Edit your /etc/hosts file and add this line:

192.168.1.30 kube.mdsanima.local rpi-1.node.test hello.dev.local mdsanima.dev.local

Now you can assess at the URL like this http://kube.mdsanima.local or this http://rpi-1.node.test:31337 specific node port services. You can type anything you want.

This config may be different of any your node. Also you can change it in WSL and if you want to access browser on Windows you need to change it in other location. Open the Windows Terminal with Administrator mode on your WSL system. I use Ubuntu 22.04 LTS Jammy. Type this command nano /mnt/c/Windows/System32/drivers/etc/hosts and add your host name.

Restart Deployment

When new image is pushing to the repository you can restart the deployment:

kubectl rollout restart deploy hello-world
kubectl rollout restart deploy hello-mdsanima

After executing these commands, new images will be downloaded.

NGINX Ingress Controller

Here is a instruction guide for install the NGINX Ingress Controller from official documentation site.

You can deploy the ingress controller with the following command:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.6.4/deploy/static/provider/cloud/deploy.yaml

Now check the namespace, pods and services with short version commands:

kubectl get ns
kubectl get pod --namespace=ingress-nginx
kubectl get svc --namespace=ingress-nginx

About

Deploy demo apps in Lightweight Kubernetes K3s cluster

License:MIT License


Languages

Language:CSS 82.5%Language:TypeScript 10.4%Language:Dockerfile 5.1%Language:JavaScript 2.0%