The SONAR Agent is responsible for collecting configuration and service health information for a local environment (i.e. a single Kubernetes cluster) and pushing it to the SONAR API.
Since the SONAR API exposes OpenApi documentation metadata, it is possible to auto-generate client C# code to access the API. Currently, this is done using NSwag. Code generation only needs to be performed when the API changes, and can be done with the following command line:
# Note: in order for this command to work you need to have the API running and
# accessible via http://localhost:8081/
dotnet msbuild -target:NSwag
Prequisites: database and SONAR API must be up.
To run the SONAR Agent, add the configuration file path as the first command line argument. Example:
dotnet run -- -f service-config.json
To run the SONAR Agent with layered configuration (multiple config files), follow the example below:
dotnet run -- -f service-config.json service-config2.json service-config3.json
To run the SONAR Agent with the configuration loaded from k8s, follow the steps below:
- Have the k3d instance up and running.
- cd to the /samples directory
- Run
kubectl apply -f namespace-samples.yaml
- Run
kubectl apply -f ado-1-manifest.yaml
&kubectl apply -f ado-2-manifest.yaml
- Run
dotnet run --kubernetes-configuration
The SONAR Agent can also be run from within Kubernetes. The easiest way to install it is via the sonar-agent Helm Chart. There are instructions for setting up a local k3d cluster and installing it for testing purposes here. Note: in order to enable kubernetes configuration loading from within the cluster you will need to specify the serviceAccountName
value when installing the chart (see the chart readme for details).