/kre

Konstellation Runtime Engine

Primary LanguageTypeScript

KRE (Konstellation Runtime Engine)

Konstellation Runtime Engine is an application that allow to run AI/ML models for inference based on the content of a .krt file.

Engine

Component Coverage Bugs Maintainability Rating
Admin UI coverage bugs mr
Admin API coverage bugs mr
K8s Manager coverage bugs mr

Runtime

Component Coverage Bugs Maintainability Rating
Runtime API coverage bugs mr
K8s Runtime Operator - - -
Mongo Writer coverage bugs mr

Runners

Component Coverage Bugs Maintainability Rating
KRE Entrypoint coverage bugs mr
KRE Go coverage bugs mr
KRE Py coverage bugs mr

Architecture

KRE is designed based on a microservice pattern to be run on top of a Kubernetes cluster.

In the following diagram is described the main components and the relationship each other.

Architecture

Below are described the main concepts of KRE.

Engine

When you install KRE in your Kubernetes cluster a Namespace called kre is created and within this are deployed some components. These components are responsible to create new runtimes and expose all the required information to the Admin UI.

The Engine is composed by the following components:

Runtime

When you create what is called a runtime, the Engine create a new Namespace within the Kubernetes cluster with the name set by the user from the Admin UI, and deploy on this Namespace all the base components that are described below.

The goal of a Runtime is to run the designed services within the .krt file to perform the inference of a AI/ML model.

Each Runtime is composed by the following components:

KRT

Konstellation Runtime Transport is a compressed file with the definition of a runtime version, included the code to run and a YAML file called kre.yaml with the desired workflows definitions.

The base structure of a kre.yaml is as follow:

version: mettel-tnba-v1
description: This is the new version that solves some problems.
entrypoint: 
  proto: public_input.proto
  image: konstellation/kre-runtime-entrypoint:latest

config:
  variables:
    - API_KEY
    - API_SECRET
  files:
    - HTTPS_CERT

nodes:
 - name: ETL
   image: konstellation/kre-py:latest
   src: src/etl/execute_etl.py
 
 - name: Execute DL Model
   image: konstellation/kre-py:latest
   src: src/execute_model/execute_model.py

 - name: Create Output
   image: konstellation/kre-py:latest
   src: src/output/output.py

 - name: Client Metrics
   image: konstellation/kre-py:latest
   src: src/client_metrics/client_metrics.py

workflows:
  - name: New prediction
    entrypoint: MakePrediction
    sequential:
      - ETL
      - Execute DL Model
      - Create Output
  - name: Save Client Metrics
    entrypoint: SaveClientMetric
    sequential:
      - Client Metrics

Install

KRE can be installed only on top of a Kubernetes cluster, and is packetized as a Helm Chart. In order to install it just need to download the desired Chart version, define your custom values.yaml and run the following command.

helm repo add konstellation-ce https://charts.konstellation.io
helm upgrade --install --namespace kre --values ./custom-values.yaml kre-v1.0.0

Custom Installation

KRE allows a custom configuration to use parts that already exist in your infrastructure.

Prometheus

  • Prometheus will be installed by default if you prefer use your own prometheus, use this helm parameter:
Param Value
prometheusOperator.enabled false

Development

Requirements

In order to start development on this project you will need these tools:

  • gettext: OS package to fill templates during deployment
  • minikube: the local version of Kubernetes to deploy KRE
  • helm: K8s package manager. Make sure you have v3+

NOTE: If you still have Helm v2 update variable $HELM_VERSION in file .krectl.conf.

Local Environment

This repo contains a tool called ./krectl.sh to handle common actions you need during development.

All the configuration needed to run KRE locally can be found in .krectl.conf file. Usually you'd be ok with the default values. Check Minikube parameters if you need to tweak the resources assigned to it.

Run help to get info for each command:

$> krectl.sh [command] --help

// Outputs:

  krectl.sh -- a tool to manage KRE environment during development.

  syntax: krectl.sh <command> [options]

    commands:
      dev     creates a complete local environment and auto-login to frontend.
      start   starts minikube kre profile.
      stop    stops minikube kre profile.
      login   creates a login URL and open your browser automatically on the admin page.
      build   calls docker to build all images inside minikube.
      deploy  calls helm to create install/upgrade a kre release on minikube.
      delete  calls kubectl to remove runtimes or versions.

    global options:
      h     prints this help.
      v     verbose mode.

Login

First of all remember to edit your /etc/hosts, see ./krectl.sh dev output for more details.

NOTE: If you have hostctl installed, updating /etc/hosts will be done automatically too.

In order to access the admin app, the login process can be done automatically using this script:

$ ./krectl.sh login [--new]

You will see an output like this:

⏳ Calling Admin API...

 Login done. Open your browser at:

 🌎 http://admin.kre.local/signin/c7d024eb-ce35-4328-961a-7d2b79ee8988

✔️  Done.