Wednesday, 31 August 2016

Moving past Docker on Mac, IBM Containers on Bluemix

Having tinkered with WebSphere Liberty Profile on Docker over the past few days, as per recent posts to this blog, I wanted to go one stage further, and recreate a similar WLP / application on IBM Containers, which runs on IBM Bluemix.



I'm definitely on the on-ramp for Bluemix, and the learning curve still looks rather steep …

For reference: -

Troubleshooting for accessing Bluemix

Logging in to the IBM Containers CLI plug-in (cf ic)


IBM® Bluemix® uses the Cloud Foundry command line interface, cf, to modify applications, service instances, and service bindings. You can also use Bluemix command line tool that provides extended experience to manage your Bluemix environment besides Cloud Foundry applications.

Command Line Interface reference

Bluemix CLI

Deploying your app with the command line interface

But here goes….

Download and Install Prerequisites

Bluemix_CLI_0.4.1.pkg
cf-cli-installer_6.21.1_osx.pkg
DockerToolbox-1.12.0.pkg

Sources

Deploying your app with the command line interface

Docker Toolbox

Fix up .cf subdirectory to avoid panic

panic: Config error: open /Users/davidhay/.cf/config.json: permission denied

sudo chmod -R 777 /Users/davidhay/.cf/

Connect to Bluemix

bluemix api https://api.ng.bluemix.net

Log in to Bluemix - may NOT need this, as we also login using Cloud Foundry (CF) CLI

bluemix login -u david_hay@uk.ibm.com -o david_hay@uk.ibm.com -s david_hay

-OR- use the SSO variant: -

bluemix login -sso -u david_hay@uk.ibm.com -o david_hay@uk.ibm.com -s david_hay

having got a passcode from here: -

https://login.ng.bluemix.net/UAALoginServerWAR/passcode

Install Mac Containers plugin for Cloud Foundry

cf install-plugin https://static-ice.ng.bluemix.net/ibm-containers-mac

Validate plugin

cf plugins

Listing Installed Plugins...
OK

Plugin Name      Version   Command Name   Command Help
IBM-Containers   0.8.934   ic             IBM Containers plug-in


Login to Cloud Foundry

cf login -a api.eu-gb.bluemix.net -u david_hay@uk.ibm.com -o david_hay@uk.ibm.com -s david_hay

-OR- use the SSO variant: -

cf login -sso -a api.eu-gb.bluemix.net -u david_hay@uk.ibm.com -o david_hay@uk.ibm.com -s david_hay

having got a passcode from here: -

https://login.ng.bluemix.net/UAALoginServerWAR/passcode

Set IBM Containers Namespace

cf ic namespace set david_hay

Initialise IBM Containers CLI

cf ic init

Check available images

cf ic images

REPOSITORY                                      TAG                 IMAGE ID            CREATED             SIZE
registry.eu-gb.bluemix.net/ibm-node-strong-pm   latest              37a6db86742f        8 weeks ago         240.4 MB
registry.eu-gb.bluemix.net/ibmliberty           javaee7             77b68609eecb        2 weeks ago         325.4 MB
registry.eu-gb.bluemix.net/ibmliberty           latest              77b68609eecb        2 weeks ago         325.4 MB
registry.eu-gb.bluemix.net/ibmliberty           webProfile6         cd1753bef3b8        2 weeks ago         264.8 MB
registry.eu-gb.bluemix.net/ibmliberty           webProfile7         c0aa4441c231        2 weeks ago         283.1 MB
registry.eu-gb.bluemix.net/ibmnode              latest              1575262a71a0        5 days ago          189.3 MB
registry.eu-gb.bluemix.net/ibmnode              v4                  1575262a71a0        5 days ago          189.3 MB
registry.eu-gb.bluemix.net/ibmnode              v1.1                554cb6bd436b        5 days ago          178.8 MB
registry.eu-gb.bluemix.net/ibmnode              v1.2                38c08ea9d331        6 days ago          185 MB


Start WebSphere Liberty Profile container

foobar=`cf ic run -d -t -p 80:9080 -p 443:9443 ibmliberty:latest`

See what's running

cf ic ps -a

CONTAINER ID        IMAGE                                          COMMAND             CREATED             STATUS                  PORTS               NAMES
ec2b1754-0f7        registry.eu-gb.bluemix.net/ibmliberty:latest   ""                  3 minutes ago       Running 3 minutes ago                       admiring_fermi


Deploy an application to WLP

cf ic cp ~/Downloads/ferret.war $foobar:/opt/ibm/wlp/usr/servers/defaultServer/dropins

Run a command against the container

cf ic exec -it $foobar /bin/bash

Monitor the container logs

cf ic logs $foobar -f 

Functionally test the Ferret app

http://localhost/ferret/

https://localhost/ferret

Stop the container

cf ic stop $foobar

Remove the container

cf ic rm $foobar

Log out from Cloud Foundry

cf logout

Log out from Bluemix

bluemix logout

PS Remember the tagline for my blog …. YMMV

No comments:

Note to self - use kubectl to query images in a pod or deployment

In both cases, we use JSON ... For a deployment, we can do this: - kubectl get deployment foobar --namespace snafu --output jsonpath="{...