Advertisements
RSS

Tag Archives: Docker

How to run the 3Scale APICast Gateway in a Docker container ?

With the rise of API popularity and the necessity for decent API Management some relatively new players emerged. And by know almost all are acquired by bigger fish in the software pond. One of these leading API Management software companies was 3Scale and in 2016 is was acquired by Red Hat. 3Scale then was a SaaS API Management offering only. Soon after the acquisition however Mike Piech, vice president and general manager of middleware at Red Hat, wrote in a blog post:

“3scale is today offered in an as-a-Service model and joins Red Hat OpenShift Online and Red Hat Mobile Application Platform in that format. We plan to quickly create an on-prem version and open source the code in the Red Hat way.”

The cloud hosted API gateway service APICast was published to GitHub. And in Q2 2017 the officially announcement was there that the Red Hat 3Scale API management platform was available as a Docker container and stand-alone installation for deployment on-premise. So now the implementation choice roughly consists of full SaaS and 3 on-premise variations as vanille Docker, Red Hat OpenShift and stand-alone.

This blogpost will show the steps and commands how to run the 3Scale APICast Gateway in “vanille” Docker containers.

High Level Overview

The commands

What we need:

  • Endpoint for the local API to hit, like api.rubix.local
  • Endpoint of the 3Scale SaaS environment, like jvzoggel-admin.3scale.net)
  • provider api key which is something like 93b21fc40335f58ee3a93d5a5c343 and can be found under your 3Scale SaaS account
  • user key which is shown at the bottom of the SaaS API Configuration screen in the curl example or can be found in Application -> your app

API endpoint to hit

 

First we will create a rubix.local Docker Network for our Apicast and API client nodes to run in:

jvzoggel$ docker network create rubix.local
142fd0f9e4a5392f2cdd90c2a625edf655f89a56b026e3c2082060521a39f6b5

We will start the 3Scale APICast Gateway docker image and configure it to port forward 8080, connect to the rubix.local network and use the environment property THREESCALE_PORTAL_ENDPOINT to make connection to our 3Scale SaaS environment to retrieve the API configuration.

jvzoggel$ docker run --name apicast --net=rubix.local --rm -p 8080:8080 -h apicast.rubix.local -e THREESCALE_PORTAL_ENDPOINT=https://PROVIDERKEY@jvzoggel-admin.3scale.net registry.access.redhat.com/3scale-amp21/apicast-gateway:1.4-2
dnsmasq[8]: started, version 2.76 cachesize 1000
dnsmasq[8]: compile time options: IPv6 GNU-getopt DBus no-i18n IDN DHCP DHCPv6 no-Lua TFTP no-conntrack ipset auth no-DNSSEC loop-detect inotify
dnsmasq[8]: using nameserver 8 #0 dnsmasq[8]: reading /etc/resolv.conf
dnsmasq[8]: using nameserver options#0
dnsmasq[8]: using nameserver 127.0.0.11#53
dnsmasq[8]: cleared cache

The API Gateway is running as apicast.rubix.local, the same endpoint URI as configured in the SaaS environment. So it’s time to hit it with our first request. We are going to use a Centos docker image as an API client and run it in interactive mode.

jvzoggel$ docker run --name centos --net=rubix.local --rm -it -h centos.rubix.local centos:latest bash
[root@centos /]# hostname
centos.rubix.local

We can first check if both docker instances can connect to each other with a ping. After that is proven we execute the following command which will connect to the Apicast docker image on our rubix.local network. The Apicast instance will download the configuration from the 3Scale SaaS solution and route our API call to the configured echo service back-end.

[root@centos /]# curl "http://apicast.rubix.local:8080/echo?user_key=USERKEY"

{
"method": "GET",
"path": "/echo",
"args": "user_key=XXXXXX",
"body": "",
"headers": {
"HTTP_VERSION": "HTTP/1.1",
"HTTP_HOST": "echo-api.3scale.net",
"HTTP_ACCEPT": "*/*",
"HTTP_USER_AGENT": "curl/7.29.0",
"HTTP_X_3SCALE_PROXY_SECRET_TOKEN": "Shared_secret_sent_from_proxy_to_API_backend",
"HTTP_X_REAL_IP": "172.20.0.3",
"HTTP_X_FORWARDED_FOR": "145.15.244.22, 10.0.101.15",
"HTTP_X_FORWARDED_HOST": "echo-api.3scale.net",
"HTTP_X_FORWARDED_PORT": "443",
"HTTP_X_FORWARDED_PROTO": "https",
"HTTP_FORWARDED": "for=10.0.101.13;host=echo-api.3scale.net;proto=https",
"HTTP_CONNECTION": "close"
},
"uuid": "24e5737c-c3ff-4333-bbbb<span data-mce-type="bookmark" style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" class="mce_SELRES_start"></span>-6030aaea6521"

Hope it helps !

Advertisements
 
1 Comment

Posted by on 28-11-2017 in Uncategorized

 

Tags: , , ,

Free ebook, DevOps with OpenShift

When getting started with OpenShift the concepts op Docker, Kubernetes and additional OpenShift toolset can be overwhelming from both the development and infrastructure background perspective. Luckily three OpenShift experts at Red Hat explain in the book “DevOps with OpenShift” how to configure Docker application containers and the Kubernetes cluster manager with OpenShift’s tools.

The book covers (and I quote):

Discover how this infrastructure-agnostic container management platform can help companies navigate the murky area where infrastructure-as-code ends and application automation begins.

  • Get an application-centric view of automation—and understand why it’s important
  • Learn patterns and practical examples for managing continuous deployments such as rolling, A/B, blue-green, and canary
  • Implement continuous integration pipelines with OpenShift’s Jenkins capability
  • Explore mechanisms for separating and managing configuration from static runtime software
  • Learn how to use and customize OpenShift’s source-to-image capability
  • Delve into management and operational considerations when working with OpenShift-based application workloads
  • Install a self-contained local version of the OpenShift environment on your computer

Red Hat offers the eBook for free on their website as a promotion for download here. It’s a great tutorial and sort of a must-read for everyone starting with OpenShift.

 

 

 

 

 
Leave a comment

Posted by on 23-08-2017 in Uncategorized

 

Tags: , ,

How to install and run OpenShift Origin on your Mac OS X ?

Installing OpenShift Origin on OS X

The easiest way to install (many software) on your OS X machine is through Homebrew. So let’s try that! :)

brew update
brew install openshift-cli

Check the installation

jvzoggel$ oc version
oc v3.6.0+c4dd4cf
kubernetes v1.6.1+5115d708d7
features: Basic-Auth

Running

When running OpenShift on your Mac OS X host.

jvzoggel$ oc cluster up
-- Checking OpenShift client ... OK
-- Checking Docker client ... OK
-- Checking Docker version ...
WARNING: Cannot verify Docker version
-- Checking for existing OpenShift container ... OK
-- Checking for openshift/origin:v1.5.1 image ... OK
-- Checking Docker daemon configuration ... FAIL

Error: did not detect an --insecure-registry argument on the Docker daemon
Solution:
Ensure that the Docker daemon is running with the following argument: 
--insecure-registry 172.30.0.0/16
You can run this command with --create-machine to create a machine with the right argument.

We have to add the registry 172.30.0.0/16 to our Docker Daemon through preferences -> Daemon and select Apply & Restart.

Next when I tried to run the cluster I get this error:

jvzoggel$ oc cluster up
-- Checking OpenShift client ... OK
-- Checking Docker client ... OK
-- Checking Docker version ... 
   WARNING: Cannot verify Docker version
-- Checking for existing OpenShift container ... OK
-- Checking for openshift/origin:v1.5.1 image ... OK
-- Checking Docker daemon configuration ... OK
-- Checking for available ports ... OK
-- Checking type of volume mount ... 
   Using Docker shared volumes for OpenShift volumes
-- Creating host directories ... OK
-- Finding server IP ... 
   Using 127.0.0.1 as the server IP
-- Starting OpenShift container ... FAIL
   Error: exec: "socat": executable file not found in $PATH

The error is what misleading because socat is a dependency (check here) in the homebrew openshiftcli and therefor should be installed automatically through the brew command. The real reason seems the Docker Toolbox on OSx requires us to add an additional parameter when starting or stopping our OpenShift cluster.

oc cluster up --docker-machine=openshift
oc cluster down --docker-machine=openshift

Voila! Hope it helps

References

 
Leave a comment

Posted by on 21-08-2017 in Uncategorized

 

Tags: , , ,

Cleaning up your old excess Docker containers

Every docker run command creates a container on your system. When you exit the container (and it is no longer running) it is still there on disk and can be seen with

docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ea520a35da1f jvzoggel/kafka "/bin/bash" 2 minutes ago Exited (0) 2 minutes ago kafka1
46067fe01dc4 jvzoggel/kafka "/bin/bash" 3 minutes ago Exited (0) 2 minutes ago kafka2
0b7bcb382e65 jvzoggel/kafka "/bin/bash" 3 minutes ago Exited (0) 3 minutes ago kafka3

The containers that are not running will not consume any system resources except disk space, but it is usually good to clean up after yourself so ..

Automatically clean-up after yourself

The Docker documentation describes how to automatically clean up the container and remove the file system when the container exits:
   –rm=false: Automatically remove the container when it exits (incompatible with -d)
The above shows that by default containers are not removed, so by adding –rm=true or just the short-hand –rm will do the trick:

docker run -i -t --rm jvzoggel/kafka /bin/bash

When you exit from the container it will be automatically removed from disc.

Manually clean-up your stuff

Another method (all credits: Guillaume J. Charmes) is the command:

docker rm `docker ps --no-trunc -aq`

which will remove all containers in a elegant way

 

 
Leave a comment

Posted by on 05-08-2016 in Uncategorized

 

Tags: