IBM/container-journey-template

Name: container-journey-template

Owner: International Business Machines

Description: null

Created: 2017-03-17 23:22:40.0

Updated: 2018-03-28 01:28:14.0

Pushed: 2017-11-30 16:57:05.0

Homepage: null

Size: 859

Language: Shell

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Status

Container Journey template - Creating a Kubernetes Cluster

Read this in other languages: ???.

This scenario provides instructions for the following tasks:

Step 1. Setting up the Bluemix CLI

Install the IBM Bluemix Container Service CLI, the image registry CLI, and their prerequisites. These CLIs are used in later lessons and are required to manage your Kubernetes cluster from your local machine, create images to deploy as containers, and in a later tutorial, deploy apps into the cluster.

  1. If you do not have one yet, create a Bluemix account. Make note of your user name and password as this information is required later.

For Linux users, you can clone this repo and run bash linux.sh. Then, move on to Step 2.

  1. As a prerequisite for the Bluemix Container Service plug-in, install the Bluemix CLI. The prefix for running commands by using the Bluemix CLI is bx.

For Mac users, after you have installed the Bluemix CLI, you can clone this repo and run bash osx.sh in your terminal. Then move on to Step 2.

  1. Log into the Bluemix CLI with username and password

     login -a https://api.ng.bluemix.net
    endpoint: https://api.ng.bluemix.net
    
    l> myemail@email.com
    
    word>
    enticating...
    
    
    ct an account (or press enter to skip):
    tuff (8b05eb34e24005a6a1f9ba77f565fe2d)
    r a number> 1  (note that not entering a number will cause this to fail)
    eted account Stuff (8b05eb34e24005a6a1f9ba77f565fe2d)
    
    eted org test.org
    
    eted space test
    
    endpoint:   https://api.ng.bluemix.net (API version: 2.75.0)
    on:         us-south
    :           email@example.com
    unt:        Stuff (8b05eb34e24005a6a1f9ba77f565fe2d)
                test.org
    e:          test
    
  2. Alternatively, if you are using Single Sign-On, you can authenticate with Bluemix by using an API key. To create an API key, navigate to the Manage -> Security -> Bluemix API Keys menu option, or go directly to: https://console.bluemix.net/iam/#/apikeys. Click the Create button to create a new API key.

Note: Once created, you will not be able to view the API key again, so save it somewhere safe!

You can now use the API key to authenticate with Bluemix by using the bx login --apikey <apikey>.

```bash

$ bx login --apikey bNUsU0vpX3ZXWUZvnSDowFDGUR8EZfTdHnJelsQvlhPr
API endpoint: https://api.ng.bluemix.net
Authenticating...
OK

Targeted account IBM (47b84451ab70b94737518f7640a9ee42) <-> 1323471

Targeted resource group default

API endpoint:     https://api.ng.bluemix.net (API version: 2.75.0)
Region:           us-south
User:             stevemar@ca.ibm.com
Account:          IBM (47b84451ab70b94737518f7640a9ee42) <-> 1323471
Resource group:   default
Org:
Space:
```
  1. To create Kubernetes clusters and manage worker nodes, install the Bluemix Container Service plug-in. The prefix for running commands by using the Bluemix Container Service plug-in is bx cs.

     plugin repo-add Bluemix https://plugins.ng.bluemix.net
     plugin install container-service -r Bluemix
    
  2. Initialize the Bluemix Container Service plug-in.

     cs init
    
  3. To view a local version of the Kubernetes dashboard and to deploy apps into your clusters, install the Kubernetes CLI. The prefix for running commands by using the Kubernetes CLI is kubectl.

    a. Download the Kubernetes CLI.

    OS X: http://storage.googleapis.com/kubernetes-release/release/v1.5.3/bin/darwin/amd64/kubectl

    Linux: http://storage.googleapis.com/kubernetes-release/release/v1.5.3/bin/linux/amd64/kubectl

    Windows: http://storage.googleapis.com/kubernetes-release/release/v1.5.3/bin/windows/amd64/kubectl.exe

    b. For OSX and Linux users, convert the binary file to an executable.

    mod +x kubectl
    

    Make sure that /usr/local/bin is listed in your PATH system variable. The PATH variable contains all directories where your operating system can find executable files. The directories that are listed in the PATH variable serve different purposes. /usr/local/bin is used to store executable files for software that is not part of the operating system and that was manually installed by the system administrator.

    ho $PATH
    /local/bin:/usr/bin:/bin:/usr/sbin:/sbin
    

    Move the executable file to the /usr/local/bin directory

    do mv kubectl /usr/local/bin/kubectl
    

Congratulations! You successfully created your Bluemix account and installed the CLIs for the following lessons and tutorials. Next, access your cluster by using the CLI.

Step 2: Setting up your cluster environment
  1. Create your free Kubernetes cluster
     cs cluster-create --name [your_cluster_name]
    
    A free cluster comes with one worker node to deploy container pods upon. A worker node is the compute host, typically a virtual machine, that your pods run on. A pod is a group of one or more containers, the shared storage for those containers, and the options about how to run them. The pod model is as an “application specific logical host”, which means it contains one or more application containers which are relatively tightly coupled.

Note: It can take up to 2 hours for the worker node machine to be ordered, and for the cluster to be set up and provisioned.

  1. Before you continue to the next step, verify that the deployment of your worker node is complete.

     cs workers [your_cluster_name]
                                             Public IP       Private IP    Machine Type  State     Status   
    0-pa8dfcc5223804439c87489886dbbc9c07-w1  169.47.223.113  10.171.42.93  free         deployed  Deploy Automation                                          Successful   
    
  2. Set the context for your cluster in your CLI. Every time you log in to the IBM Bluemix Container Service CLI to work with the cluster, you must run these commands to set the path to the cluster's configuration file as a session variable. The Kubernetes CLI uses this variable to find a local configuration file and certificates that are necessary to connect with the cluster in Bluemix.

    a. Download the configuration file and certificates for your cluster using the cluster-config command.

     cs cluster-config [your_cluster_name]
    rt KUBECONFIG=/Users/ibm/.bluemix/plugins/cs-cli/clusters/wordpress/kube-config-dal10-wordpress.yml
    

    b. Copy and paste the command from the previous step to set the KUBECONFIG environment variable and configure your CLI to run kubectl commands against your cluster.

  3. From here you should be able to verify that your Kubernetes credentials are working by running the kubectl-specific version of the bx cs workers command above:

    bectl get nodes
                 STATUS    AGE       VERSION
    172.242.18   Ready     3h        v1.5.6-4+abe34653415733
    

Great work! The cluster is created, configured, and your local environment is ready for you to start deploying apps into the cluster. To make sure it's running as it should, let's run the simple Docker hello-world container app on our new cluster.

$ kubectl run -i --tty hw --image=hello-world --restart=Never

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/

That's it, you can now go back to the Journey that brought you here!


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.