DZone
Cloud Zone
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
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Cloud Zone > Running the Sample BlueChatter App on Kubernetes

Running the Sample BlueChatter App on Kubernetes

Now that Bluemix has started support for Kubernetes, let's go through what it takes to convert docker-compose files into YAML and build your containers. Orchestrate away!

Niklas Heidloff user avatar by
Niklas Heidloff
CORE ·
Apr. 12, 17 · Cloud Zone · Tutorial
Like (3)
Save
Tweet
4.86K Views

Join the DZone community and get the full member experience.

Join For Free

since last month, bluemix has started to support kubernetes (beta), which many people consider the de-facto standard for container orchestration. some of the older and simpler bluemix sample applications use docker-compose. below is a description of how to run those examples on kubernetes.

essentially, the docker-compose file needs to be converted to a kubernetes yaml file. for example, i use the chat application bluechatter . the sample is a node.js application that leverages redis to store session data. the file docker-compose.yml defines the two containers: the ports and links.

in order to create the kubernetes configuration file, i’ve tried an open source project kompose (kubernetes + compose) . when you run it, four files are created, two for the deployments and two for the services. for a quick introduction to these terms, watch this video . i’ve merged everything into one file.

there were only two things i had to manually change in the file.

  1. i had to enter the name of my docker image, e.g. ‘registry.ng.bluemix.net/nheidloff/bluechatter_web’

  2. in order to expose the web application via a public ip address, i defined a public port for the ‘web’ service via nodeport .

here is a screenshot of the kubernetes dashboard.

kube-bluechatter

here is the kubernetes file ‘bluechatter.yaml’.

apiversion: extensions/v1beta1
kind: deployment
metadata:  
  name: redis
spec:
  replicas: 1  
  template:
    metadata:      
      labels:
        bluechatter: redis
    spec:
      containers:
      - image: redis
        name: redis        
      restartpolicy: always
---
apiversion: v1
kind: service
metadata:  
  labels:
    bluechatter: redis
  name: redis
spec:
  clusterip: none
  ports:
  - name: headless
    port: 55555
    targetport: 0
  selector:
    bluechatter: redis
---
apiversion: extensions/v1beta1
kind: deployment
metadata:  
  name: web
spec:
  replicas: 1
  template:
    metadata:
      labels:
        bluechatter: web
    spec:
      containers:
      - name: web
        image: registry.ng.bluemix.net/nheidloff/bluechatter_web
        ports:
        - containerport: 80
        - containerport: 8080
      restartpolicy: always
---
apiversion: v1
kind: service
metadata:
  labels:
    bluechatter: web
  name: web
spec:
  type: nodeport
  ports:
  - name: "80"
    port: 80
    nodeport: 30072  
  selector:
    bluechatter: web


run these commands to create and configure a cluster.

$ bx cs cluster-create --name my_cluster
$ bx cs workers my_cluster # wait and repeat until state is 'deployed'
$ bx cs cluster-config my_cluster # copy and paste the 'export ...' line


run these commands to build the containers of the sample .

$ git clone https://github.com/ibm-bluemix/bluechatter.git
$ cd bluechatter
$ docker-compose build
$ docker tag bluechatter_web registry.ng.bluemix.net/nheidloff/bluechatter_web
$ docker push registry.ng.bluemix.net/nheidloff/bluechatter_web


run these commands to deploy the sample application.

$ kubectl create -f bluechatter.yaml
$ bx cs workers my_cluster # to get the public ip
$ kubectl describe service web # to get the port (nodeport)


Kubernetes app

Published at DZone with permission of Niklas Heidloff, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Anypoint CLI Commands in MuleSoft
  • 5 Ways to Optimize Your CQL Queries for Performance
  • No Code Expectations vs Reality
  • Kotlin vs Java: Which One Is the Best?

Comments

Cloud Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • 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:

DZone.com is powered by 

AnswerHub logo