Getting Started Tutorial¶
This tutorial walks you through publishing an API and managing consumer access using the Kuadrant developer portal.
By the end, you will have:
- Deployed an API with authentication and tiered rate limiting
- Published it as an API Product via Backstage
- Requested and approved API access
- Used the generated API key
Prerequisites¶
- Kubernetes cluster with Kuadrant operator installed
- Gateway API CRDs and a gateway provider (Istio or Envoy Gateway)
- RHDH/Backstage with Kuadrant plugins installed (see Installation Guide)
Part 1: Platform Engineer Setup¶
These steps are performed by a platform engineer or API owner with cluster access. They prepare the infrastructure and policies that enable API access management.
Step 1: Deploy the API¶
Create the namespace and deploy the toystore application:
kubectl apply -f - <<EOF
apiVersion: v1
kind: Namespace
metadata:
name: getting-started-tutorial
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: toystore
namespace: getting-started-tutorial
labels:
app: toystore
spec:
replicas: 1
selector:
matchLabels:
app: toystore
template:
metadata:
labels:
app: toystore
spec:
containers:
- name: toystore
image: quay.io/kuadrant/authorino-examples:talker-api
ports:
- containerPort: 3000
env:
- name: PORT
value: "3000"
---
apiVersion: v1
kind: Service
metadata:
name: toystore
namespace: getting-started-tutorial
spec:
selector:
app: toystore
ports:
- protocol: TCP
port: 80
targetPort: 3000
EOF
Wait for the deployment to be available:
kubectl -n getting-started-tutorial wait --timeout=120s --for=condition=Available deployment/toystore
Step 2: Create the Gateway and HTTPRoute¶
Create a Gateway and expose the API via an HTTPRoute.
kubectl apply -f - <<EOF
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: getting-started-gateway
namespace: getting-started-tutorial
spec:
gatewayClassName: istio
listeners:
- name: http
protocol: HTTP
port: 80
allowedRoutes:
namespaces:
from: All
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: getting-started-toystore
namespace: getting-started-tutorial
spec:
parentRefs:
- name: getting-started-gateway
namespace: getting-started-tutorial
hostnames:
- getting-started.toystore.com
rules:
- matches:
- path:
type: PathPrefix
value: /
method: GET
backendRefs:
- name: toystore
port: 80
EOF
Verify:
Step 3: Configure API Key Authentication¶
Create an AuthPolicy requiring API key authentication. Keys are stored as Kubernetes Secrets with the label app: getting-started-toystore-api (matching the APIProduct name we'll create in Step 5).
kubectl apply -f - <<EOF
apiVersion: kuadrant.io/v1
kind: AuthPolicy
metadata:
name: getting-started-auth
namespace: getting-started-tutorial
spec:
targetRef:
group: gateway.networking.k8s.io
kind: HTTPRoute
name: getting-started-toystore
rules:
authentication:
"api-key-users":
apiKey:
selector:
matchLabels:
app: getting-started-toystore-api
allNamespaces: true
credentials:
authorizationHeader:
prefix: APIKEY
EOF
Verify the policy is enforced:
Step 4: Create Plan Tiers¶
Create a PlanPolicy defining access tiers with different rate limits.
kubectl apply -f - <<EOF
apiVersion: extensions.kuadrant.io/v1alpha1
kind: PlanPolicy
metadata:
name: getting-started-plans
namespace: getting-started-tutorial
spec:
targetRef:
group: gateway.networking.k8s.io
kind: HTTPRoute
name: getting-started-toystore
plans:
- tier: gold
predicate: |
has(auth.identity) && auth.identity.metadata.annotations["secret.kuadrant.io/plan-id"] == "gold"
limits:
daily: 100
- tier: silver
predicate: |
has(auth.identity) && auth.identity.metadata.annotations["secret.kuadrant.io/plan-id"] == "silver"
limits:
daily: 50
- tier: bronze
predicate: |
has(auth.identity) && auth.identity.metadata.annotations["secret.kuadrant.io/plan-id"] == "bronze"
limits:
daily: 10
EOF
Verify:
The platform engineer setup is complete. The HTTPRoute is now available for API owners to publish via the developer portal.
Part 2: API Owner Workflow¶
These steps are performed by an API owner using the Backstage UI.
Step 5: Publish as an API Product¶
- Navigate to your Backstage instance
- Go to the Kuadrant/API Products page from the sidebar
- Click Create API Product
- Select the getting-started-toystore HTTPRoute from the dropdown
- Fill in the details:
- Name:
getting-started-toystore-api - Display Name:
Getting Started Toystore API - Description:
Toystore API for the getting started tutorial - Approval Mode: Manual
- Publish Status: Published
- Click Create
The plugin creates an APIProduct resource in Kubernetes. The PlanPolicy tiers (gold, silver, bronze) are automatically discovered and shown on the API Product page.
Verify via kubectl:
Part 3: API Consumer Workflow¶
These steps are performed by an API consumer using the Backstage UI.
Step 6: Discover the API¶
- Navigate to the API in the Backstage catalog
- Find Getting Started Toystore API in the list
- Click to view the API details
The API page shows:
- Overview tab with description and metadata
- Definition tab with the API specification
- API Keys tab for requesting access
- API Product Info tab with plan tiers and rate limits
Step 7: Request API Access¶
- Click the API Keys tab
- Click Request API Access
- Select a tier (e.g. silver - 50 requests/day)
- Provide a use case description (e.g. "Testing API integration")
- Click Submit
Backstage generates the key value, creates a Secret in your consumer namespace, and creates an APIKey referencing it. The controller creates an APIKeyRequest in the APIProduct's namespace for owner review. The key remains Pending until approved.
Part 4: API Owner Approval¶
Back to the API owner workflow.
Step 8: Approve the Request¶
- Navigate to the Kuadrant page
- Go to the API Key Approval section and look for requests with Pending status
- Find the request and review the details:
- Requester
- Requested tier
- Use case
- Click Approve
Backstage records the decision in an APIKeyApproval. The developer-portal-controller updates the APIKey's status conditions to Approved and copies the consumer's key value into an enforcement Secret in the Kuadrant namespace. That enforcement Secret makes the key usable for API authentication.
Part 5: Using the API¶
Back to the API consumer.
Step 9: Retrieve and Use the API Key¶
- Navigate to the Getting Started Toystore API in the catalog
- Click the API Keys tab
- Find your approved key
- Click the eye icon to reveal the secret
- Copy the API key value
Test the API:
export GATEWAY_IP=$(kubectl get gateway getting-started-gateway -n getting-started-tutorial -o jsonpath='{.status.addresses[0].value}')
export API_KEY="your-api-key-here"
curl -H "Host: getting-started.toystore.com" -H "Authorization: APIKEY $API_KEY" http://$GATEWAY_IP/
You should receive a response from the toystore API.
Cleanup¶
Delete the tutorial APIKey from Backstage and remove its consumer Secret (see Deletion Flow). Then remove the API infrastructure namespace:
Summary¶
| Persona | Actions |
|---|---|
| Platform Engineer | Deploy API, create Gateway/HTTPRoute, configure AuthPolicy and PlanPolicy |
| API Owner | Publish API Product via Backstage, approve access requests |
| API Consumer | Discover APIs, request access, use API keys |
Variant: OIDC Authentication¶
This section shows how to configure the tutorial API with OIDC/JWT authentication instead of API key authentication. This approach delegates authentication to an external identity provider.
Prerequisites¶
- An OIDC-compliant identity provider (e.g., Keycloak, Auth0, Azure AD)
- The issuer URL from your identity provider (e.g.,
https://keycloak.example.com/realms/myrealm) - Client credentials for testing (client ID and secret)
Modified Step 3: Configure OIDC Authentication¶
Replace the API key AuthPolicy from Step 3 with this OIDC-based AuthPolicy:
kubectl apply -f - <<EOF
apiVersion: kuadrant.io/v1
kind: AuthPolicy
metadata:
name: getting-started-auth
namespace: getting-started-tutorial
spec:
targetRef:
group: gateway.networking.k8s.io
kind: HTTPRoute
name: getting-started-toystore
rules:
authentication:
"oidc-users":
jwt:
issuerUrl: https://your-oidc-provider.example.com/realms/your-realm
credentials:
authorizationHeader:
prefix: Bearer
EOF
Replace https://your-oidc-provider.example.com/realms/your-realm with your actual OIDC issuer URL.
Modified Consumer Workflow¶
When using OIDC authentication, API consumers follow a different workflow:
- Go to the Kuadrant/API Products page from the sidebar
- Find Getting Started Toystore API in the list
- Click to view the API details
- View the OIDC tab showing:
- Identity Provider URL
- Token Endpoint
- Example curl command for obtaining a token
- Obtain a token from the identity provider (Example using Client Credentials Flow):
export TOKEN_ENDPOINT="https://your-oidc-provider.example.com/realms/your-realm/protocol/openid-connect/token"
export CLIENT_ID="your-client-id"
export CLIENT_SECRET="your-client-secret"
# Get access token
TOKEN=$(curl -X POST \
-d "grant_type=client_credentials" \
-d "client_id=$CLIENT_ID" \
-d "client_secret=$CLIENT_SECRET" \
$TOKEN_ENDPOINT | jq -r '.access_token')
- Use the token to call the API:
export GATEWAY_IP=$(kubectl get gateway getting-started-gateway -n getting-started-tutorial -o jsonpath='{.status.addresses[0].value}')
curl -H "Host: getting-started.toystore.com" -H "Authorization: Bearer $TOKEN" http://$GATEWAY_IP/
Key Differences¶
| Aspect | API Key Authentication | OIDC Authentication |
|---|---|---|
| Credential Source | Generated by Backstage before approval | External identity provider |
| Approval Workflow | Yes (manual or automatic) | No (managed by identity provider) |
| APIKey Resources | Required | Not needed |
| Consumer Workflow | Request → Approve → Retrieve key | View provider → Obtain token |
| Use Cases | Internal APIs, dev environments | Enterprise SSO, external APIs, stronger auth requirements |
Next Steps¶
- RBAC Permissions - Configure role-based access control
- API Reference - Backend API endpoints
- Kuadrant Documentation - Full Kuadrant operator documentation