This repository helps you create a kubernetes cluster locally with k3s using Docker
and traefik
.
Also it contains all useful utils to manage kubernetes cluster like kubectl
, helm
and more
- git
- docker
- docker compose
- make
If you already have an installed traefik you can skip this step
First, install traefik stack from this repository https://github.com/devgine/traefik
git clone git@github.com:devgine/k3s-in-docker.git
make run
Enjoy ! 🥳
To manage kubernetes resources in the cluster, you can connect to the k8s container and run kubectl or helm commands.
This container contains the necessary tools to manage kubernetes cluster.
make shell
Below is an example to install nginx. You should run it inside the k8s container.
kubectl apply -f 00-nginx.yaml
Visit http://nginx.k3s.localhost
By default, traefik is installed as an ingress reverse proxy, if you want to allow ingress nginx follow the following instructions
make shell
kubectl create ns ingress-nginx
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm install ingress-nginx ingress-nginx/ingress-nginx -n ingress-nginx
Router >> *.k3s.localhost >> Docker Traefik >> K3S container >> Ingress (traefik OR nginx) >> Service
Node | Directory | Description |
---|---|---|
Server | /output | k3s will generate a kubeconfig.yaml in this directory. |
Server | /var/lib/rancher/k3s/server/manifests | This directory is where you put all the (yaml) configuration files of the Kubernetes resources. |
Agent | /var/lib/rancher/k3s/agent/images | this is where you would place an alternative traefik image (saved as a .tar file with'docker save'), if you want to use it, instead of the traefik:v3.1 image. |
https://github.com/its-knowledge-sharing/K3S-Demo/blob/production/docker-compose.yaml
https://docs.k3s.io/cli/server
https://thenets.org/how-to-create-a-k3s-cluster-with-nginx-ingress-controller/
https://blog.stephane-robert.info/post/homelab-ingress-k3s-certificats-self-signed/
https://github.com/its-knowledge-sharing/K3S-Demo-Addons
owncloud/docs-ocis#716
https://learn.microsoft.com/en-us/azure/aks/coredns-custom#hosts-plugin