1. Choose Infra
Steps to choose and setup the required infrastructure/environment for deployment
Click on the relevant environment option (local machine/VM/Cloud AWS)below to start with the setup. Before proceeding with the setup, make sure to check the hardware requirement of the selected environment.
Pre-requisites
- Linux distribution running in a VM or bare metal
- Install
curl
,wget
git
, andtar
(if they're not already installed):sudo apt-get install curl git wget tar
- Open terminal and Install k3d(v4.4.8) on Linux using the below command
wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=v4.4.8 bash
- OSX or Mac
- Install k3d on Mac, on terminal use curl command
brew install curlcurl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | TAG=v4.4.8 bash
- Windows 10 or above
- Admin access to follow the steps
- Docker Desktop for windows need to be installed ( make sure wsl is installed to run Docker Desktop )
Ensure that the docker is running and you have the admin privileges for the device. Run the following in the terminal/command prompt.
Note: Make sure the k3d is already installed as part of the pre-requisites.
Start with the setup of the lightweight Kubernetes cluster on your local machine/VM. Execute all the instructions as admin/root/sudoer to give the installer full access to provision the required system resources/folders etc.
- 1.Create the "Kube" directory in the desired place (ensure you use the right dir path if it is different from the example) and change permission. This is used as k3d cluster persistent storage to store metadata and container logs.
- For Linux/Mac
- 1.cd ~mkdir kubechmod 777 kubecd kubepwd #copy the path you get here. Provide an absolute path to below k3d cmd, by replacing "/home/<user_name>/kube" with your directory path
- For Windows
- 1.cd D:\mkdir kubewsl chmod -R 777 kubecd kubepwd #copy the path you get here. Provide an absolute path to below k3d cmd, by replacing "/home/<user_name>/kube" with your directory path
- 2.Create a k3d cluster with a single master node and 2 agents (Worker Nodes) and mount the above-created directory (for data persistence). Here's where it stores all the metadata and persists the logs of the workloads.
- k3d cluster create --k3s-server-arg "--no-deploy=traefik" --agents 2 -v "/home/<user_name>/kube:/kube@agent[0,1]" -v "/home/<user_name>/kube:/kube@server[0]" --port "80:80@loadbalancer"
NOTE: Update "/home/<user_name>/kube" path in the above cmd with your respective absolute path. - 3.Once the cluster creation is successful, get the kubeconfig file, that enables you to connect to the cluster.
- k3d kubeconfig get k3s-default > myk3dconfigexport KUBECONFIG=<path-to-your-kube_config>
- kubectl config use-context k3d-k3s-default --kubeconfig=myk3dconfig
- 4.Verify the cluster creation by running the following commands from your local machine where the kubectl is installed. It provides the sample output as below if everything works fine.
- kubectl cluster-info
OutPut
Kubernetes control plane is running at https://0.0.0.0:33931CoreDNS is running at https://0.0.0.0:33931/api/v1/namespaces/kube-system/services/kube-dns:dns/proxyMetrics-server is running at https://0.0.0.0:33931/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy - k3d cluster list
OutPut
NAME SERVERS AGENTS LOADBALANCERk3s-default 1/1 2/2 true - kubectl get nodes
OutPut
NAME STATUS ROLES AGE VERSIONk3d-k3s-default-agent-0 Ready <none> 3d18h v1.21.1+k3s1k3d-k3s-default-agent-1 Ready <none> 3d18h v1.21.1+k3s1k3d-k3s-default-server-0 Ready control-plane,master 3d18h v1.21.1+k3s1 - kubectl top nodes
OutPut
W0625 07:56:24.588781 12810 top_node.go:119] Using json format to get metrics. Next release will switch to protocol-buffers, switch early by passing --use-protocol-buffers flagNAME CPU(cores) CPU% MEMORY(bytes) MEMORY%k3d-k3s-default-agent-0 547m 6% 1505Mi 9%k3d-k3s-default-agent-1 40m 0% 2175Mi 13%k3d-k3s-default-server-0 59m 0% 2286Mi 14%