Clone the repo and cd
into it. Go through the below steps to setup the development environment.
- Make
brew install make
- Golang 1.21 or higher
make install-go
- K8s Cluster (minikube/k3s/k8s, etc), to install minikube on Mac, run
brew install minikube
- Podman
brew install podman
- Docker (https://www.docker.com/products/docker-desktop)
- Ensure you have the requirements installed (see above)
- Run
make setup-dev
, this will install all the required dependencies and tools for development.
The steps will start minikube cluster, installs the istio, creates required CRDs and starts the Naavik.
- Ensure you have the requirements installed (see above)
- Ensure setup is complete (see above)
- Ensure Podman is initialized and started. If not run -
podman machine init --memory 8500 --rootful
andpodman machine start
- Setup a minikube cluster by running
./tools/dev/setup-minikube.sh <cluster name>
Create multiple clusters by changing the cluster name. - Run
./tools/dev/run-with-minikube.sh <list of clusternames space separated>
. Example:./tools/dev/run-with-minikube.sh cluster1 cluster2
. The first cluster will be the primary cluster and the rest will be the secondary clusters.
If the cluster is already running with Istio and required CRDs, you can go through the below steps to run the Naavik.
- Ensure you have the requirements installed (see above)
- Ensure setup is complete (see above)
- Run
go run ./main.go --kube_config=<path-to-kubeconfig> --log_level=trace --log_color=true
- Check supported arguments for more details.
- Ensure you have the requirements installed (see above)
- Ensure setup is complete (see above)
- Open the project in your IDE and run
./main.go
with the below arguments--kube_config=<path-to-kubeconfig>
--log_level=trace
--log_color=true
- Check supported arguments for more details.
Usage:
go run ./main.go [flags]
Flags:
--argo_rollouts Use argo rollout configurations. Defaults to true (default true)
--async_executor_max_goroutines int Maximum number of go routines to be used by async executor. Defaults to 20000 (default 20000)
--config_path string Path where the configuration file resides. Defaults to "/etc/admiral/config.yaml" (default "/etc/admiral/config.yaml")
--config_resolver string Set the config resolver to run naavik with, defaults to "secret" (default "secret")
--dependency_namespace string Namespace to monitor for service dependency data. Defaults to "admiral" (default "admiral")
--deprecated_envoy_filter_versions stringArray List of envoy filter versions that are deprecated and should be removed while traffic config processing. Defaults to ["1.13"] (default [1.13])
--disabled_features stringArray Comma separated list of features to be disabled. Available features [gwproxyfilter routerfilter throttlefilter virtualservice]
--enable_profiling Enable go profiling for cpu, memory, goroutines, etc. Defaults to false
--env_key env_key The annotation or label, on a pod spec in a deployment/rollout, which will be used to group deployments across regions/clusters under a single environment. Defaults to "admiral.io/env"The order would be to use annotation specified as env_key, followed by label specified as `env_key` and then fallback to the label `env` (default "admiral.io/env")
--envoy_filter_versions stringArray List of envoy filter versions that should be processed for traffic config. Defaults to ["1.21"] (default [1.21])
-h, --help help for naavik
--hostname_suffix string The hostname suffix to customize the cname generated by admiral. Default suffix value will be "mesh" (default "mesh")
--ignore_asset_aliases stringArray List of asset aliases that should be ignored for traffic config processing. Defaults to []
--injection_enabled_label_key string The hostname suffix to customize the cname generated by admiral. Default suffix value will be "sidecar.istio.io/inject" (default "sidecar.istio.io/inject")
--kube_config string Use a Kubernetes configuration file instead of in-cluster configuration. Defaults to empty string, which means in-cluster configuration
--log_color Enable color for logs. Default is false
--log_level string Set log verbosity, defaults to 'Info'. Must be between "trace" and "info" (default "info")
--profiler_endpoint string Set the continuous profiler endpoint. Defaults to "localhost:4040" (default "localhost:4040")
--resource_ignore_label string The label on the resource, which will be used to ignore the resource from getting processed. Defaults to "admiral.io/ignore" (default "admiral.io/ignore")
--secret_namespace string Namespace to monitor for secrets that contains remote cluster data. Defaults to "admiral" (default "admiral")
--secret_sync_label string The label on the secret, which will be used to sync the secret of remote clusters. Defaults to "admiral.io/sync" (default "admiral.io/sync")
--state_checker string Set the state checker to run naavik with, defaults to "none" (default "none")
--sync_namespace string Namespace to monitor for custom resources. Defaults to "admiral-sync" (default "admiral-sync")
--sync_period duration Interval for syncing Kubernetes resources. Defaults to 1000000000 (default 1s)
--traffic_config_clusters_scope stringArray List of clusters that should be processed for traffic config. Defaults to [".*"] (default [.*])
--traffic_config_identity_key string The traffic config identity key holds identity value of a service. Default label key will be "asset". (default "asset")
--traffic_config_namespace string Namespace to monitor for service traffic config data. Defaults to "admiral" (default "admiral")
--worker_concurrency int Number of workers to process events from informers (This is per controller config). Defaults to 1 (default 1)
--workload_identity_key string The workload identity key, on deployment/rollout which holds identity value used to generate cname. Default label key will be "alpha.istio.io/identity"If present, that will be used. If not, it will try an annotation (for use cases where an identity is longer than 63 chars) (default "alpha.istio.io/identity")
- Naavik supports continuous profiling using Pyroscope. To enable profiling set
--enable_profiling=true --profiler_endpoint=localhost:4040
in the command line arguments. - Install Pyroscope in your local machine using
brew install pyroscope-io/brew/pyroscope
- Start
brew services start pyroscope
- Open
http://localhost:4040
in your browser to view the profiling data.
- Ensure you have the requirements installed (see above)
- Run
make lint
to lint the code with auto-fix
- Naavik uses Swagger to expose REST APIs. To view the REST APIs available, run the Naavik and open
http://localhost:8080/api/v1/docs/index.html#/
in your browser. - To test the REST APIs, use the Swagger UI.
- If you are working on new/modifying existing REST APIs, refer to SWAG's declarative comment format to expose the API on Swagger UI.
- Setup the
swag
cli usingmake setup-swag
. This will install theswag
cli to generate the Swagger documentation. - Whenever you modify the REST APIs, run
make generate-swagger
to update the Swagger documentation (doc resides under ./internal/server/swagger directory).
settings.json
to enable linting and formatting
{
...
"go.lintTool": "golangci-lint",
"go.lintFlags": ["--fast"],
"go.lintOnSave": "package",
"gopls": {
"formatting.gofumpt": true,
"ui.semanticTokens": true
}
...
}