Skip to main content

snowplow

Snowplow is a web service that plays a key role within the suite of components that make up Krateo PlatformOps.

It serves multiple purposes, primarily acting as a bridge between Krateo's custom resources and the UI. By enabling a dynamic and declarative approach to defining UI components and layouts, Snowplow ensures that the interface is interpreted and rendered seamlessly by Krateo Frontend.

Currently, Snowplow handles on-demand resolution of the RESTAction custom resource. For all other custom resources within Krateo, it delegates the task to the Kubernetes API server, which, in turn, leverages Krateo’s custom aggregation API layer to process them.

Looking ahead, Snowplow will take full responsibility for managing all custom resources beyond RESTAction, eventually eliminating the need for delegation altogether.

As of today, the overall architecture is structured as follows:

RESTAction

This document provides an overview of the RESTAction CRD and its properties to facilitate its usage within Kubernetes environments.

Overview

The RESTAction Custom Resource Definition (CRD) allows users to declaratively define calls to APIs that may depend on other API calls.

Schema spec Details

PropertyTypeDescription
apiarrayDefines API requests to an HTTP service.
filterstringA JQ filter that can be applied to the global response.

api Array Item Properties

A single api item defines an HTTP REST call. The invoked API must produce a JSON content type

PropertyTypeDescription
dependsOnobjectDefines dependencies on other APIs.
endpointRefobjectReferences an Endpoint object.
filterstringA JQ expression for response processing.
headersarray of stringsCustom request headers (each header can be a JQ expression).
namestringUnique identifier for the API request.
pathstringRequest URI path (can be a JQ expression).
payloadstringRequest body payload (can be a JQ expression).
verbstringHTTP method (defaults to GET if omitted).

dependsOn Object Properties

PropertyTypeDescription
iteratorstringA JQ expression that returns a JSON array on which to iterate.
namestringName of another API on which this depends.

endpointRef Object Properties

Reference to a Kubernetes secret that describes the HTTP REST API endpoint.

PropertyTypeDescription
namestringName of the referenced object.
namespacestringNamespace of the referenced object.

status Properties

The status field is an open-ended object that preserves unknown fields for storing results of all the api calls.

Examples

Some RESTAction examples can be found here. Lets check the one that query jsonplaceholder.typicode.com API:

---
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: typicode-endpoint
namespace: demo-system
stringData:
server-url: https://jsonplaceholder.typicode.com
---
apiVersion: templates.krateo.io/v1
kind: RESTAction
metadata:
name: typicode
namespace: demo-system
spec:
filter: "[.todos[] as $todo | .users[] | select(.id == $todo.userId) | { name: .name, id: $todo.id, title: $todo.title, completed: $todo.completed }]"
api:
- name: users
path: "/users"
endpointRef:
name: typicode-endpoint
namespace: demo-system
filter: map(select(.email | endswith(".biz")))
- name: todos
dependsOn:
name: users
iterator: .users
path: ${ "/todos?userId=" + (.id|tostring) }
headers:
- ${ "X-UserID:" + (.id|tostring) }
endpointRef:
name: typicode-endpoint
namespace: demo-system