Awesome
Kubernetes Local Cluster with Kind, Terraform and Kftray Annotations
<a href="https://github.com/hcavarsan/kftray"> <img src="https://raw.githubusercontent.com/hcavarsan/kftray-blog/175ab7b009619f33dd5224f10e110bd5d55c0504/public/img/auto-import.gif" alt="KFtray Demo" width="600"> </a>Overview
This project provides a simple way to build a Kubernetes (k8s) cluster. It automates the bootstrap process for a local k8s cluster and uses Kind (Kubernetes IN Docker), Terraform
, and Helm to set up ArgoCD
, Prometheus
, Alertmanager
, Grafana
, Jaeger
and `Meshery. Additionally, it automatically configures kubectl port forwarding via Kftray based on service annotations.
Why?
In some cases, there is no need of Ingress controllers or exposed services with NodePort/LoadBalancer, What happens in this setup is that everything stays inside the cluster, thus making the environment safer and simpler. All external traffic is tunneled through kubectl port-forward on localhost via kftray.
Bootstrapping the stack
Before you begin, make sure you have these installed on your computer:
- Docker
- Terraform (v1.9.5)
- Kftray - you can choose beetwen kftray (GUI) or kftui (TUI)
1. Terraform
To bootstrap all the k8s cluster stack, just clone this repository and run terrarform:
git clone https://github.com/hcavarsan/kftray-k8s-tf-example
cd kftray-k8s-tf-example/terraform
make apply
2. Install Kftray
Access the Kftray GitHub page and follow the installation instructions.
3. Import kubectl port-forward configurations in kftray
Once 'terraform apply' finishes, follow these steps:
- Open Kftray and click the tray icon to open the main window.
- Click the menu icon in the bottom left corner.
- Select "Auto Import".
- Click "Set kubeconfig" and choose the kubeconfig file created by Terraform (like
~/.kube/kind-config-kftray-cluster
). - Select the right context (e.g.,
kftray-cluster
) from the dropdown. - Click "Import" to load the port forwarding settings automatically.
After importing, you can start port forwarding by toggling the switch next to each service in Kftray or simply click "Start All" to forward everything at once.
<a href="https://github.com/hcavarsan/kftray"> <img src="docs/kftray.gif" alt="KFtray Import"> </a>Or, you can do the same in kftui if you prefer a terminal user interface:
- Export the KUBECONFIG environment variable and start kftui:
KUBECONFIG="~/.kube/kind-config-kftray-cluster" kftui
- Press Tab to access the top menu and select
Auto Import
- Select all configs by pressing Ctrl+A.
- Press F to start all port forwards.
4. Access Your Services
With Kftray managing the port forwarding, you can access your services locally at the following URLs:
- Argo CD: http://localhost:16080
- Prometheus: http://localhost:19090
- Alertmanager: http://localhost:19090
- Grafana: http://localhost:13080
- Jaeger: http://localhost:15090
- Meshery: http://localhost:9081
Customizing the Kuberentes cluster and KFTray settings
Cluster Settings
You can customize the cluster settings by editing the variables.tf
file. For example, if you want to change the cluster name or Kubernetes version, just update file:
variable "cluster_name" {
description = "Name of the Kind cluster"
type = string
default = "kftray-cluster"
}
variable "kubernetes_version" {
description = "Version of the Kind node image"
type = string
default = "v1.30.4"
}
Service Versions
If you need different versions of the services, you can update them in the variables.tf
file as well. For example, to change the Argo CD version:
variable "argocd_chart_version" {
description = "Argo CD Helm chart version"
type = string
default = "5.19.12"
}
Do the same for Prometheus, Grafana, and Jaeger if needed.
Kftray Port Forwarding
You can customize how ports are forwarded by editing the locals.tf
file:
locals {
services = {
argocd = {
kftray = {
server = {
alias = "argocd"
local_port = "16080"
target_port = "http"
}
}
}
}
}
- alias: The name you see in Kftray.
- local_port: The port on your computer to access the service.
- target_port: The service’s port or port name.