Skip to content

GuilhermeCamposo/demo_3scale

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Comprehensive 3scale Demo

This repository demonstrates how to use many of 3scale’s features.

Demo Last Tested with

  • OCP 4.13

  • oc client >= 4.13

  • 3scale 2.14

3scale Installation

Parameters

Parameter Example Value Definition

token

sha256~vFanQbthlPKfsaldJT3bdLXIyEkd7ypO_XPygY1DNtQ

access token for a user with cluster-admin privileges

server

https://api.mycluster.domain.com:6443

OpenShift cluster API URL

How to run the playbook

ansible-playbook -e token=${token} -e server=${server} playbook.yml

Manual steps

After the installation there are some steps that need to be done using 3scale’s console.

Enable portal

Update Provider Name

add a name for the provider here: https://${3scale-admin-portal}/p/admin/account/edit

Update Developer Portal website

In the dev_portal folder you will find an automation to update the Developer Portal in a specific environment. Run the playbook in the same way you run the installation playbook.

Modifications

  • Multiple plans

Multiple plans selection
  • Search docs

Search DOC
  • Select API

Select API

Using the 3scale CLI

Connect to tenants

export UAT_TOKEN, PROD_TOKEN and DOMAIN as environment variables, then run the following command.

3scale remote add -k uat https://${UAT_TOKEN}@uat-admin.apps.${DOMAIN}
3scale remote add -k prod https://${PROD_TOKEN}@prod-admin.apps.${DOMAIN}

Copy Database API Backend and Product

3scale backend copy -k -s prod -d uat database-backend
3scale product copy -k -s prod -d uat database-api

Copy Database API Application Plan

3scale application-plan export prod database-api basic -k > basic-plan.yml
3scale application-plan import uat -f basic-plan.yml database-api -k

Create an Application for the new Environment

Find an account:

3scale account find uat admin+test@example.com -a -k

Create the application with the account information:

3scale application create -k uat ${ACCOUNT_ID} ${SERVICE_ID} basic 'Test App' --application-id=${APP_ID} --application-key=${USER_KEY} --redirect-url=' ' --description='some description'

How to present this demo?

this demo has many different features that can me demonstrated for different purpouse. I will document here some things you may need to know.

How to log in 3scale’s console and SSO?

both are using self-generated crendentials.

  1. Look for the system-seed secret for the 3scale’s credentials in the demo-3scale project

  2. Look for the credential-example-keycloak for SSO’s crendentials in the demo-rhsso project

How to use the Postman collection?

the Postman collection has 3 requests:

  1. Request SSO token

  2. GET Database API

  3. POST Database API

before starting using it, update the cluster_domain variable to reflect your OpenShift enviroment.

To be able to get an valid token from SSO, you need to update the Request SSO Token headers with the credentials generated for the application. Go to SSO console and retrieve the client_id and client_secret from the latest created client.

How to present SMTP configuration?

SMTP configuiration is required for 3scale’s notification system to be able to send emails. For this demo we can mock one using Mailhog. To access it just hit the URL:

URL=$(oc get route mailhog -n demo-tools -o jsonpath='{.spec.host}')
echo https://$URL

How to present 3scale and Registry integration with Tekton?

This demo comes with a pipeline that downloads an Open API spec from Registry, publish it in 3scale and creates a configmap for an application to consume. You can find it in the demo-cicd project. To demonstrate that feature you need an application like the one here. You will need to configure that API on 3scale.

Demo notes:

  1. 3scale ERD

    3scale entities relations
  2. component architecture:

    oidc apis
  3. env variables

     $ export OIDC_PROVIDER_HOSTNAME=<hostname of RHBK>
     $ export OIDC_TOKEN_URL=https://$OIDC_PROVIDER_HOSTNAME/auth/realms/threescale-apps/protocol/openid-connect/token
     $ export API_SSO_CLIENT_ID=<3scale app id>
     $ export API_SSO_CLIENT_CRED=<3scale app secret>
     $ export API_GW_HOSTNAME=<hostname of 3scale APIcast gw>
     $ export API_GW_URL=https://$API_GW_HOSTNAME/backend
  4. Retrieve tokens and parse for access_token :

    $ TKN=$(curl -X POST "$OIDC_TOKEN_URL" \
                -H "Content-Type: application/x-www-form-urlencoded" \
                -d "grant_type=client_credentials" \
                -d "client_id=$API_SSO_CLIENT_ID" \
                -d "client_secret=$API_SSO_CLIENT_CRED" \
                -d "scope=openid" \
                | sed 's/.*access_token":"//g' | sed 's/".*//g')
  5. Inspect token:

    $ jq -R 'split(".") | .[] | @base64d | fromjson' <<< $TKN | jq .
  6. Populate backend service with an Attendee resource (in json representation):

    $ curl -v \
        -H "Authorization: Bearer $TKN" \
        -H "Content-Type: application/json" \
        -X POST $API_GW_URL \
        -d '{"name": "test", "email": "test@gmail.com" }'
  7. Retreive list of Attendee resources:

    $ curl -v \
        -H "Authorization: Bearer $TKN" \
        -X GET $API_GW_URL

About

Comprehensive demo about 3scale

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published