This folder contains helm charts for deploying SONAR components. Currently, our only Helm deployed component is the SONAR agent.
This file contains internal developer documentation. For documentation of the normal usage and configuration of the sonar-agent Helm chart see this readme.
To test the SONAR agent in kubernetes locally you can deploy it to a local K3D cluster by following these steps:
To create k3d cluster of the sonar-agent with the name "sonar-test" and install the sonar agent helm chart, run the following from the root of the repository:
./scripts/k3d-deploy.sh sonar-test
You can subsequently re-run this command with the -r
flag to delete and recreate the cluster, or with the -u
flag to upgrade the previously installed helm chart.
Usage: k3d-deply.sh [options] <cluster_name> [helm_args...]
Creates or recreates a K3D cluster and installs or upgrades the sonar-agent helm
chart in that cluster.
Cluster name is required. Any additional arguments will be passed to Helm.
Options:
-f <file> Designate a single helm values file. If you want to specify
multiple files you can pass --values as a helm argument.
-t <tag> The tag to apply to the docker image.
-r Recreate cluster if exists. Cannot be combined with (-u).
-u Upgrade the helm chart. Cannot be combined with (-r).
-a Install sonar API, dependencies, and test apps as well.
When run with the -a
flag, this script use the kustomization and kubernetes resources defined in the k8s folder to install the SONAR API and the test-metric and http-metric-test apps to enable end-to-end testing.
Once your k3d cluster is up and running you can access services running within k3d via port 8088
. Because services running in k3d are all exposed via a single port, routing is done based on path prefix:
Path | Service |
---|---|
/ | sonar-ui |
/api/* | sonar-api |
/metrics | test-metric-app |
/test/* | http-metric-test-app |
/prometheus/* | prometheus |
These steps are automated by the k3d-deploy.sh script, but if you are really curious, here are the manual steps that you can use to set up a k3d cluster.
k3d cluster create sonar-test --registry-create sonar-registry -p "8088:80@loadbalancer"
docker ps -f name=sonar-registry
In order to access the k3d docker registry via the host name sonar-registry
we need to make that host name resolve to localhost (127.0.0.1). To do so add the following to your /etc/hosts
file (note: you will need to launch your text editor with admin privileges using sudo
)
# k3d docker registry for sonar
127.0.0.1 sonar-registry
From the root of the repository
docker build -f Dockerfile.agent . -t sonar-agent:testing
docker tag sonar-agent:testing sonar-registry:{PORT_NUMBER_FROM_STEP_2}/sonar-agent:testing
docker push sonar-registry:{PORT_NUMBER_FROM_STEP_2}/sonar-agent:testing
helm install my-sonar-agent ./charts/sonar-agent -f ./charts/sonar-agent/examples/values.example-service-config.yaml --set image.repository=sonar-registry:{PORT_NUMBER_FROM_STEP_2}/sonar-agent --set image.tag=testing