- Local Kubernetes Environment
- Install Docker
- Install Visual Studio Code
- Install Visual Studio Code Dev Containers Extension
- Install Lens or OpenLens
Open this repo's folder in VSCode, it might immediately propose you to re-open it in a Dev Container or you can click on Remote Explorer, find plus button and choose the Open Current Folder in Container option and wait when it is ready.
When your Dev Container is ready, the VS Code window will be re-opened. Open a new terminal in this Dev Container which will be executing the commands under this prepared Linux container where we have already pre-installed and pre-configured:
- Docker Outside of Docker aka Docker from Docker to be able to use host's docker daemon from inside the container
- kind to create a k8s cluster locally in Docker
- kubectl to call k8s cluster from CLI (bypassing Lens)
- helm, helmfile to deploy all services helm charts at once to the local k8s cluster created with
kind - helm-diff show nicely what has changed since the last
helmfile apply
Note: You don't need to install these packages in your OS, these are part of the Dev Container already. Thus, it is a clean way to run the stack for any host OS.
To create a new cluster where you will work execute the following command once:
kind create cluster --name inner-circle --config kind-local-config.yaml --kubeconfig ./.inner-circle-cluster-kubeconfig- In Docker Desktop, go to settings (the gear on the top left);
- Select Kubernetes in the settings on the right;
- Turn on Kubernetes;
- Apply the settings with the “Apply & restart” button;
- Create
.to-dos-cluster-kubeconfigfile in this repo root folder; - Go to your system user
.kubefolder and openconfigfile (on Windows:C:/Users/<USERNAME>/.kube, on masOSUsers/<USERNAME>/.kube/config); - Copy this config file content and paste to
.to-dos-cluster-kubeconfigfile, created in the first step.
Then you should be able to go and grap the created k8s cluster config here in the root of the repo .inner-circle-cluster-kubeconfig and use it in Lens (or OpenLens) to connect to the cluster.
In Lens/OpenLens you can go to File -> Add Cluster and put there the copied config file content and create it.
Then you should be able to connect to it.
To deploy the stack to the cluster at the first time or re-deploy it after a change in charts or their configuration execute the following command:
helmfile cache cleanup && helmfile --environment local --namespace local -f deploy/helmfile.yaml applyNote: at the first time this really takes a while.
Note:
helmfile cache cleanupis needed to force to re-fetch remote values.yaml files from git repos. Otherwise it will never invalidate them. Links: roboll/helmfile#720 (comment) and https://helmfile.readthedocs.io/en/latest/#cache.
Note: if one of your services version was updated e.g. a newer version was published to
inner-circle-ui:latestyou won't see the changes executinghelmfile applycommand. Instead you need to remove the respective service Pod that it can be re-created by its Deployment and fetch the latest docker image.
To see how all charts manifest are going to look like before apply you can execute the following command:
helmfile cache cleanup && helmfile --environment local --namespace local -f deploy/helmfile.yaml templateTo delete the previously created cluster by any reason execute the following command:
kind delete cluster --name inner-circleWhen the all k8s pods are running inside local namespace you should be able to navigate to this URL's in your browser and see Inner Circle.
-
OpenLens not showing any pods, deployments, etc.. Make sure the "Namespace" in view "Workloads" is set to "
local" or "All namespaces" -
cannot open http://localhost/
This site can’t be reached localhost refused to connect.if you see this in your browser please try to open in Incognito Mode
-
cannot install inner-circle-ui chart
COMBINED OUTPUT: Release "inner-circle-ui" does not exist. Installing it now. coalesce.go:286: warning: cannot overwrite table with non table for nginx.ingress.annotations (map[]) coalesce.go:286: warning: cannot overwrite table with non table for nginx.ingress.annotations (map[]) Error: context deadline exceededif you see this after you try to run
helmfile applycommand, simply retryhelmfile applycommand. -
in case of any other weird issue:
- Remove the
inner-circle-control-planedocker container. - Remove the cluster from Lens.
- Re-try over starting from
kind createcommand.
- Remove the
- https://shisho.dev/blog/posts/docker-in-docker/
- https://devopscube.com/run-docker-in-docker/
- kubernetes-sigs/kind#3196
- https://github.com/devcontainers/features
- https://fenyuk.medium.com/helm-for-kubernetes-helmfile-c22d1ab5e604
How to deploy images from GitHub Registry or local Docker environments
To deploy specific image tag published to GitHub Registry, use the following configuration for values-your-service.yaml.gotmpl file:
# layout-ui as example
image:
registry: ghcr.io
repository: "tourmalinecore/inner-circle-layout-ui"
# Write tag of your image for deploy (change only symbols after "sha-")
tag: "sha-f1c1e64bcb3401f602ac3b2afdf6066c6e2d4876"
To deploy local Docker image, first load it into the kind cluster using the following command:
kind load docker-image your-local-image:your-tag --name your-cluster-name
Then use the following configuration for values-your-service.yaml.gotmpl file:
image:
registry: ""
repository: "my-layout"
tag: "0.0.1"
pullPolicy: "Never"
repository and tag are your-local-image and your-tag from deploy command
after helm apply the job is considered completed, so you need to remove release from lens or uninstall chart (and job in this chart) locally and run helm apply again for it to work. it needs to execute it again because otherwise it will not restart if it has already been completed
helm uninstall create-test-accounts -n local
command to see job logs
kubectl logs job/create-test-accounts -n local -f