SlideShare a Scribd company logo
And, deploying to Kubernetes
Containerizing a
REST
microservice
Ashley Roach – Cisco DevNet
Principal Engineer & Evangelist
@aroach
@aroach@CiscoDevNetdeveloper.cisco.com
About Me
• API & Cloud Evangelist
• 10+ Yrs Technical Product Mgmt
• Life-long, self-taught developer
• Denver, CO
• github.com/aroach & github.com/ciscodevnet
• Podcast: devtools.libsyn.com
• slideshare.net/aroach
DevNet Vision
Help developers build solutions
and grow their careers.
Learn Code Inspire
@aroach@CiscoDevNetdeveloper.cisco.com
• §1: Why and What
• §2: REST API + Container
• §3: Deploying to Kubernetes
@aroach@CiscoDevNetdeveloper.cisco.com
§1: Why and What
@aroach@CiscoDevNetdeveloper.cisco.com
• Quickly build a REST API using Swagger
• How to containerize it
• How to deploy it
What is this guy talking about?
@aroach@CiscoDevNetdeveloper.cisco.com
• It’s faster
• Saves you from writing boilerplate code
• Useful for mocking REST APIs
• More reliable deployment mechanism
Why build a REST API this way
@aroach@CiscoDevNetdeveloper.cisco.com
§ 2: REST + Containers
@aroach@CiscoDevNetdeveloper.cisco.com
Inspiration
• Created background “mini-hacks” activity at
sales conference
• Needed a way for them to submit answers
• Why not make them do it via an API?!
@aroach@CiscoDevNetdeveloper.cisco.com
Infrastructure Architecture
DBaaS
CI/CD
Scheduler
@aroach@CiscoDevNetdeveloper.cisco.com
Heart of the Matter
@aroach@CiscoDevNetdeveloper.cisco.com
OpenAPI Spec (fka Swagger)
• Open specification for describing REST APIs
• A top-down approach where you would use
the Swagger Editor to create your Swagger definition
and then use the integrated Swagger Codegen tools to
generate server implementation.
• A bottom-up approach where you have an existing
REST API for which you want to create a Swagger
definition.
@aroach@CiscoDevNetdeveloper.cisco.com
Swagger-node
• Runtime environment that includes Swagger Editor
• swagger project <command>
• Start
• Edit
• node app.js for proper deployments
@aroach@CiscoDevNetdeveloper.cisco.com
Swagger Editor
@aroach@CiscoDevNetdeveloper.cisco.com
Demo
@aroach@CiscoDevNetdeveloper.cisco.com
Dockerfile
FROM node:5.11.1
# Create app directory
RUN mkdir -p /usr/src/app
# Establish where your CMD will execute
WORKDIR /usr/src/app
# Bundle app source into the container
COPY ./node_modules /usr/src/app/node_modules
COPY ./api /usr/src/app/api
COPY ./config /usr/src/app/config
COPY ./app.js /usr/src/app/
# Expose the port for the app
EXPOSE 10010
# Execute "node app.js"
CMD ["node", "app.js"]
@aroach@CiscoDevNetdeveloper.cisco.com
Makefile
run:
docker run --rm --name $(NAME)-$(INSTANCE) $(LINK)
$(PORTS) $(VOLUMES) $(ENV) $(NS)/$(REPO):$(VERSION)
$ make run
$ docker run --rm --name swagger-default -p 8080:10010
ciscodevnet/rest-api-swagger:latest
@aroach@CiscoDevNetdeveloper.cisco.com
Demo
@aroach@CiscoDevNetdeveloper.cisco.com
§ 3: Kubernetes
@aroach@CiscoDevNetdeveloper.cisco.com
• Container Orchestration
• Keeping your containers up, scaling them, routing
traffic to them
• Kubernetes != Docker though K8S uses Docker
(or CoreOS rkt)
What is Kubernetes?
@aroach@CiscoDevNetdeveloper.cisco.com
• MiniKube (local workstation)
• Installers (on-prem, hybrid, custom)
• Kops (part of core kubernetes.io github)
• Kubespray (Ansible + Terraform)
• Etc, etc…
• Cloud
• Google Container Engine (GKE )
• Azure Container Service
• Etc…
Installation options
@aroach@CiscoDevNetdeveloper.cisco.com
• Step-by-step tutorial of how to assemble a
kubernetes cluster
• https://github.com/kelseyhightower/kubernetes-
the-hard-way
Sidebar: K8S the hard way
Source: http://x-team.com/2016/07/introduction-kubernetes-architecture/
@aroach@CiscoDevNetdeveloper.cisco.com
Infrastructure Architecture
Persistence
CI/CD
Kubernetes Registry
@aroach@CiscoDevNetdeveloper.cisco.com
• Kubectl & ~/.kube/config
• Minikube CLI
• The Real Way™: CI system
Deploying Containers
@aroach@CiscoDevNetdeveloper.cisco.com
K8S templates: deployment
# k8s/dev/api-deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: rest-api-swagger
spec:
replicas: 2
template:
metadata:
labels:
app: rest-api-swagger
spec:
containers:
- name: rest-api-swagger
image: ciscodevnet/rest-api-swagger:latest
ports:
- containerPort: 10010
@aroach@CiscoDevNetdeveloper.cisco.com
K8S templates: service
# k8s/services/api-service-lb.yaml
kind: Service
apiVersion: v1
metadata:
name: rest-api-swagger
spec:
type: LoadBalancer # or NodePort, etc.
ports:
- name: http
port: 8080
targetPort: 10010
protocol: TCP
selector:
app: rest-api-swagger
@aroach@CiscoDevNetdeveloper.cisco.com
Manual kubectl deployment
$ kubectl apply -f k8s/dev/api-deployment.yaml
$ kubectl apply -f k8s/services/api-service-lb.yaml
$ kubectl describe deployment
$ kubectl describe service rest-api-swagger
$ kubectl delete -f k8s/dev/api-deployment.yaml
$ kubectl delete -f k8s/services/api-service-lb.yaml
@aroach@CiscoDevNetdeveloper.cisco.com
Drone CI kubectl deployment
deploy:
k8s:
image: containers.ex.com/devnet/drone-kubectl
apiserver: https://your-gke-api-endpoint #kubectl cluster-info
token: $$K8S_TOKEN
commands:
- 'kubectl apply -f k8s/services/*.yaml’
- 'kubectl apply -f k8s/dev/*.yaml --record’
- 'kubectl describe service ${SERVICE_NAME}’
when:
branch: master
@aroach@CiscoDevNetdeveloper.cisco.com
Möar Demo
@aroach@CiscoDevNetdeveloper.cisco.com
• Swagger-node provides fast REST API creation
• Prototyping, mocking
• Spec-first development was an adjustment
• Container-based workflows made deployment
super simple
Takeaways
@aroach@CiscoDevNetdeveloper.cisco.com
Helpful Links
• https://communities.cisco.com/people/asroach/blog/2016/09/19/building-the-devnet-api-
scavenger-hunt
• https://communities.cisco.com/people/asroach/blog/2016/08/11/creating-a-cisco-spark-
membership-via-google-forms
• https://github.com/swagger-api/swagger-node
• https://github.com/CiscoDevNet/rest-api-swagger
• https://scotch.io/tutorials/authenticate-a-node-js-api-with-json-web-tokens
• http://blog.mongodb.org/post/32866457221/password-authentication-with-mongoose-part-1
• http://www.itnotes.de/docker/development/tools/2014/08/31/speed-up-your-docker-workflow-
with-a-makefile/
• http://sahatyalkabov.com/how-to-implement-password-reset-in-nodejs/
• https://marcqualie.com/2015/07/docker-dotenv
@aroach@CiscoDevNetdeveloper.cisco.com
Thank you!
Containerizing a REST API and Deploying to Kubernetes

More Related Content

What's hot (20)

PDF
Scaling Docker with Kubernetes
Carlos Sanchez
 
PDF
Kubernetes - Starting with 1.2
William Stewart
 
PDF
Containers, Clusters and Kubernetes - Brendan Burns - Defrag 2014
brendandburns
 
PPTX
Kubernetes Immersion
Juan Larriba
 
ODP
Kubernetes Architecture
Knoldus Inc.
 
PDF
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
Mario Ishara Fernando
 
PDF
Apache Stratos 4.1.0 Architecture
Imesh Gunaratne
 
PPTX
Managing Docker Containers In A Cluster - Introducing Kubernetes
Marc Sluiter
 
PPTX
Orchestrating Docker Containers with Google Kubernetes on OpenStack
Trevor Roberts Jr.
 
PDF
Moving to Kubernetes - Tales from SoundCloud
Tobias Schmidt
 
PDF
Kubernetes 101
Jacopo Nardiello
 
PPTX
Docker & Kubernetes intro
Arnon Rotem-Gal-Oz
 
PPTX
Deploying apps with Docker and Kubernetes
Daniel Fenton
 
PDF
Hands on docker
inovex GmbH
 
PPTX
Containers in production with docker, coreos, kubernetes and apache stratos
WSO2
 
PDF
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
Brian Grant
 
PDF
Platform Orchestration with Kubernetes and Docker
Julian Strobl
 
PDF
Kubernetes with docker
Docker, Inc.
 
PPTX
An Introduction to Kubernetes
Rohman Muhamad
 
PDF
Deploying WSO2 Middleware on Kubernetes
Imesh Gunaratne
 
Scaling Docker with Kubernetes
Carlos Sanchez
 
Kubernetes - Starting with 1.2
William Stewart
 
Containers, Clusters and Kubernetes - Brendan Burns - Defrag 2014
brendandburns
 
Kubernetes Immersion
Juan Larriba
 
Kubernetes Architecture
Knoldus Inc.
 
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
Mario Ishara Fernando
 
Apache Stratos 4.1.0 Architecture
Imesh Gunaratne
 
Managing Docker Containers In A Cluster - Introducing Kubernetes
Marc Sluiter
 
Orchestrating Docker Containers with Google Kubernetes on OpenStack
Trevor Roberts Jr.
 
Moving to Kubernetes - Tales from SoundCloud
Tobias Schmidt
 
Kubernetes 101
Jacopo Nardiello
 
Docker & Kubernetes intro
Arnon Rotem-Gal-Oz
 
Deploying apps with Docker and Kubernetes
Daniel Fenton
 
Hands on docker
inovex GmbH
 
Containers in production with docker, coreos, kubernetes and apache stratos
WSO2
 
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
Brian Grant
 
Platform Orchestration with Kubernetes and Docker
Julian Strobl
 
Kubernetes with docker
Docker, Inc.
 
An Introduction to Kubernetes
Rohman Muhamad
 
Deploying WSO2 Middleware on Kubernetes
Imesh Gunaratne
 

Viewers also liked (20)

PPTX
Docker containerd Kubernetes sig node
Patrick Chanezon
 
PPTX
Setting up Kubernetes with tectonic
Vishal Biyani
 
PDF
GitLab, Prometheus и Grafana с Kubernetes
Victor Login
 
PPTX
Serverless Pune Meetup 1
Vishal Biyani
 
PDF
Microservices Journey NYC
Christian Posta
 
PPTX
Kubernetes Intro @HaufeDev
Haufe-Lexware GmbH & Co KG
 
PPTX
RackN DevOps meetup NYC
Bob Sokol
 
PDF
Welcome talk for Moscow Kubernetes Meetup 1
MoscowKubernetes
 
PDF
Net core, mssql, container und kubernetes
Thomas Fricke
 
PDF
Opening: builderscon tokyo 2016
lestrrat
 
PDF
Mirantis Contributions to Kubernetes Ecosystem
MoscowKubernetes
 
PPTX
Keeping up with Tech
Elana Krasner
 
PPTX
Microservices summit talk 1/31
Varun Talwar
 
PPTX
Ростислав Фридман: “Kubernetes как средство управления микросервисами"
Provectus
 
PDF
Docker Containers in Azure
Aarno Aukia
 
PPTX
Deploy your favorite apps on Kubernetes
Adnan Abdulhussein
 
PPTX
Kubernetes as Orchestrator for A10 Lightning Controller
Akshay Mathur
 
PDF
Google Cloud Computing compares GCE, GAE and GKE
Simon Su
 
PDF
Kubernetes API - deep dive into the kube-apiserver
Stefan Schimanski
 
PDF
Bangalore Container Conference - Sponsor Deck
CodeOps Technologies LLP
 
Docker containerd Kubernetes sig node
Patrick Chanezon
 
Setting up Kubernetes with tectonic
Vishal Biyani
 
GitLab, Prometheus и Grafana с Kubernetes
Victor Login
 
Serverless Pune Meetup 1
Vishal Biyani
 
Microservices Journey NYC
Christian Posta
 
Kubernetes Intro @HaufeDev
Haufe-Lexware GmbH & Co KG
 
RackN DevOps meetup NYC
Bob Sokol
 
Welcome talk for Moscow Kubernetes Meetup 1
MoscowKubernetes
 
Net core, mssql, container und kubernetes
Thomas Fricke
 
Opening: builderscon tokyo 2016
lestrrat
 
Mirantis Contributions to Kubernetes Ecosystem
MoscowKubernetes
 
Keeping up with Tech
Elana Krasner
 
Microservices summit talk 1/31
Varun Talwar
 
Ростислав Фридман: “Kubernetes как средство управления микросервисами"
Provectus
 
Docker Containers in Azure
Aarno Aukia
 
Deploy your favorite apps on Kubernetes
Adnan Abdulhussein
 
Kubernetes as Orchestrator for A10 Lightning Controller
Akshay Mathur
 
Google Cloud Computing compares GCE, GAE and GKE
Simon Su
 
Kubernetes API - deep dive into the kube-apiserver
Stefan Schimanski
 
Bangalore Container Conference - Sponsor Deck
CodeOps Technologies LLP
 
Ad

Similar to Containerizing a REST API and Deploying to Kubernetes (20)

PPTX
Building a REST API Microservice for the DevNet API Scavenger Hunt
Ashley Roach
 
PPTX
Coding 102 REST API Basics Using Spark
Cisco DevNet
 
PPTX
Azure Bootcamp 2016 - Docker Orchestration on Azure with Rancher
Karim Vaes
 
PPTX
Advanced Postman for Better APIs - Web Summit 2018 - Cisco DevNet
Cisco DevNet
 
ODP
Docker AWS TechCONNECT Boston, 28-July-2015
Docker, Inc
 
PDF
Making a small QA system with Docker
Naoki AINOYA
 
PDF
OpenFaaS KubeCon Zero to Serverless in 60 seconds anywhere
Alex Ellis
 
PDF
MesosCon - Be a microservices hero
Dragos Dascalita Haut
 
PDF
ContainerCon 2015 - Be a Microservices Hero
Dragos Dascalita
 
PDF
Docker module 1
Liang Bo
 
PPTX
#dddsw - Modernizing .NET Apps with Docker
Elton Stoneman
 
PPTX
Docker Container As A Service - Mix-IT 2016
Patrick Chanezon
 
PPTX
#SDD2017 - Modernizing .NET Apps with Docker
Elton Stoneman
 
PPTX
Docker Container As A Service - JAX 2016
Patrick Chanezon
 
PPTX
Docker Container As A Service - March 2016
Patrick Chanezon
 
PPTX
Containers as a Service with Docker
Docker, Inc.
 
PDF
Docker All The Things - ASP.NET 4.x and Windows Server Containers
Anthony Chu
 
PPTX
Pipelining DevOps with Jenkins and AWS
Jimmy Ray
 
PDF
Can I Contain This?
Eficode
 
Building a REST API Microservice for the DevNet API Scavenger Hunt
Ashley Roach
 
Coding 102 REST API Basics Using Spark
Cisco DevNet
 
Azure Bootcamp 2016 - Docker Orchestration on Azure with Rancher
Karim Vaes
 
Advanced Postman for Better APIs - Web Summit 2018 - Cisco DevNet
Cisco DevNet
 
Docker AWS TechCONNECT Boston, 28-July-2015
Docker, Inc
 
Making a small QA system with Docker
Naoki AINOYA
 
OpenFaaS KubeCon Zero to Serverless in 60 seconds anywhere
Alex Ellis
 
MesosCon - Be a microservices hero
Dragos Dascalita Haut
 
ContainerCon 2015 - Be a Microservices Hero
Dragos Dascalita
 
Docker module 1
Liang Bo
 
#dddsw - Modernizing .NET Apps with Docker
Elton Stoneman
 
Docker Container As A Service - Mix-IT 2016
Patrick Chanezon
 
#SDD2017 - Modernizing .NET Apps with Docker
Elton Stoneman
 
Docker Container As A Service - JAX 2016
Patrick Chanezon
 
Docker Container As A Service - March 2016
Patrick Chanezon
 
Containers as a Service with Docker
Docker, Inc.
 
Docker All The Things - ASP.NET 4.x and Windows Server Containers
Anthony Chu
 
Pipelining DevOps with Jenkins and AWS
Jimmy Ray
 
Can I Contain This?
Eficode
 
Ad

Recently uploaded (20)

PDF
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PPTX
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PPTX
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
DOCX
Import Data Form Excel to Tally Services
Tally xperts
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PPTX
How Cloud Computing is Reinventing Financial Services
Isla Pandora
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Import Data Form Excel to Tally Services
Tally xperts
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
How Cloud Computing is Reinventing Financial Services
Isla Pandora
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 

Containerizing a REST API and Deploying to Kubernetes