Skip to content

API collections

This tutorial explains how to create and manage API collections.


Introduction

In this tutorial, you'll learn how to create and manage API collections with CRDs.

Collections are managed with the API collection selector.

Please check the official Kubernetes documentation if you want to learn more about Labels and Selectors.


CRD

This example CRD creates an API collection with the name crm-all and all APIs with the matching label crm will be part of this collection.

All user of the group crm-group will have access to this API collection.

Field Description Required
pathPrefix PathPrefix used by the collection, for example /crm.
The PathPrefix will append the URL of the API Gateway.
This would make the API collection accessible under api.example.com/crm.
Only absolute paths are accepted for this setting.
No
apiSelector.matchLabels Select APIs based on Labels. No
apiCollectionSelector.matchExpressions Select APIs based on Selectors. No

Save the following YAML file as api-collection.yaml.

Example

apiVersion: hub.traefik.io/v1alpha1
kind: APICollection
metadata:
  name: crm-all
  labels:
    module: crm
spec:
  groups:
    - crm-group
  pathPrefix: "/crm"
  apiSelector:
    matchLabels:
      module: crm

Use kubectl commands to deploy the collection CRD:

kubectl apply -f api-collection.yaml

Summary

In this tutorial, you learned how to create and manage API collections with CRDs and through the UI.


What's next