Add usage plans

Decide on the usage plans that you want to make visible to your users in the developer portal.

Add usage plans

You can add information about the usage plan, such as a display name and a description that you want to show to users that access the developer portal.

  1. Get the usage plans that you set up earlier. The usage plans are set in the rate limit server configuration.

    kubectl get ratelimitserverconfigs usage-plans -n gloo-mesh-addons -o yaml
    
  2. Select the usage plans that you want to include in your portal. To reference a usage plan in your portal resource, you need to get the simpleDescriptors.value value. In the following example, the usage plan value is bronze.

       ...
       spec:
         destinationServers:
         - port:
             name: grpc
           ref:
             cluster: $CLUSTER_NAME
             name: rate-limiter
             namespace: gloo-mesh-addons
         raw:
           setDescriptors:
           - rateLimit:
               requestsPerUnit: 1
               unit: MINUTE
             simpleDescriptors:
             - key: userId
             - key: usagePlan
               value: bronze
       

  3. Add the usage plan values to the usagePlans section of your portal resource. Make sure to enter the usage plan value that you retrieved in the previous step in the spec.usagePlans.name field. You can optionally add information, such as the display name or a description for each usage plan that is shown to users that access the developer portal. For example, you might include pricing details, rate limiting, or access instructions in the plan description.

    apiVersion: apimanagement.gloo.solo.io/v2
    kind: Portal
    metadata:
      name: developer-portal
      namespace: gloo-mesh-addons
    spec:
      domains:
        - "developer-portal.example.com"
      portalBackendSelectors:
        - selector:
            labels:
              app: gloo-mesh-portal-server
      usagePlans:
        - name: bronze
          displayName: "Bronze Plan"
          description: "A basic usage plan"
        - name: silver
          description: "A better usage plan"
        - name: gold
          description: "The best usage plan!"
      apis:
        - labels:
            portal: dev-portal
       

Next steps

Next, create the portal backend.

When you are done with trying out Portal, you can clean up all of the resources that you created.