jessewei

Laboratory to bluemix, a cloud solution exercise to etl scheduler

Deploy a container through the command line

  1.  You can verify connection via cf ic images. This will show a list of all the images in your organization’s repository, which should be the four public IBM images so far.
        $ cf ic images
        REPOSITORY                                                            TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
        registry.ng.bluemix.net/ibm-node-strong-pm                         latest              ef21e9d1656c        13 days ago         528.7 MB
        registry.ng.bluemix.net/ibmliberty                                 latest              2209a9732f35        13 days ago         492.8 MB
        registry.ng.bluemix.net/ibmnode                                    latest              8f962f6afc9a        13 days ago         429 MB
        registry.ng.bluemix.net/ibm-mobilefirst-starter                    latest              5996bb6e51a1        13 days ago         770.4 MB
    
  2. You will be using the IBM Containers plug-in. You can run help for more information   $ cf ic help

  3. To create a container deploying the IBM Liberty container image again:cf ic run --name container-lab-1 -p 9080 -m 64 registry.ng.bluemix.net/ibmlibertywhere:
    • -p specifies the exposed port of the image, similar to the Ports field in Task 2, Step 9 above.When you specify a port, you are making the application available to the Bluemix Load Balancer and other containers attempting to access that port. If a port is specified in the Dockerfile for the image that you are using, include that port.For the IBM certified Liberty Server image, enter port 9080 via -p 9080.
      For the IBM certified Node.js, enter port 8000 via p 8000.
      If you plan on logging in to the container via SSH, add port 22 via -p 22.
    • --name specifies the name you can use to refer to the container
    • -m specifies the memory limit (and associated storage capacity), similar to Task 2, Step 7 above
    • registry.ng.bluemix.net/ibmliberty is the repository name for the image as displayed by the cf ic images command
  4. To check that the container has been deployed successfully, run the cf ic ps -a command to show all the container artifacts that have been created or deployed in your organization.
        $ cf ic ps -a
        CONTAINER ID        IMAGE                                                            COMMAND             CREATED            STATUS                  PORTS                                                                                     NAMES
        a055ba5e-77b        registry.ng.bluemix.net/ibmliberty:latest                     ""                  5 minutes ago      Running 4 minutes ago   134.XXX.YYY.ZZZ:9080->9080/tcp                                                             container-lab-1
    
  5. Now you can assign a public IP to the container. The cf ic run command will proactively attempt to request and bind a public IP address for your container instance if there is room left in your IP Quota. By default, you have 2 Public IP addresses in your quota.If your cf ic ps -a command returns your Liberty container with ports in the form of 134.XXX.YYY.ZZZ:9080->9080/tcp, then your container already has an assigned Public IP address and you can skip the next step.
  6. (Optional) You will first list all requested Public IP addresses and then bind an available IP address to your running container instance.
        $ cf ic ip list -a
        Number of allocated public IP addresses:  2
    
        IpAddress         ContainerId   
        134.XXX.YYY.174   df6ba7fd-436e-4d57-a69b-4228e19cadc1   
        134.XXX.YYY.175       
    

    Choose an IP address that is not bound to a container. Note that in Bluemix, you are allocated 2 Public IPs free of charge. If you do not have any public IP addresses available to complete the lab, use the cf ic ip release command to release one. In a real environment, contact your Bluemix organization administrator to provision additional public IP addresses for your organization.

    Once you have identified the desired IP address (selecting 134.XXX.YYY.175 from above), you run the cf ic ip bindcommand to associate a running container instance to a public IP address. The cf ic ip bind command takes either the container name or the container ID as the second argument to support scriptable interactions.

          $ cf ic ip bind 134.XXX.YYY.175 container-lab-1
          Successfully bound IP
    
  7. Validate access to the container through the browser. Run cf ic ps -a once again and copy the public IP address associated with your container. Enter this value into your browser via http://%5BPublic_IP_Address%5D:9080 and you should see the Welcome to Liberty landing page.
  8. Since both the UI and the CLI are working with the same backend, you can view your newly CLI-created container instance in the UI as well. This can be done by returning to the Bluemix Dashboard.
  9. Click on CONTAINERS in the left-hand menu. Your dashboard is now filtered to show your running container instances. Clicking on the square with the container-lab-1 title will take you to the container overview dashboard. From here you have access to the same Monitoring & Logging, as well as the controls available to Stop, Pause, Restart, & Delete containers.

Conclusion

Congratulations, you have successfully completed this IBM Containers lab! You learned how to work with IBM Containers, and deploy Docker images onto Bluemix through the UI & CLI.

Cleanup

If you plan to do another lab, you need to clean up your container instances. This can be done through the UI and the DELETE button on each container, or you can do this through the CLI with the cf ic rm -f [CONTAINER_NAME] command.

Advertisements

Deploy container on Bluemix

  1. Go to the Bluemix dashboard for the same organization you logged into above. This is available via Bluemix Dashboard.
  2. Click on Start Containers and you will be taken to your organization’s Catalog, containing all the public and private images stored for your organization.You have not pushed any images to your private registry, so you should only see the following images:
    • ibm-mobilefirst-starter – Starter image for IBM MobileFirst Platform Foundation
    • ibm-node-strong-pm – Starter image for IBM Strongloop Process Manager
    • ibmliberty – IBM-Supported WebSphere Liberty Profile runtime container image
    • ibmnode – IBM-Supported Node.js runtime container image
  3. Select the ibmliberty image from the list of available images.
    Catalog - IBM Bluemix - Google Chrome_2016-03-24_13-26-12
  4. You are taken to the Create Container page.This is a user-interface driven method to deploying container instances on IBM Containers. The same capability is available through the CLI, but you will be using the UI to deploy your first container on IBM Bluemix.
  5. Choose the space in your organization where you would like to host the container. At this point, you should probably only have the BAO-TW space.Select BAO-TW.In Bluemix, spaces provide a mechanism to collect related applications, services, containers, and the users that can collaborate on the resources. You can have one or more spaces within an organization.
    ibmliberty - IBM Bluemix - Google Chrome_2016-03-24_13-30-09
  6. Provide a name for the container.Enter libertydemo1. This is the same as the --name parameter when using the Docker CLI.
  7. Choose the size of the container.Select Pico (64 MB Memory, 4 GB Storage). IBM Containers allows you to select right-sized hardware resources for your container instances to allow for cost-effective runtimes. Note: The size of a container cannot be changed once it has been created.
  8. Associate a publicly-routed IP address to the newly created container.Select the option Request and bind a public IP. or your existed public IPIn Bluemix, you are provided with a default private network for all your running container instances automatically. You can optionally select container instances to be assigned Public IP addresses and expose them to the public internet. This is useful for web frontends and load balancing containers, while your database and similarly functioning containers can remain walled off from public internet traffic.
  9. When deploying through the Bluemix user interface, container images have their exposed ports automatically detected. You should see the following ports automatically detected when viewing the ibmliberty image: 22/tcp, 9080/tcp, 9443/tcp
  10. Click CREATE.Your container instance will now be deployed to Bluemix. You will be redirected to the dashboard overview for this new container instance.In future tasks and labs you will interact with elements under the Advanced Options and Vulnerability Assessment, but feel free to explore before clicking CREATE. These additional options allow you to work with volumes stored on Bluemix, bind your containers to over 150 Bluemix services, and inject your own SSH key into each container you deploy.
  11. From the dashboard overview, you should see the Public IP address assigned to your running WebSphere Liberty container.Find your Public IP address and enter it into a browser, like http://Public_IP_Address:9080. You should be presented with the Welcome to Liberty landing page.Alternatively, you can click on the 9080 port that is linked from the dashboard page to open the container instance via the exposed port. You should see the same Welcome to Liberty landing page.
  12. Back in the dashboard overview page in Bluemix, you are presented with all the controls necessary to manage your container instance. You are also presented with pre-integrated Logging & Monitoring for all your container instances.Click on Monitoring and Logs on the left hand menu and you will be taken to deeper view into the provided monitoring & logging stack. You can configure your containers to log additional information directly to this endpoint as well.This is a key piece in enabling container-based infrastructures, as it becomes quickly unmanageable to interact with all the singular instances at the lowest level. This is just one of a few capabilities that IBM Containers provides to reduce the amount of time users take to get value out of Docker containers and hosted infrastructure. You’ll touch on a few more in subsequent labs.
  13. Once you have verified your container was successfully deployed, you can delete your running container instance via the DELETE button on the container dashboard.As you are most likely on a Trial account, removing containers after each lab will make sure you are making efficient use of your Trial quota.

5. Install the IBM Containers plugin

Ref: Install IBM Container plugin@Step3

Installation

Instead of using the depreciated IBM® Containers Extension (ice), use the Cloud Foundry plug-in for IBM Containers after 2016-Jan.

  • Install the IBM Containers Cloud Foundry plug-in download for your operating system by running one of the following commands.
    Table 2. Cloud Foundry plug in commands
    Operating system Command
    Linux 64-bit
     $ cf install-plugin https://static-ice.ng.bluemix.net/ibm-containers-linux_x64

    When the installation completes, an OK message is displayed.Verify the plug-in installation

 

Verify the plug-in installation

$ cf plugins

Listing Installed Plugins…
OK

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

 

Logging in through CLI

Log in to Bluemix through the Cloud Foundry CLI

$ cf login -a api.ng.bluemix.net
  1. For Email, enter the IBM ID that you use to log in to Bluemix.
  2. For Password, enter the password for the IBM ID that you use to log in to Bluemix. By entering your user name and password, your Bluemix organization and space are retrieved.
  3. Enter the number that represents one of your Bluemix organizations.
  4. Enter the number that represents one of your Bluemix spaces

Log in to the IBM Container service

$ cf ic login


 

Bluemix Container Lab @ Windows

Preparation

There are many configuration to enable Bulemix devops process. Here I show is the easiest way for lab.

  1. Install Docker@Windows
    Install Docker Toolbox
  2. Sign up for an IBM Bluemix account
  3. Install IBM Containers plugin
    Table 1. Two ways to install plugin @ Windows
    Operating system Command
    Windows 7 64-bit
    Linux 64-bit@VirtualBox

     

  4. Sign up for IBM Containers in IBM Bluemix
    • From the Bluemix dashboard, click Start Containers
    • You will be prompted to Set registry namespace.
    • Enter in a registry name, cannot be changed afterwards. This registry name is used across your account when using the IBM Containers service.

Read more…

2. Install Docker

 

Docker Installation reference

Update apt sources

To set APT to use packages from the new repository:

  1. Open a terminal window.
  2. Update package information, ensure that APT works with the https method, and that CA certificates are installed.
     $ sudo apt-get update
     $ sudo apt-get install apt-transport-https ca-certificates
    
  3. Add the new GPG key.
    $ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
    
  4. Open the /etc/apt/sources.list.d/docker.list file in your favourite editor.If the file doesn’t exist, create it. For example,$ sudo vi /etc/apt/sources.list.d/docker.list 
  5. Remove any existing entries.
  6. Add an entry for your Ubuntu operating system.The possible entries are:
    • On Ubuntu Trusty 14.04 (LTS)
      deb https://apt.dockerproject.org/repo ubuntu-trusty main
      

    Save and close the /etc/apt/sources.list.d/docker.list file.

  7. Update the APT package index.
    $ sudo apt-get update
    
  8. Purge the old repo if it exists.
    $ sudo apt-get purge lxc-docker
    
  9. Verify that APT is pulling from the right repository.
    $ sudo apt-cache policy docker-engine
    

    From now on when you run apt-get upgrade, APT pulls from the new repository.

Prerequisites by Ubuntu Version

For Ubuntu Trusty and Wily, it’s recommended to install the linux-image-extra kernel package. The linux-image-extra package allows you use the aufs storage driver.

To install the linux-image-extra package for your kernel version:

  1. Open a terminal on your Ubuntu host.
  2. Update your package manager.
    $ sudo apt-get update
    
  3. Install the recommended package.
    $ sudo apt-get install linux-image-extra-$(uname -r)
    
  4. Go ahead and install Docker.
  5. Install apparmor is required. You can install it using:
    $ sudo apt-get install apparmor

 

Install Docker

Then, install Docker using the following:

  1. Update your APT package index.
    $ sudo apt-get update
    
  2. Install Docker.
    $ sudo apt-get install docker-engine
    
  3. Start the docker daemon.
    $ sudo service docker start
    
  4. Verify docker is installed correctly.
    $ sudo docker run hello-world
    

    This command downloads a test image and runs it in a container. When the container runs, it prints an informational message. Then, it exits.

Create a Docker group

The docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can access it with sudo. For this reason, docker daemon always runs as the root user.

To avoid having to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.

To create the docker group and add your user:

  1. Create the docker group and add your user.
    $ sudo usermod -aG docker osboxes
    
  2. Log out and log back in.This ensures your user is running with the correct permissions.
  3. Verify your work by running docker without sudo.
    $ docker run hello-world
    

    If this fails with a message similar to this:

    Cannot connect to the Docker daemon. Is 'docker daemon' running on this host?
    

    Check that the DOCKER_HOST environment variable is not set for your shell. If it is, unset it.

1. Build up Ubuntu 14.04

Install Ubuntu 14.04

Why Ubuntu14.04@VirtualBox

There are many choice, but I meet some difficult to continue in current Bluemix version. So the following step is the most easy path I have tried. The other option you may like try yourself are:

  • Ubuntu14.04@Docker@Windows
    Install X11 on Windows and configure docker, then install CLI in Ubuntu@Docker…..
  • Ubuntu14.04@VMware
    Network connect fail, seems conflict with my current setting.
  •  OtherOS@…

Steps Overview

  1. Download from OsBoxes image
  2. Unzip to your VM directory
  3.  Guest OS Installation guide for VirtualBox
  4.  Setup network
  5.  Setup display resolution issue

Setup Steps

1. Download from OsBoxes image

~~~

2. Unzip to your VM directory

~~~

3.  Guest OS Installation guide for VirtualBox

VirtualBox -> [New] button

Oracle VM VirtualBox Manager_2016-03-22_11-31-27

Virtual Box -> ..-> ‘Use an existing virtual hard disk file’
Create Virtual Machine_2016-03-22_11-34-30

VirtualBox -> [Start] button

Oracle VM VirtualBox Manager_2016-03-22_11-36-08

4. Setup network

VirtualBox -> Device -> Network -> Network Setting
check [Cable Connected]

ubuntu14

 

5. Setup display resolution issue

VirtualBox -> Devices -> Insert Guest Additions CD image
docker ubuntu x11 on windows
Restart OS, then display resolution works
VirtualBox -> View -> Virtual Screen 1 -> .... 
ubuntu14-4
 

Next Step: Install Docker

 

Reference

Labs and tutorials used Codemotion.es 2015 for IBM Containers

IBM Bluemix Architecture Series: Web Application Hosting on IBM Containers

My playground

Post Navigation