Categorygithub.com/nais/api
module
0.0.0-20241216101142-2a06ba94f38b
Repository: https://github.com/nais/api.git
Documentation: pkg.go.dev

# README

NAIS API

NAIS API is the main entrypoint when interacting with the API of the NAIS platform.

Local development

asdf install # Install required dependencies, see .tool-versions for plugins used
docker compose up -d
make setup-local # Setup local environment (seeds database and creates pubsub topic)
make local

For local development you need to set the WITH_FAKE_CLIENTS environment variable to true (as set by make local), and you will also need to set the X-User-Email header to [email protected] if you want to act as a regular user, or [email protected] if you need an admin user, when interacting with the GraphQL API.

If you want to override the default configuration, you can create a .env file in the root of the project.

Locally, most external services are replaced with fake clients, and the Kubernetes client reads data from data/k8s.

Development practices

Check practices used in this project here: docs/practices.md

Graph-API

We have defined a set of practices for the Graph-API in the docs/graphql_practices.md file.

Fake clients

We have a set of fake clients, and stubs, that can be used for local development. One of the clients is a fake Kubernetes client that read data from data/k8s. You can read more about how the fake clients works in the data/k8s/README.md file.

Integration tests

We are using tester for integration tests. These tests are written in Lua and can be found in the integration_tests directory.

A spec file is generated to support auto-completion using the Lua language server.

When running make test the integration tests will be run as part of the test suite. If you only want to run the integration tests, and get information about coverage, you can run make integration-test.

To run the integration tests in watch mode, run make integration_test_ui. This will start a web server on localhost:9876 where you can see the test results. They will be re-run every time you save a .lua file.

Architecture


graph TD
  API --> Postgres[(psql)]
  Service[NAIS Service] --> |GRPC|API
  Clients[External Clients] --> |GraphQL|API
  API -.-> PubSub{PubSub}

  subgraph ext [External data]
    API --> K8s([Kubernetes])
    API --> Prom([Prometheus])
    API --> GA([Google Admin])
    API --> BQ([BigQuery])
  end
ComponentDescription
APIThis service
PostgresThe postgres database storing state from this application
NAIS ServiceServices by NAIS that requires special communication with API. E.g. Reconcilers and Deploy
External ClientsExternal clients that communicates with the API. E.g. Browsers and NADA
KubernetesThe Kubernetes clusters of the tenant
PubSubThe PubSub topic used for communication between the API and the NAIS Service
PrometheusWe collect historic data from the tenants prometheus
Google AdminWe use the Google Admin API to manage a list of users
BigQueryWe collect historic cost data from BigQuery

# Packages

No description provided by the author