This project demonstrates how to setup a local k8s cluster (specifically on macOS) using k3d.
Make sure brew and docker is installed.
-
Install tools:
make prepare
-
Make sure Docker is already running, then deploy k3s cluster using one of following commands:
task single-node:deploy
task multi-nodes:deploy
task multi-nodes-ingress-nginx:deploy
NOTE: Kubernetes dashboard will be enabled by default.
-
Wait until the cluster reaches the Running state, then open Kubernetes dashboard and paste the bearer token into the form to login (The bearer token will be copied to clipboard automatically).
task dashboard:open
To get the bearer token, run
task dashboard:get-admin-token
-
Deploy an example app to k3s
task deploy-app -- http_echo.yaml
NOTE: The default namespace for app will be
k3s-local
and can be customized via Taskfile.yaml variableKUBE_NAMESPACE
.If you deploy the k3s cluster using
task multi-nodes-ingress-nginx:deploy
, use the below command:task deploy-app -- http_echo_ingress_nginx.yaml
-
Test app
curl --resolve k3s.local:8080:127.0.0.1 http://k3s.local:8080/
You should see this result:
hello
Le Minh Tri @ansidev.
This source code is released under the MIT License.