Previously, you set up Gloo Gateway, the portal server, and several sample apps. In this tutorial, you bundle your apps into ApiProducts that you later expose in a frontend developer portal.

Before you begin

Complete the portal setup tutorial.

Verify your ApiDocs

With Gloo Portal, you can share REST API services that conform to the OpenAPI specification (OAS), v2 or v3. Gloo uses an ApiDoc custom resource to identify the OpenAPI spec for all of the API services in your environment. For more options to create ApiDocs, see the Create ApiDocs guide.

  1. Describe the app services that you created in the previous tutorial. Check the annotations of the services. For more information about the annotations or to update them, see the Create ApiDocs guide.

    Example output:

      annotations:
       gloo.solo.io/scrape-openapi-pull-attempts: "60"
       gloo.solo.io/scrape-openapi-retry-delay: 1s
       gloo.solo.io/scrape-openapi-source: /swagger.json
       gloo.solo.io/scrape-openapi-use-backoff: "false"
      
  2. List the ApiDocs in each app’s namespace.

      kubectl get apidocs -A
      
  3. Describe one of the ApiDocs, and verify that the ApiDoc has the OpenAPI spec for the service. For more information, see the Verify ApiDocs guide.

      kubectl describe apidocs -n tracks
      

    Example output:

      ...
    Spec:
      Openapi:
        Inline String:  {"components":{"schemas":{"Author":{"properties":{"id":{"type":"string"},"name":{"type":"string"},"photo":{"type":"string"}},"type":"object"},"Module":{"properties":{"authorId":{"type":"string"},"content":{"type":"string"}
      

Create API products

API products are what your users find and use in your developer portal. The API products might represent an entire product with many APIs, such as a pet store, or a large feature within the product that you want to treat separately, such as a checkout cart. Each API product might represent a particular version of your API.

API products target the route that the backing app is available on. This way, you have greater flexibility in how you structure your API products. For example, you might create several HTTPRoutes that are backed by the same app. For each route, you can apply different routing rules and policies, such as rate limits and external auth. Then, you can create different ApiProducts for different routes.

  1. Create an ApiProduct for the Tracks app. Notice that the ApiProduct includes the portal metadata to describe the ApiProduct and configures a label that you can use to select the ApiProduct later, expose-portal: "true". You create the ApiProduct in the same namespace as the HTTPRoute. This way, you do not need to create a Kubernetes ReferenceGrant to let the ApiProduct refer to the HTTPRoute.

      kubectl apply -n gloo-system -f- <<EOF
    apiVersion: apimanagement.gloo.solo.io/v2
    kind: ApiProduct
    metadata:
      labels:
        expose-portal: "true"
      name: tracks-svc-api-product
      namespace: gloo-system
    spec:
      portalMetadata:
        apiProductId: "tracks"
        apiProductDisplayName: "Catstronauts Course Tracks"
        apiVersion: "v1"
        title: "Catstronauts REST API"
        description: "REST API for Catstronauts to retrieve data for tracks, authors and modules."
        termsOfService: "You must authenticate to use this API! And other Terms of Service."
        contact: "support@example.com"
        license: "License info, such as MIT"
        lifecycle: "Supported"
        customMetadata:
          compatibility: "None"
      targetRef:
        group: gateway.networking.k8s.io
        kind: HTTPRoute
        name: tracks-route
        namespace: gloo-system  
    EOF
      
  2. Repeat the previous steps for the Petstore ApiProduct.

      kubectl apply -n gloo-system -f- <<EOF
    apiVersion: apimanagement.gloo.solo.io/v2
    kind: ApiProduct
    metadata:
      labels:
        expose-portal: "true"
      name: petstore-svc-api-product
      namespace: gloo-system
    spec:
      portalMetadata:
        apiProductId: "petstore"
        apiProductDisplayName: "Pet Store"
        apiVersion: "v1"
        title: "Pet Store REST API"
        description: "Totally awesome API for all things pets!"
        termsOfService: "You must authenticate to use this API! And other Terms of Service."
        contact: "support@example.com"
        license: "License info, such as MIT"
        lifecycle: "Supported"
        customMetadata:
          compatibility: "None"
      targetRef:
        group: gateway.networking.k8s.io
        kind: HTTPRoute
        name: petstore-route
        namespace: gloo-system
    EOF
      
  3. Check the status of your ApiProducts. Notice the FAILED message that indicates no portal was found. Your ApiProducts are not healthy until you create a portal that shares the ApiProducts with your end users.

      kubectl get apiproducts -n gloo-system -o yaml | grep status -A5
      

    Example output:

      status:
      state:
        State:
          approval: FAILED
          message: no portal found for APIProduct tracks-svc-api-product.gloo-system
          observedGeneration: 1
      

Next steps

Next, create the backend and frontend for your developer portal..