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
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
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. 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 · Tutorial
Like (3)
Save
Tweet
Share
5.00K 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

  • An Introduction to Data Mesh
  • Kotlin Is More Fun Than Java And This Is a Big Deal
  • Stream Processing vs. Batch Processing: What to Know
  • Bye-Bye, Regular Dev [Comic]

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: