Skip to main content
Version: 1.5.x

API

API objects define a set of servers and endpoints that expose the business logic for an Application. APIs are attached to existing Applications to configure how the features exposed by the different services that are part of the Application can be accessed.

The format used to define APIs is based on the OpenAPI v3 spec. users can attach OpenAPI documents to the applications, and Service Bridge will generate all the configuration that is needed to make the APIs available. Service Bridge also provides a set of custom extensions to the OpenAPI spec that can be used to further customize the APIs in those cases where the standard OpenAPI properties are not sufficient.

The following example shows how an API can be attached to an existing application:

apiversion: application.tsb.tetrate.io/v2
kind: API
metadata:
organization: my-org
tenant: tetrate
application: example-app
name: ezample-app-api
spec:
description: An example OpenAPI based API
workloadSelector:
namespace: exampleapp
labels:
app: exampleapp-gateway
openapi: |
openapi: 3.0.0
info:
title: Sample API
description: An example API defined in an OpenAPI spec
version: 0.1.9
x-tsb-service: sample-app.sample-ns # service exposing this api
servers:
- url: http://api.example.com/v1
description: Optional server description, e.g. Main (production) server
- url: http://staging-api.example.com
paths:
/users:
get:
summary: Returns a list of users.
description: Optional extended description in CommonMark or HTML.
responses:
'200': # status code
description: A JSON array of user names
content:
application/json:
schema:
type: array
items:
type: string

API

An API configuring a set of servers and endpoints that expose the Application business logic.

FieldDescriptionValidation Rule

openapi

string
REQUIRED
The raw OpenAPI spec for this API.

string = {
  min_len: 1
}

workloadSelector

tetrateio.api.tsb.types.v2.WorkloadSelector
Optional selector to specify the gateway workloads (pod labels and Kubernetes namespace) under the application gateway group that should be configured with this gateway. There can be only one gateway for a workload selector in a namespace. If the selector is omitted, then the following default workload selector will be applied, based on the name of the Application and the API objects.

workloadSelector:
namespace: exampleapp
labels:
app: application-name
api: api-name

servers

List of tetrateio.api.tsb.gateway.v2.HttpServer
OUTPUT_ONLY
List of servers that expose the API. Server hostnames must be unique in the system, and only one API can expose a specific hostname.

endpoints

List of tetrateio.api.tsb.application.v2.HTTPEndpoint
OUTPUT_ONLY
List of endpoints exposed by this API. This field is read-only and generated from the configured OpenAPI spec.

HTTPEndpoint

An HTTP Endpoint represents an individual HTTP path exposed in the API.

FieldDescriptionValidation Rule

path

string
OUTPUT_ONLY
The HTTP path of the endpoint, relative to the hostnames exposed by the API.

methods

List of string
OUTPUT_ONLY
The list of HTTP methods this endpoint supports.

hostnames

List of string
OUTPUT_ONLY
The list of hostnames where this endpoint is exposed. If omitted, the endpoint is assumed to be exposed in all hostnames defined for the API.

service

string
OUTPUT_ONLY
The FQN of the service in the service registry that is exposing this endpoint.