How to Install and Use K3D
Getting Started
I have discovered K3D a bit late but it is one of the best tools for local Kubernetes development It does not run your Kubernetes cluster inside a virtual machine just like Minikube does. It uses Docker and allows you to create multi-node clusters. You may want to check their official page for more information.
I created a sample project to install and configure K3D for my local Kubernetes development and also added some sample deployments with ingress service.
Prerequisites
Docker and Helm need to be installed in your local development environment. Please do not proceed with the installation before installing Docker and Helm.
Installation
I followed the official documentation to installK3D
on my local development environment but made a few changes. I skipped the deployment of Traefik because K3D
install V1 and I wanted to install the latest version of Traefik
. You can also prefer another ingress controller like nginx
.
You can install the environment by running a single script - deploy-cluster.sh
and the script itself is quite self-explanatory:
You may want to change the global variables for your own environment. Once the script is running you can check the Traefik Dashboard by visiting http://localhost:9000/dashboard/#/.
Example Deployment
You can check one of the example deployments in the main project directory and apply it via kubectl apply -f <sample-directory>
command. If you do not edit anything in the YAML
definitions, it will create a host-based ingress rule for the deployment. If you check the Traefik HTTP services, you will find your rule as below:
Please note that if you want to use the host-based ingress rule, you will have to add the FQDN to your /etc/hosts file.
Example deployment output will look like this:
Last updated