DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
11 Monitoring and Observability Tools for 2023
Learn more
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Kubernetes From IBM Bluemix Container Service

Kubernetes From IBM Bluemix Container Service

Learn to set up clusters using Kubernetes on IBM Bluemix, expose services, and manage the logs with the following steps.

Vidyasagar Machupalli user avatar by
Vidyasagar Machupalli
CORE ·
Jun. 21, 17 · Tutorial
Like (3)
Save
Tweet
Share
4.30K Views

Join the DZone community and get the full member experience.

Join For Free

this post helps you get started with kubernetes on ibm bluemix via cli. after a post on how to get started with docker containers on bluemix , the next destination was to play with container orchestration on bluemix.

why do we need container orchestration?

as the use of containers increases and organizations deploy them more widely, the need for tools to manage containers across the infrastructure also increases. orchestrating a cluster of containers is a competitive and rapidly evolving area, and many tools exist offering various feature sets.kubernetes is one of the many container orchestration tools available out there.

why kubernetes on bluemix?

earlier this year, ibm announced the integration of advanced container orchestration of kubernetes into the ibm bluemix container service . you can create your first kubernetes cluster within minutes and flexibly manage dedicated cluster resources for both stateless (microservice) applications and stateful workloads. with a single kubernetes dashboard,

  • manage security compliance throughout your devops pipeline by automatically scanning both docker images and live containers for known vulnerabilities and the presence of malware.
  • verify appropriate container settings and application configurations.
  • review risk ratings and match container service policies to those of your organization.
  • deploy your application with auto-scaling policies to handle fluctuations in workloads and auto-recovery for higher availability.
  • leverage the value of the ibm bluemix platform by easily binding to other services, which bring cognitive and analytics capabilities to your application.

setting bluemix cli for kubernetes

refer to this link for the initial setup and login. additionally, setup kubernetes cli on your local machine to run kubectl commands, tunning kubernetes locally via minikube .

run the below commands to install bluemix container-registry and container-service plugins.

bx plugin install container-registry -r bluemix-bx
bx plugin install container-service -r bluemix-bx

login before you start:

bx login

creating and configuring your first cluster on bluemix

first, initialize the bluemix container service by running the below command:

bx cs init

response:

using default api endpoint: https://us-south.containers.bluemix.net

ok

let's start with a lite cluster:

bx cs cluster-create --name {cluster_name}

to check the list of clusters, run the below command:

bx cs clusters

run the below commands to set the environment variable and download the kubernetes configuration files:

bx cs cluster-config {cluster_name or id}

when the download of the configuration files is finished, a command is displayed that you can use to set the path to the local kubernetes configuration file as an environment variable. to verify whether the kubeconfig environment variable is set properly or not, run the below command (for osx):

echo $kubeconfig

also, run the below command to check the current context; it should be set to your cluster you created on ibm cloud.

kubectl config current-context

point to any folder with a dockerfile and run the below command:

docker build -t registry.ng.bluemix.net/<namespace>/<image_name>:<tag>  .

example <tag> values - latest, 1 etc.

the build command results in a new image that you can start using docker run just like any other image. each line in the dockerfile will correspond to a layer in the image's commit history.

for a sample docker project and dockerfile, refer to this link .

run the below command to push the image to your bluemix private registry:

docker push registry.ng.bluemix.net/<namespace>/<image_name>:<tag>

run the below command to list the images available in your private registry on bluemix:

bx cr images --include-ibm

note: remove --include-ibm to see images under your namespace. this should list the images available in your registry, as shown below:

listing images...

repository                                                     namespace   tag            digest         created         size     vulnerability status   

registry.ng.bluemix.net/ibm-backup-restore                                 latest         bce829551e9a   2 months ago    203 mb   vulnerable   

registry.ng.bluemix.net/ibm-integration-bus                                latest         d614af281959   2 weeks ago     694 mb   vulnerable   

registry.ng.bluemix.net/ibm-mq                                             latest         ed28839a5c76   1 week ago      780 mb   ok   

registry.ng.bluemix.net/ibm-node-strong-pm                                 latest         ae3138081fa6   1 month ago     281 mb   vulnerable   

registry.ng.bluemix.net/ibm-websphere-extreme-scale                        latest         6b458b36f95d   1 week ago      463 mb   ok   

registry.ng.bluemix.net/ibm_wa_agent                                       latest         bc818ce92d11   1 month ago     435 mb   vulnerable   

registry.ng.bluemix.net/ibmliberty                                         javaee7        6f5ef08d5376   2 months ago    317 mb   vulnerable   

registry.ng.bluemix.net/ibmliberty                                         latest         6f5ef08d5376   2 months ago    317 mb   vulnerable   

registry.ng.bluemix.net/ibmliberty                                         microprofile   a6f9cbfeaa95   2 months ago    241 mb   vulnerable   

registry.ng.bluemix.net/ibmliberty                                         webprofile6    26efdf1f962c   2 months ago    271 mb   vulnerable   

registry.ng.bluemix.net/ibmliberty                                         webprofile7    e9849596c72c   2 months ago    279 mb   vulnerable   

registry.ng.bluemix.net/ibmnode                                            latest         329c7a70282d   1 week ago      192 mb   ok   

registry.ng.bluemix.net/ibmnode                                            v1.1           866bede31a01   1 week ago      180 mb   ok   

registry.ng.bluemix.net/ibmnode                                            v1.2           0881af5d9188   1 week ago      186 mb   ok   

registry.ng.bluemix.net/ibmnode                                            v4             dd7bb74fe76d   1 week ago      192 mb   ok   

registry.ng.bluemix.net/mods15/bluechatter                     mods15      latest         2fc2265a9a93   1 hour ago      216 mb   vulnerable   

registry.ng.bluemix.net/mods15/docker-openwhisk-node-console   mods15      1              9de7a52cc8ed   1 day ago       271 mb   vulnerable   

registry.ng.bluemix.net/mods15/hello-world                     mods15      latest         30c3326e99f1   4 months ago    971 b    ok   

registry.ng.bluemix.net/mods15/mf-analytics                    mods15      latest         1cddd191f00f   7 months ago    808 mb   vulnerable   

registry.ng.bluemix.net/mods15/mf-server                       mods15      latest         c765a3767146   10 months ago   1.1 gb   vulnerable   

registry.ng.bluemix.net/mods15/node-openwhisk-docker-console   mods15      latest         96d709515c73   1 month ago     266 mb   vulnerable   

ok

create a deployment and expose the service

to create a deployment, run the below command:

kubectl run <deployment_name> --image=registry.ng.bluemix.net/<namespace>/<image_name>:<tag>

list all your deployments anytime using the command below:

kubectl get deployments

run the below command to create a service:

kubectl expose deployment <deployment_name_created_above> --type=nodeport --name=<service_name>  --port=<port_number>

note: use --type=loadbalancer to accept external traffic. you need an ip address and a port number to access your app. for the ip address, run the command below:

bx cs workers <cluster_name>

you should see the below response:

listing cluster workers...

ok

id                                                 public ip        private ip    machine type   state    status   

kube-xxxx                                          xxx.xxx.xxx.xx   yy.yy.yy.yy    free/paid     normal   ready

public ip is the one you require. the port you mentioned while creating the deployment above is not the actual port; you need nodeport for nodeport- run the below command:

kubectl describe service <service_name>

you should see the below response:

name: donc

namespace: default

labels: run=donc

annotations: <none>

selector: run=donc

type: loadbalancer

ip: 10.10.10.219

port: <unset> 32100/tcp

nodeport: <unset> 30007/tcp

endpoints: 172.30.13.11:32100

session affinity: none

events:

pointing to external_ip: nodeport, you should show the desired output. for logs, you need the pod name:

kubectl get pods

once you have the pod details, run the below command on your terminal to view the logs:

kubectl logs <pod_name>

happy learning!

Docker (software) Kubernetes Bluemix

Published at DZone with permission of Vidyasagar Machupalli, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • DZone's Article Submission Guidelines
  • Unlocking the Power of Elasticsearch: A Comprehensive Guide to Complex Search Use Cases
  • Spring Boot vs Eclipse Micro Profile: Resident Set Size (RSS) and Time to First Request (TFR) Comparative
  • Create a REST API in C# Using ChatGPT

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: