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.
Field | Description | Validation Rule |
openapi | string | string = { |
workloadSelector | tetrateio.api.tsb.types.v2.WorkloadSelector
| – |
servers | List of tetrateio.api.tsb.gateway.v2.HttpServer | – |
endpoints | List of tetrateio.api.tsb.application.v2.HTTPEndpoint | – |
HTTPEndpoint
An HTTP Endpoint represents an individual HTTP path exposed in the API.
Field | Description | Validation Rule |
path | string | – |
methods | List of string | – |
hostnames | List of string | – |
service | string | – |