Ricky Moorhouse

Blog

First Potatoes

Today I harvested our first row of potatoes from our raised beds:

First potatoes

Quite pleased with them, and looking forward to tasting them!

Portsmouth Harbour

Garden Meadow

Avoid delays from validate compilation in your APIs

Castle views

Customising the API invocation hostname in v10 Reserved Instance

API Connect toolkit with GitHub Actions - re-usable step

API Connect Remote Gateway with IBM Cloud Satellite

API Connect Reserved instance provides the ability to add remote API gateways so that you can co-locate the gateway service with your back-end systems for improved performance. With the new announcement of IBM Cloud Satellite, you can make use of this to securely expand your API Connect footprint across cloud providers and into the on-premise datacenter close to where your applications are running.

Create your Satellite location

To create a Satellite location you will need 3 hosts for the control plane, and at least one host to deploy DataPower on. For each of the hosts you will need to do the following:

  • Set up the host prior based on the host requirements for Satellite.

  • Register the host for RedHat updates using subscription-manager register - then apply a subscription to it in the RedHat Customer Portal

  • Refresh the packages and enable the repositories

subscription-manager refresh
subscription-manager repos --enable rhel-server-rhscl-7-rpms
subscription-manager repos --enable rhel-7-server-optional-rpms
subscription-manager repos --enable rhel-7-server-rh-common-rpms
subscription-manager repos --enable rhel-7-server-supplementary-rpms
subscription-manager repos --enable rhel-7-server-extras-rpms
  • Run the attach script obtained from the IBM Cloud Satellite UI to attach the host.

For the three hosts to form the control plane, you will need to assign them to the Satellite control plane through the UI or CLI.

Install DataPower in the Satellite location

  • Download the DataPower rpms from your reserved instance.
  • Install DataPower on your RHEL VM. In order to do this along with the pre-reqs I used the following commands:
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install schroot ipvsadm telnet
yum install idg_cloud1.10011.common.x86_64.rpm idg_cloud1.10011.image.x86_64.rpm
  • Create a link endpoint pointing to the API Connect Gateway management endpoint (usually port 3000)

Configure DataPower for API Connect

  • Follow the steps to configure your DataPower for use with API Connect.
  • For the certificates, in order to avoid a hostname mismatch create a self-signed keypair for the management interface for the hostname generated for your link endpoint.

Configure Certificate Manager service

Add Remote gateway to your reserved instance

  • Register your gateway in your API Connect Reserved Instance, filling in the details as follows:
    • Management endpoint - enter the full URL and port generated by IBM Cloud Satellite for the Link Endpoint prefixed with https://
    • Certificate - the certificate to present for the mutual TLS communication with the Gateway management
    • CA bundle - the certificate in certificate manager to use to verify the gateway management endpoint (either your CA or the certificate itself)
    • Base URL - the endpoint you want APIs to be called through - should map to the API gateway address configured in the API Connect Gateway service either directly or through a load balancer.

API Connect v10 Reserved - authentication for CI/CD

Currently the v10 Reserved Instance of API Connect doesn't yet have a simple approach for headless use of the CLI toolkit. The following details how to use an IBM Cloud IAM bearer token with the API Connect CLI and REST API in a headless environment such as a CI/CD pipeline.

For interactive use of the API Connect CLI, you can login using the --sso option, retreive an api key with your browser and provide that to the CLI for example:

apic-slim login --server {apic-api-endpoint} --sso

However if you want to use the CLI in a non-interactive context such as a CI/CD pipeline you need to retrieve an IBM Cloud IAM Bearer token for the toolkit to use. This can be obtained using ibmcloud iam oauth-tokens and then placed in ~/.apiconnect/token for the apic CLI to use.

The token file needs to contain:

{apic-api-endpoint}/api: |
  refresh_token: ""
  access_token: {access_token} 

This can be done programmatically using something like this:

ibmcloud iam login --apikey {api-key}
ic iam oauth-tokens | sed 's/IAM token:  Bearer /api.9a6e-bd639816.us-south.apiconnect.cloud.ibm.com\/api: |\n  refresh_token: ""\n  access_token: /' > ~/.apiconnect/token

apic orgs --my --server {apic-api-endpoint}
production    [state: enabled]   https://api...apiconnect.cloud.ibm.com/api/orgs/9123ae60-427c-4997-8a6b-ddd75b169bfb
test-porg     [state: enabled]   https://api...apiconnect.cloud.ibm.com/api/orgs/b73708ea-a7b5-4d27-b562-80767e0b238e

Invoking the API Connect REST APIs

To invoke the API Connect REST APIs in Reserved Instance v10, you can use an IBM Cloud IAM token which can be obtained using the ibmcloud iam oauth-tokens CLI command or with an API call as detailed in the IAM API documentation. This token can then be used as a bearer token to invoke the API Connect REST APIs.

The full process looks like this:

Firstly use your IBM Cloud API key to retrieve an IAM token

curl -X POST \
  "https://iam.cloud.ibm.com/identity/token" \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --header 'Accept: application/json' \
  --data-urlencode "grant_type=urn:ibm:params:oauth:grant-type:apikey" \
  --data-urlencode "apikey=[your api key]"

{"access_token":"[access token would be here]","refresh_token":"not_supported","token_type":"Bearer","expires_in":3600,"expiration":1615370557,"scope":"ibm openid"}

Then take the value of the access_token and use it to call the API Connect API e.g.

curl https://{{ api_host }}/api/orgs \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer [access_token]

{
  "total_results": 2,
  "results": [
    {
      "type": "org",
      "org_type": "provider",
    ...
    }
  ]
}

2021 Reading Log

  • Rising Moon (Jesse McDermitt #19) - Wayne Stinnett
  • The Holly Lin Series - Robert Swartwood
  • The Dark Archive (Invisible Library #7) - Genevieve Cogman
  • Murder in the Caribbean (Death in Paradise #4) - Robert Thorogood
  • The Marlow Murder Club - Robert Thorogood
  • List of Secrets - DF Hart
  • Interference - Brad Parks
  • Codename Villanelle (Killing Eve #1) - Luke Jennings
  • No Tomorrow (Killing Eve #2) - Luke Jennings
  • Double Agent - Tom Bradby
  • Habitat Zero (Sam Reilly #15) - Christopher Cartwright
  • On the Run (Ryan Kaine #1) - Kerry J Donovan
  • On the Rocks (Ryan Kaine #2) - Kerry J Donovan
  • On the Defensive (Ryan Kaine #3) - Kerry J Donovan
  • On the Attach (Ryan Kaine #4) - Kerry J Donovan
  • On the Money (Ryan Kaine #5) - Kerry J Donovan
  • On the Wing (Ryan Kaine #7) - Kerry J Donovan
  • On the Hunt (Ryan Kaine #8) - Kerry J Donovan
  • Perfect Record (DCI Jones #1) - Kerry J Donovan
  • The Law of the Heart - Boris Starling
  • Steady As She Goes (Jesse McDermitt #21) - Wayne Stinnett
  • Hard Vengeance (Jon Reznick #9) - JB Turner
  • Dark Sky (Joe Pickett #21) - CJ Box
  • The Cipher (Nina Guerrera #1) - Isabella Maldonado
  • A Different Dawn (Nina Guerrera #2) - Isabella Maldonado
  • The Quantum Curators and the Fabergé Egg (Quantum Curators #1) - Eva St John
  • Kings of the Yukon: An Alaskan River Journey - Adam Weymouth
  • The Quantum Curators and the Enemy Within (Quantum Curators #2) - Eva St John
  • The Quantum Curators and the Missing Codex (Quantum Curators #3) - Eva St John
  • The Cove (Summer Suspense #1) LJ Ross
  • The Apollo Muders - Chris Hadfield
  • On The Edge (Ryan Kaine #6) - Kerry J Donovan
  • On the Outside (Ryan Kaine #9) - Kerry J Donovan
  • Wayward Sons (Jerry Snyder #1) - Wayne Stinnett
  • All Ahead Full (Jesse McDermitt #22) - Wayne Stinnett