For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
Create ApiDocs
Create ApiDoc resources to pair OpenAPI schemas with your backend services.
An ApiDoc resource represents the OpenAPI schema that is served by a backend Kubernetes service. The portal controller reads ApiDocs to render the API reference documentation in the portal frontend.
Before you begin
- Follow the Get started guide to install Solo Enterprise for kgateway.
- Set up a portal. For more information, see Get started with portal.
Deploy a sample app
Deploy the petstore sample app. The examples in this guide use this app as the backing service for the ApiDocs resource.
kubectl apply -f https://raw.githubusercontent.com/kgateway-dev/kgateway.dev/refs/heads/main/assets/docs/examples/petstore.yamlVerify that the petstore pod is running.
kubectl get pods -n default -l app=petstoreExample output:
NAME READY STATUS RESTARTS AGE petstore-6fd9c7f69d-4bntz 1/1 Running 0 10sCreate an HTTPRoute for the petstore sample app. If you followed the Get started with portal guide, you already exposed the httpbin app under the
api.example.comsample domain. This domain can be used as an umbrella for all APIs that you want to expose in the portal, including the petstore app from this example. To distinguish the routing paths for the different apps, you expose the petstore API endpoints under the/petstoreprefix and use a URLRewrite filter to remove that prefix before forwarding requests to the petstore app.kubectl apply -f- <<EOF apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: petstore-route namespace: default spec: parentRefs: - name: portal-gateway namespace: default hostnames: - "api.example.com" rules: - matches: - path: type: PathPrefix value: /petstore filters: - type: URLRewrite urlRewrite: path: type: ReplacePrefixMatch replacePrefixMatch: / backendRefs: - name: petstore port: 8080 EOF
Set up ApiDocs
Create an ApiDocs resource that represents the OpenAPI schema that your services serve. You can choose between the following options to provide your OpenAPI schema:
- Manual: You can manually add the OpenAPI schema to the ApiDocs resource and inline each API endpoint in the resource directly.
- URL: Provide a URL that exposes the OpenAPI schema that you want to serve.
- Kube: Fetch the OpenAPI schema from an endpoint that is exposed by an in-cluster Kubernetes service.
Inline the full OpenAPI schema directly in the ApiDoc resource. Use this option when you want full control over the spec or when your service does not expose the schema on a specific path. The schema must be a valid OpenAPI v2 or v3 spec in JSON or YAML format.
Make sure to add the servedBy field to pair the ApiDoc with the service that serves the OpenAPI schema.
kubectl apply -f- <<EOF
apiVersion: portal.solo.io/v1alpha1
kind: ApiDoc
metadata:
name: petstore-apidoc
namespace: default
spec:
source:
manual:
content: |
{
"openapi": "3.0.0",
"info": {
"title": "Petstore API",
"version": "1.0.0"
},
"paths": {
"/pets": {
"get": {
"summary": "List all pets",
"responses": {
"200": {
"description": "A list of pets"
}
}
}
}
}
}
servedBy:
name: petstore
namespace: default
port: 8080
EOF| Setting | Description |
|---|---|
source.manual.content | The full OpenAPI v2 or v3 schema in JSON or YAML format. |
servedBy | The Kubernetes service that backs this API. |
servedBy.name | The name of the Kubernetes service. |
servedBy.namespace | The namespace of the Kubernetes service. |
servedBy.port | The port of the Kubernetes service. |
Fetch the OpenAPI schema from an externally hosted HTTP or HTTPS endpoint. Use this option when the OpenAPI spec is maintained outside the cluster and you do not want to store a local copy.
Make sure to add the servedBy field to pair the ApiDoc with the service that serves the OpenAPI schema.
kubectl apply -f- <<EOF
apiVersion: portal.solo.io/v1alpha1
kind: ApiDoc
metadata:
name: petstore-url-apidoc
namespace: default
spec:
source:
url:
endpoint: "https://petstore3.swagger.io/api/v3/openapi.json"
servedBy:
name: petstore
namespace: default
port: 8080
EOF| Setting | Description |
|---|---|
source.url.endpoint | The full HTTP or HTTPS URL where the portal controller fetches the OpenAPI schema. For HTTPS, the URL must be included in the certificate that validates the HTTPS traffic. |
servedBy | The Kubernetes service that backs this API. Required for URL sources because the controller cannot infer the backend automatically. |
servedBy.name | The name of the Kubernetes service. |
servedBy.namespace | The namespace of the Kubernetes service. |
servedBy.port | The port of the Kubernetes service. |
Fetch the OpenAPI schema from an endpoint that is exposed by an in-cluster Kubernetes service. Use this option when the service exposes its own OpenAPI spec at a known path, such as /openapi.json or /swagger.json.
Note that you do not need to set the servedBy field, because the services is automatically derived from the service that is referenced in the targetRef field.
kubectl apply -f- <<EOF
apiVersion: portal.solo.io/v1alpha1
kind: ApiDoc
metadata:
name: petstore-kube-apidoc
namespace: default
spec:
source:
kube:
targetRef:
name: petstore
port: 8080
path: /openapi.json
EOF| Setting | Description |
|---|---|
source.kube.targetRef.name | The name of the Kubernetes service that exposes the OpenAPI schema. |
source.kube.targetRef.port | The port of the Kubernetes service. |
source.kube.path | The path on the service where the OpenAPI schema is available, such as /openapi.json or /swagger.json. |
servedBy | Optional. If not specified, the controller infers the backend from source.kube.targetRef. |
Verify ApiDocs
List the ApiDocs in your namespace. Verify that their
READYstatus is set toTrue.kubectl get apidoc -n defaultExample output:
NAME SOURCE READY petstore-apidoc Manual True petstore-url-apidoc URL True petstore-kube-apidoc Kube TrueIf an ApiDoc does not show
Ready=True, describe the resource to see error details.kubectl describe apidoc <name> -n defaultCommon issues that you might encounter include:
- The OpenAPI schema exceeds the 1MB size limit.
- The schema contains invalid OpenAPI syntax.
- The
servedByfield is missing or the referenced service is unreachable. - For URL sources, the endpoint is not accessible or the HTTPS certificate is invalid.