Get Started with Kubernetes on IBM Cloud!

Kubernetes is now in beta on the IBM Cloud!

What does that mean for us? Well, if you’re scratching your head as to what that interesting name represents, I present to you this great article: Kubernetes 101 .

If however, you find yourself as excited about having this wonderful container orchestration software available in the cloud as I am, look no further! With just a few steps, we can have you with your own free Kubernetes cluster running with the performance of IBM’s Bluemix Cloud Platform.

Step 1 — Sign up for a Bluemix Account

I regret to inform you that this remains as the initial (boring) step for almost every internet service today. The good news is that it doesn’t cost you any money to do so :) Quick, head over to https://console.ng.bluemix.net/ and make an account so we can get to the fun stuff.

Step 2 — Create a Kubernetes Cluster

Now that you’ve signed in, head to the Bluemix catalog and click on the containers section. Alternatively, here’s the link: https://console.ng.bluemix.net/catalog/?taxonomyNavigation=apps&category=containers .

Once there, you will see the Kubernetes Cluster option, almost as if it’s smiling at you :)

Kubernetes in Bluemix Catalog

The next page allows you to choose a data center, cluster name, and if you’re really itching to spend money, there’s a paid option in the bottom left. With that, there’s more cluster customization options. Now then, go ahead and click on “Create Cluster”.

Step 3 — Install the CLI tools

The first tool to install is the Bluemix CLI.
- Mac users, download the installer here.
- Windows users, download the installer here.
- Linux users, please follow the instructions at https://clis.ng.bluemix.net/ui/home.html .

Last, but certainly not least, is the Kubernetes CLI (woot!). 
Mac:

curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.5.5/bin/darwin/amd64/kubectl -o kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl

Linux:

curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.5.5/bin/linux/amd64/kubectl -o kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl

Windows:

curl https://storage.googleapis.com/kubernetes-release/release/v1.5.5/
bin/windows/amd64/kubectl.exe -o kubectl.exe

You’ll be using the Bluemix CLI to get cluster info, and using the Kubernetes CLI (kubectl) to interact with your cluster. Before doing anything though, you must the following command:

bx plugin install container-service -r Bluemix

Step 4 — Access Your Cluster

bx login
bx cs init
bx cs cluster-config clustername

The last command will return information for setting your KUBECONFIG environment variable, which will let kubectl know how to connect to your cluster. It might take a few minutes for the provisioning of your cluster to be fully complete.

Now you should be free to use kubectl for interacting with your cluster. Try a few commands:

kubectl get nodes -o wide

will show information regarding the nodes (virtual machines) that make up your cluster.

kubectl run sample_deployment --image=nginx --port=80
kubectl expose deployment sample_deployment --type=NodePort

The above will expose an Nginx server on your Node’s IP. You can get the port number by doing

kubectl describe deployment sample_deployment

Then you can either go to the IP:Port in your browser, or access it via a curl command.

Conclusion

That’s all there is to it! Now you have your own Kubernetes cluster running on IBM Bluemix, and you’re free to deploy containers just like that.

If you’re more interested in simply writing the code that will be ran, without worrying about containerizing the code with Docker, try serverless development. Specificially, check out IBM’s OpenWhisk, where you can even develop in the browser. https://console.ng.bluemix.net/openwhisk/