Step 3. Prepare SimpleAPI Configuration

Before deploying SimpleAPI, you need to gather information from several sources to prepare the configuration YAML file.

Whitelist Configuration

For each brand that you use, you need to gather branding URLs and decide on a Marketplace code. These codes will be used by resellers to authenticate against the API and to tell SimpleAPI which brand to authenticate against.

For example, if you have multiple L1 resellers (one for each country) under which your L2 resellers exist, you can map each of those L1 brands to country codes.

Note: If you are deploying the SimpleAPI mock application, you will need to create a separate whitelist configuration file with its own name for the mock application.

  1. Create the whitelist-configmap.yaml file:

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: whitelist-configmap
    data:
      marketplaces.txt: |
        {marketplace code 1} {marketplace brand 1}
        {marketplace code 2} {marketplace brand 2}
      logins.txt

    The marketplaces.txt is the list of marketplace codes mapped onto the brand URLs. Resellers will use these marketplace codes when requesting a token and depending on that code, SimpleAPI will direct the authentication to the chosen brand.

    For example, the value us https://cp.us.brand.com will map the marketplace us to the branding URL for cp.us.brand.com.

  2. Apply the ConfigMap resource using this command:

    kubectl apply -f whitelist-configmap.yaml

Whitelist Configuration for Mock API

When operating the SimpleAPI Mock application, you will need to provide a list of user names that can access the API. These user names are stored inside a separate ConfigMap from the production application.

Note: User names should be randomly generated in such a way that they cannot be guessed. As there is no password validation, the user name is the only thing that obfuscates access to data stored in the Mock API’s memory.

  1. Create the whitelist-configmap-mock.yaml file:

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: whitelist-configmap-mock
    data:
      logins.txt: |
        9zEYKGrvPZ4u@example.org www.example.org
        XseVvqQ78ep6@example.org www.example.org

    The logins.txt is the list of user names that can be used to access Mock API. The URL behind each user name will be ignored in Mock API mode.

  2. Apply the ConfigMap resource using this command:

    kubectl apply -f whitelist-configmap.yaml

JWT Key

SimpleAPI uses JWT to sign all API requests. For this purpose, you must create a JWT Key add it to the configuration. To generate a JWT key use, for example, this command:

pwgen 48 1

Copy the generated key from the output and add it to the configuration YAML file in the jwtkey parameter.

Reports Database

You need to add the information about the database you deployed in the previous step to the corresponding parameters in the YAML file:

  • Database host - dshost.
  • Database port - dsport.
  • Database name - dsdbname.
  • Database login - dslogin.
  • Database password - dspassword.

You need to add this information to the configuration YAML file under the reports section.

Alternatively, the database information can be stored in a Kubernetes Secret. In this case, the Secret’s reference name should be used in the db_secret parameter.

Note: In this first release, the reports.enabled configuration parameter should be set to false, because currently there is no automatic cleanup process implemented to empty old data. If you enable reporting, please monitor database usage and clean up old records manually.

Onboarding Service

For the onboarding service, you will need perform the following steps.

  1. Generate a key and secret that will be stored in the oauthkey oauthsecret parameters and used for authentication of SimpleAPI requests in the Azure API Management service (APIM).

    You can generate them using the uuidgen command.

  2. If you are using APIM, obtain the following information about it.
    • Management API BaseURL. This should be stored in the baseurl parameter. To obtain it, preform these steps:
      1. Open the API Gateway Overview page in the Azure portal.
      2. Go to Management API under the Deployment + Infrastructure section.
      3. Ensure that Enable Management REST API is set to Yes.
      4. Copy the value from the field Management API URL.
    • Management API Key. This should be stored in the azuresubscription parameter.
      1. Open the API Gateway Overview page in the Azure portal
      2. Go to Management API under the Deployment + Infrastructure section.
      3. Ensure that Enable Management REST API is set to Yes.
      4. Copy the value from the field Primary Key.
    • Management API Subscription ID. This should be stored in the cmpapisubscription parameter.
      1. Open the API Gateway Overview page in the Azure Portal
      2. Copy the URL from the browser starting at /subscription, but remove /overview from the end. It should look similar to this: /subscriptions/7f702c53-060f-41a8-a665-9cef8ec0ad73/resourceGroups/cmpapi/providers/Microsoft.ApiManagement/service/cmpapi
    • SimpleAPI product ID. This should be stored in the cmpapiproduct.
      1. Open the API Gateway Overview page in the Azure portal.
      2. Go to Products under the APIs section.
      3. Select the product that you configured for SimpleAPI.
      4. Go to the Settings page.
      5. Copy the value from the field Id on that page.
  3. Add the gathered parameter values to the configuration YAML file under the onboarding section.

Monitoring

SimpleAPI can be monitored using Prometheus & Grafana. For this to work, you must add the username and password to the configuration YAML file under the monitoring section.

CloudBlue, an Ingram Micro business, uses cookies to improve the usability of our site. By continuing to use this site and/or logging in you are accepting the use of these cookies. For more information, visit our Privacy Policy.