Skip to content

Kriten gRPC

Kriten supports gRPC from version 1.2.0. This facilitates efficient communication between the client and Kriten, whilst also enabling bi-directional communication. Consequently, users may subscribe to a running job and await the result, thereby eliminating the requirement for polling. Furthermore, the Kriten gRPC implementation incorporates the same AAA controls as the REST API interface.

Installation

gRPC is disabled by default, it needs to be enabled at Kriten instlallation.

There is a set of parameters for gRPC configurable at install via Helm chart:

# gRPC parameters
GRPC_ENABLED = true
GRPC_PORT = 9090
GRPC_REFLECTION = false
WATCH_INTERVAL = 5
WATCH_MAX_DURATION = 3600
Brief explanation of parameters:

  • GRPC_ENABLE (true/false) enable/disable gRPC at the install time (default false).
  • GRPC_PORT (int) - port gRPC server is listening on (default 9090).
  • GRPC_REFLECTION (true/false) - enable/disable gRPC reflection, auto-discovery of available gRPC services for clients (default false).
  • WATCH_INTERVAL (seconds, int) - interval for watcher to check job status (default 5s).
  • WATCH_MAX_DURATION (seconds, int) - max wait interval for the job completion (default 1h).

Services Available

  • kriten.v1.KritenService/ListTasks - list task, available for execution;
  • kriten.v1.KritenService/RunTask - execute task, returns running job object;
    • Metadata: {"task_id": "<UUID>}
  • kriten.v1.KritenService/ListJobs - list of all jobs;
  • kriten.v1.KritenService/GetJob - get Job object with all data;
    • Metadata: {"id": <UUID>}
  • kriten.v1.KritenService/WatchJob - gRPC streaming subscription to watch a long running job until completion or WATCH_MAX_DURATION whichever is first;
    • Metadata: {"id": <<UUID>>}

Authentication

gRPC authentication is done via API Bearer token, defined in the header as following key/pair: "token": <bearer_token>

Refer to Kriten documentation on how to create API token. API token has to be created for a user, thus would carry his/her identity with RBAC and audit.

TLS is not currently available, TLS termination can be offered by fronting Ingress/Proxy, HTTP/2 support is required end-to-end.

Example

Below Kriten gRPC service is exposed as NodePort (30090) in a Kubernetes cluster:

NAME                   TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
kriten                 ClusterIP   10.43.221.231   <none>        80/TCP           7d21h
kriten-frontend        ClusterIP   10.43.75.194    <none>        80/TCP           7d21h
kriten-grpc            NodePort    10.43.89.217    <none>        9090:30090/TCP   7d21h
kriten-postgresql      ClusterIP   10.43.137.230   <none>        5432/TCP         7d21h
kriten-postgresql-hl   ClusterIP   None            <none>        5432/TCP         7d21h

We will demonstrate gRPC using open-source grpcurl CLI tool (https://github.com/fullstorydev/grpcurl). Kriten proto files are available in repo (https://github.com/kriten-io/kriten/tree/main/proto/kriten/v1)

We exported API token as Env Var TOKEN.

Let's explore available services:

bash-3.2$ grpcurl -H token:$TOKEN -import-path ./proto/kriten/v1 -proto kriten.proto -plaintext 192.168.10.190.nip.io:30090 list
kriten.v1.KritenService

bash-3.2$ grpcurl -H token:$TOKEN -import-path ./proto/kriten/v1 -proto kriten.proto -plaintext 192.168.10.190.nip.io:30090 list kriten.v1.KritenService
kriten.v1.KritenService.GetJob
kriten.v1.KritenService.ListJobs
kriten.v1.KritenService.ListTasks
kriten.v1.KritenService.RunTask
kriten.v1.KritenService.WatchJob

We will demonstrate gRPC with a python Nornir script, which pulls Arista switch inventory from Infrahub SoT and collects set of health metrics from Arista switches via eAPI and returns result in json format (https://github.com/kriten-io/kriten-community-toolkit/tree/main/arista-health). We have configured Runner and Task to execute that script and it is available as aristahealth-nornir task.

bash-3.2$ grpcurl -H token:$TOKEN -import-path ./proto/kriten/v1 -proto kriten.proto -plaintext 192.168.10.190.nip.io:30090 kriten.v1.KritenService.ListTasks
{
  "tasks": [
    {
      "id": "65e3fe86-c4fa-4a5f-9eb5-2cb68be38c53",
      "name": "aristahealth-nornir",
      "runnerId": "00d97df9-91a7-4ae2-84e1-56f9d07bcd9d",
      "command": "python arista-health/aristahealth_nornir.py",
      "schema": {
        "description": "Arista health-check task, pulls inventory from Infrahub SoT and collects health information from Arista switches."
      },
      "createdAt": "2026-11-26T15:04:23.484513Z",
      "updatedAt": "2026-12-04T11:53:23.059819Z"
    }
  ],
  "total": 1
}

Next we execute this task by ID and get Job object back:

bash-3.2$ grpcurl -H token:$TOKEN -d '{"task_id": "65e3fe86-c4fa-4a5f-9eb5-2cb68be38c53"}' -import-path ./proto/kriten/v1 -proto kriten.proto -plaintext 192.168.10.190.nip.io:30090 kriten.v1.KritenService.RunTask
{
  "id": "eb0e1684-30e2-4dd8-b113-2689257f55ce",
  "name": "aristahealth-nornir-2hd4g",
  "taskId": "65e3fe86-c4fa-4a5f-9eb5-2cb68be38c53",
  "taskName": "aristahealth-nornir",
  "owner": "root",
  "startTime": "Fri Dec  4 12:02:07 UTC 2026",
  "status": "running",
  "createdAt": "2026-12-04T12:02:07.914857398Z",
  "updatedAt": "2026-12-04T12:02:07.914857398Z"
}

It doesn't take long for the Job to run as there are only 5 switches, thus we can observe result of the Job:

{
  "id": "eb0e1684-30e2-4dd8-b113-2689257f55ce",
  "name": "aristahealth-nornir-2hd4g",
  "taskId": "65e3fe86-c4fa-4a5f-9eb5-2cb68be38c53",
  "taskName": "aristahealth-nornir",
  "owner": "root",
  "startTime": "Fri Dec  4 12:02:07 UTC 2026",
  "completionTime": "Fri Dec  4 12:02:21 UTC 2026",
  "completed": 1,
  "status": "completed",
  "jsonData": {
    "health": [
      {
        "bgp": {
          "peers": 2
        },
        "cooling": {
          "PowerSupply1/1": 48,
          "PowerSupply2/1": 48,
          "ambientTemperature": 19.9375,
          "fanStatus": "fanAlarmOk",
          "fanTray1/1": 32,
          "fanTray2/1": 32,
          "status": "coolingOk"
        },
        "device": "lon-lab-arbg01",
        "discards": {
          "in": 0,
          "out": 0
        },
        "interfaces": {
          "disabled": 0,
          "down": 54,
          "err-disabled": 0,
          "up": 3
        },
        "last_reload": {
          "cause": "Reload requested by the user.",
          "days_since": 22
        },
        "lldp_neighbors": 3,
        "mlag_detail": {},
        "port_channel": {
          "inactive_ports": 0
        },
------ long output truncated -------

To simulate long running Job, we will prepend "sleep 60" command before calling python script in aristahealth-nornir task. We will RunTask and then will use WatchJob to wait for that Job result.

Run task and get Job ID:

bash-3.2$ grpcurl -H token:$TOKEN -d '{"task_id": "65e3fe86-c4fa-4a5f-9eb5-2cb68be38c53"}' -import-path ./proto/kriten/v1 -proto kriten.proto -plaintext 192.168.10.190.nip.io:30090 kriten.v1.KritenService.RunTask
{
  "id": "f5bcb5d1-a8c8-4f4a-96fd-3721fb823305",
  "name": "aristahealth-nornir-j55gj",
  "taskId": "65e3fe86-c4fa-4a5f-9eb5-2cb68be38c53",
  "taskName": "aristahealth-nornir",
  "owner": "root",
  "startTime": "Fri Dec  4 12:08:46 UTC 2026",
  "status": "running",
  "createdAt": "2026-12-04T12:08:46.187146414Z",
  "updatedAt": "2026-12-04T12:08:46.187146414Z"
}

Executing WatchJob, it receives first status that Job is running, and on completion it receives Job result and exits.

bash-3.2$ grpcurl -H token:$TOKEN -d '{"id": "f5bcb5d1-a8c8-4f4a-96fd-3721fb823305"}' -import-path ./proto/kriten/v1 -proto kriten.proto -plaintext 192.168.10.190.nip.io:30090 kriten.v1.KritenService.WatchJob
{
  "jobId": "f5bcb5d1-a8c8-4f4a-96fd-3721fb823305",
  "status": "running"
}
{
  "jobId": "f5bcb5d1-a8c8-4f4a-96fd-3721fb823305",
  "status": "completed",
  "completed": 1,
  "completionTime": "Fri Dec  4 12:09:56 UTC 2026",
  "terminal": true,
  "jsonData": {
    "health": [
      {
        "bgp": {
          "peers": 2
        },
        "cooling": {
          "PowerSupply1/1": 48,
          "PowerSupply2/1": 48,
          "ambientTemperature": 19.875,
          "fanStatus": "fanAlarmOk",
          "fanTray1/1": 32,
          "fanTray2/1": 32,
          "status": "coolingOk"
        },
        "device": "lon-lab-arbg01",
        "discards": {
          "in": 0,
          "out": 0
        },
        "interfaces": {
          "disabled": 0,
          "down": 54,
          "err-disabled": 0,
          "up": 3
        },
        "last_reload": {
          "cause": "Reload requested by the user.",
          "days_since": 22
        },
        "lldp_neighbors": 3,
        "mlag_detail": {},
        "port_channel": {
          "inactive_ports": 0
        },
        "power_supplies": {
          "1": {
            "state": "powerLoss"
          },
          "2": {
            "state": "ok"
          }
        },
        "routes": {
          "bgp_total": 8,
          "connected": 2,
          "static": 0,
          "total": 10
        },
------ long output truncated -------