Overview

Skill Level: Any Skill Level

Basic familiarity with git, Bluemix, and Kubernetes.

Learn how to deploy a Kubernetes application to Bluemix using a Continuous Delivery pipeline.

Ingredients

Bluemix account - Sign up for a trial account if you don't already have one.

GitHub ID - Create an ID if you don't already have one.

In this tutorial we will use the Bluemix Continuous Delivery service to deploy the Kubernetes Guestbook example to the Bluemix Container Service.

Step-by-step

  1. Install the Bluemix command line utilities

    1. Download and install the latest Bluemix CLI. (Check out the official documentation here.)
    2. Install the Container Service plugin
      bx plugin install container-service -r Bluemix
    3. Verify that you have the plugin installed by running
      bluemix plugin list
  2. Create a cluster

     

    A Kubernetes pod refers to one or more containers. These pods run on clusters. For this example we will provision a cluster in Bluemix’s free tier.

    1. Log into Bluemix using the command bx login -a https://api.ng.bluemix.net
    2. Run the following command to create your cluster. (For this recipe we chose the name Kate which will be used later on in the recipe when configuring the pipeline.)
      bx cs cluster-create --name Kate
    3. The command will return
      OK....
    4. Use bx cs clusters to see the defined clusters
    5. Use bx cs workers Kate to see the provisioned workers

    Once the cluster reaches the deployed state you can provision pods, but they will be enqueued until the cluster’s pods are finished provisioning. Note that it takes approximately 15 minutes for the cluster to be fully provisioned and ready to accept the sample pods. 

    Name              ID                                 State      Created                    Workers
    Kate              d20f6c096ce6483ab3f65556d3db41b7   deployed   2017-03-16T17:17:39+0000   1   

    Note this step creates a free cluster with a single worker. Create a Softlayer account if you want to create large, multi-worker clusters.

  3. Explore the sample application

    This tutorial relies on the Kubernetes Guestbook example. We use the all-in-one configuration file to create our pods. The application consists of a Redis master, Redis slave, and frontend pod. The frontend contains the very simple guestbook ui server.

  4. Create the toolchain

    1. Click the Create toolchain button in the sample repository readme to fork the repo into your GitHub account.

      KubernetesRepoReadme

    2. Once the repository is forked, you will be taken to the Bluemix Continuous Delivery toolchain setup. This toolchain has been defined by the template in the sample repository.

      IDS-Toolchain

    3. If you have not authenticated to GitHub you will see an Authorize button.

      IDS-GH-Authorize

    4. Click the Create button. This will generate a toolchain that looks like the following:

      IDS-Simple-Toolchain

  5. Configure the pipeline environment properties

    1. Select the Delivery Pipeline tile from the toolchain view to open the pipeline stages view.

      IDS-Simple-Toolchain

    2. The pipeline executes immediately after being created. The Deploy stage will fail on the first run. The stages view will look like this once the build completes.

      InitialDeployFailure

    3. Click on the gear at the top right corner of the Deploy stage to select Configure Stage.
    4. Set the following environment properties
      • BLUEMIX_USER – your Bluemix user ID.
      • BLUEMIX_PASSWORD – your Bluemix password.
      • BLUEMIX_ACCOUNT – The GUID of the Bluemix account where you created the cluster. Retrieve it with bx iam accounts.
      • CLUSTER_NAME – Defaults to Kate. Update if your cluster name is different.

        EnvProperties

    5. Run the Deploy stage using the Run Stage button at the top righthand side of the stage’s card. This time the Deploy stage will succeed and the Guestbook sample will be deployed.
  6. Access the Guestbook application

    1.  View logs and history of the Deploy stage to find the URL of the Guestbook application.

      DeploySuccess

    2. Click the Guestbook link to load the application in your browser. Note it takes a few seconds from the time the pods deploy until they are ready to serve requests.

      DeployLogs

    3. Post some greetings to your host.

      Guestbook

  7. Closing thoughts…

    The Bluemix Continuous Delivery service provides a flexible platform to deploy services to a variety of environments. The new Bluemix Container Service provides the scalable Kubernetes environment your business demands. Paired together these scalable, flexible services allow you to focus on your business instead of your infrastructure.

    Authors

    Jesse Antoszyk is a Software Engineer with IBM Cloud.

    Adam King is a Senior Software Engineer with IBM Cloud.

Join The Discussion