How-tos

Deploying to IBM Cloud Private 2.1.0.3 with IBM Cloud Developer Tools CLI

Share this post:

IBM Cloud Private and IBM Cloud Developer Tools CLI

IBM Cloud Private is an application platform for developing and managing on-premises, containerized applications. It is an integrated environment for managing containers that includes the container orchestrator Kubernetes, a private image repository, a management console, and monitoring frameworks. This article is focused on IBM Cloud Private 2.1.0.3. For prior versions of IBM Cloud Private, see these related articles:

IBM Cloud Developer Tools CLI version 2.1.4 adds deployment support for IBM Cloud Private 2.1.0.3. This version of IBM Cloud Private uses a more secure Helm for Kubernetes deployments and simplifies the cluster configuration for the client compared to prior IBM Cloud Private releases. IBM Cloud Developer Tools CLI support is not limited to this environment; it also deploys to the Kubernetes environment on the public IBM Cloud and older versions of IBM Cloud Private. This means that you can use the IBM Cloud Developer Tools CLI to generate starter applications and perform deployments to all of your IBM Cloud Private and public IBM Cloud environments.

To install the IBM Cloud Developer Tools CLI which includes all prerequisites, follow these instructions.

Deploying to IBM Cloud Private

First things first, you need to create an application using the ibmcloud dev create command.  Follow the prompts and select the language and Starter Kit that you’d like to use. I recommend either the Node.js or Java Basic Web starters (they are simple and easy to follow), but feel free to choose any language or Starter Kit.   Once the app is created, cd into the new directory on your system. You can also enable an existing application for Kubernetes deployment by using the ibmcloud dev enable command.  In either case, ibmcloud dev build the app before proceeding to the following steps.

Now that you have an application, you need to configure your local machine to deploy to the IBM Cloud Private environment.

Set up IBM Cloud Private 2.1.0.3 security dependencies

To begin, download the Helm client compatible with your IBM Cloud Private deployment. For version 2.1.0.3, this is Helm version 2.7.2. To install this Helm version use the following instructions:

Mac/Linux:

Complete these commands:

export DESIRED_VERSION=v2.7.2

curl -sL https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash

export HELM_HOME=~/.helm

Windows:

Download and install the binary at https://github.com/kubernetes/helm/releases/tag/v2.7.2

From the PowerShell terminal, you will use the following for deployment:

Set-Location Env:
Set-Item HELM_HOME C:\.helm\

Tip: You can use another location for HELM_HOME, but it must be set before you proceed.

Tip: Do not run helm init at this time, even if the installation instructs you to do so.

Next, IBM Cloud Private 2.1.0.3 adds the pr plug-in to the IBM Cloud CLI to ease security configuration. To install this plug-in, download it directly from your IBM Cloud Private deployment as described here.

Finally, use the pr plug-in to:

  1. Configure the IP and port of the IBM Cloud Private master
  2. Add a certificate for your Helm client to communicate with IBM Cloud Private.
  3. Choose the cluster that you intend to use for deployment.

Log in to IBM Cloud Private using a valid user account created on that system as follows:

ibmcloud pr login -a https://<master_ip_address>:8443 --skip-ssl-validation

The <master_ip_address> is the same IP address that you use to access the IBM Cloud Private management console. The user and password are the same that you use to access the console, as well.

After you log in, the dialog asks you to choose the account that you use for deployment from a list of possible accounts. You can then choose the cluster to use for your deployments by running the following command:

ibmcloud pr cluster-config <the_cluster_name>

Configure Docker registry access

First, create an entry in your hostSure file that maps to mycluster.icp:

# Replace <master_ip_address> with the IP address of your IBM Cloud Private system

<master_ip_address> mycluster.icp

This is added in /etc/hosts on MacOS and Linux or C:\Windows\System32\drivers\etc\hosts on Windows.

Next, add the registry mycluster.icp:8500 for IBM Cloud Private to the list of insecure Docker registries on your local machine as follows:

Mac/Linux:

  1. Click the Docker icon in the menu bar.
  2. Select Preferences.
  3. Add the insecure registry on the Daemon tab.

Windows:

  1. Click the Docker icon in the system tray.
  2. Select Settings.
  3. Add the insecure registry on the Daemon tab.

Finally, log in to the IBM Cloud Private Docker registry by using the appropriate user and password from your IBM Cloud Private server and the hostname you defined above:

docker login mycluster.icp:8500

Configure kubectl for access

In the IBM Cloud Private management console, click your username in the top right corner and then select the Configure client option.

To ensure that the credentials for your client are valid, complete a fresh login to the IBM Cloud Private management console. If you need help logging into IBM Cloud Private, see these instructions. The Configure client button provides a set of commands like the following example that you then run on your local system:

kubectl config set-cluster mycluster.icp --server=https://<master_IP_address>:8001 --insecure-skip-tls-verify=true
kubectl config set-context mycluster.icp-context --cluster=mycluster.icp

kubectl config set-credentials mycluster.icp-user --token=eyJhbGciOiJSUzI1NiIs...

kubectl config set-context mycluster.icp-context --user=mycluster.icp-user --namespace=default

kubectl config use-context mycluster.icp-context

Deploy an app

For the simplest deployment experience, you can update your application’s cli-config.yml file to point to the IBM Cloud Private Kubernetes environment by adding these entries:

deploy-target: "container"
deploy-image-target: "mycluster.icp:8500/<Namespace>/<App-Name>"

The <Namespace> is the namespace on IBM Cloud Private to which you are deploying. For example, default.  The <App-Name> is the name of your application deployment.

The deploy-target value instructs the CLI to target a Kubernetes/container environment, and the deploy-image-target value tells the CLI what to tag your image with for the IBM Cloud Private registry. If you do not update the cli-config.yml, you must specify -t container for the deploy command, and then the deployment action queries you for the deploy-image-target.

Tip: For Public IBM Cloud users, you must run ibmcloud logout before you deploy to IBM Cloud Private.

You’re now ready to deploy your Kubernetes application to IBM Cloud Private. Just use the deploy command to kick off the deployment:

ibmcloud dev deploy

In this case, the deploy command will:

  • build and upload the Docker image of your application to the IBM Cloud Private image repository, and
  • perform a deployment to your IBM Cloud Private Kubernetes cluster using the Helm chart that was generated by the ibmcloud dev create or ibmcloud dev enable command.

You have now generated and deployed your first application to IBM Cloud Private using the IBM Cloud Developer Tools CLI. You can launch a browser window to your deployed app by entering this command in the app directory:  ibmcloud dev view

Lead Developer, IBM Cloud Developer Tools CLI

More How-tos stories
December 12, 2018

Deploying to IBM Cloud Private 3.1 with IBM Cloud Developer Tools CLI

IBM Cloud Developer Tools CLI version 2.1.12 adds deployment support for IBM Cloud Private 3.1.

Continue reading

December 7, 2018

Highly Available Applications with IBM Cloud Foundry

To properly deploy an application in a cloud environment and ensure maximum responsiveness, your app needs to be deployed in a certain (and easy) way that maximizes the chance of an instance always being ready to respond to a user request. This article will explain how to deploy your Cloud Foundry applications in the IBM Cloud such that you reach your target application availability.

Continue reading

December 5, 2018

Cloud Foundry Container-to-Container Networking

If you're like many developers who are deploying applications to Cloud Foundry, you probably don't think about networking too often. After all, as a PaaS, Cloud Foundry takes care of all the routing and connectivity for you. There is one feature, however, you might consider before writing your next app: container-to-container networking.

Continue reading