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

PDF
Continuous delivery of microservices with kubernetes - Quintor 27-2-2017
PDF
Microservices at scale with docker and kubernetes - AMS JUG 2017
PPTX
Kubernetes Introduction
PDF
Kubernetes on aws
PDF
Kubernetes Architecture and Introduction
PDF
The top 5 Kubernetes metrics to monitor
PDF
Marc Sluiter - 15 Kubernetes Features in 15 Minutes
PPTX
Introduction to Kubernetes
Continuous delivery of microservices with kubernetes - Quintor 27-2-2017
Microservices at scale with docker and kubernetes - AMS JUG 2017
Kubernetes Introduction
Kubernetes on aws
Kubernetes Architecture and Introduction
The top 5 Kubernetes metrics to monitor
Marc Sluiter - 15 Kubernetes Features in 15 Minutes
Introduction to Kubernetes

What's hot (20)

PDF
Scaling Docker with Kubernetes
PDF
Kubernetes - Starting with 1.2
PDF
Containers, Clusters and Kubernetes - Brendan Burns - Defrag 2014
PPTX
Kubernetes Immersion
ODP
Kubernetes Architecture
PDF
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
PDF
Apache Stratos 4.1.0 Architecture
PPTX
Managing Docker Containers In A Cluster - Introducing Kubernetes
PPTX
Orchestrating Docker Containers with Google Kubernetes on OpenStack
PDF
Moving to Kubernetes - Tales from SoundCloud
PDF
Kubernetes 101
PPTX
Docker & Kubernetes intro
PPTX
Deploying apps with Docker and Kubernetes
PDF
Hands on docker
PPTX
Containers in production with docker, coreos, kubernetes and apache stratos
PDF
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
PDF
Platform Orchestration with Kubernetes and Docker
PDF
Kubernetes with docker
PPTX
An Introduction to Kubernetes
PDF
Deploying WSO2 Middleware on Kubernetes
Scaling Docker with Kubernetes
Kubernetes - Starting with 1.2
Containers, Clusters and Kubernetes - Brendan Burns - Defrag 2014
Kubernetes Immersion
Kubernetes Architecture
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
Apache Stratos 4.1.0 Architecture
Managing Docker Containers In A Cluster - Introducing Kubernetes
Orchestrating Docker Containers with Google Kubernetes on OpenStack
Moving to Kubernetes - Tales from SoundCloud
Kubernetes 101
Docker & Kubernetes intro
Deploying apps with Docker and Kubernetes
Hands on docker
Containers in production with docker, coreos, kubernetes and apache stratos
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
Platform Orchestration with Kubernetes and Docker
Kubernetes with docker
An Introduction to Kubernetes
Deploying WSO2 Middleware on Kubernetes
Ad

Viewers also liked (20)

PPTX
Docker containerd Kubernetes sig node
PPTX
Setting up Kubernetes with tectonic
PDF
GitLab, Prometheus и Grafana с Kubernetes
PPTX
Serverless Pune Meetup 1
PDF
Microservices Journey NYC
PPTX
Kubernetes Intro @HaufeDev
PPTX
RackN DevOps meetup NYC
PDF
Welcome talk for Moscow Kubernetes Meetup 1
PDF
Net core, mssql, container und kubernetes
PDF
Opening: builderscon tokyo 2016
PDF
Mirantis Contributions to Kubernetes Ecosystem
PPTX
Keeping up with Tech
PPTX
Microservices summit talk 1/31
PPTX
Ростислав Фридман: “Kubernetes как средство управления микросервисами"
PDF
Docker Containers in Azure
PPTX
Deploy your favorite apps on Kubernetes
PPTX
Kubernetes as Orchestrator for A10 Lightning Controller
PDF
Google Cloud Computing compares GCE, GAE and GKE
PDF
Kubernetes API - deep dive into the kube-apiserver
PDF
Bangalore Container Conference - Sponsor Deck
Docker containerd Kubernetes sig node
Setting up Kubernetes with tectonic
GitLab, Prometheus и Grafana с Kubernetes
Serverless Pune Meetup 1
Microservices Journey NYC
Kubernetes Intro @HaufeDev
RackN DevOps meetup NYC
Welcome talk for Moscow Kubernetes Meetup 1
Net core, mssql, container und kubernetes
Opening: builderscon tokyo 2016
Mirantis Contributions to Kubernetes Ecosystem
Keeping up with Tech
Microservices summit talk 1/31
Ростислав Фридман: “Kubernetes как средство управления микросервисами"
Docker Containers in Azure
Deploy your favorite apps on Kubernetes
Kubernetes as Orchestrator for A10 Lightning Controller
Google Cloud Computing compares GCE, GAE and GKE
Kubernetes API - deep dive into the kube-apiserver
Bangalore Container Conference - Sponsor Deck
Ad

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

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

Recently uploaded (20)

PDF
System and Network Administraation Chapter 3
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
AI in Product Development-omnex systems
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Online Work Permit System for Fast Permit Processing
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Materi_Pemrograman_Komputer-Looping.pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Essential Infomation Tech presentation.pptx
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
history of c programming in notes for students .pptx
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
System and Network Administraation Chapter 3
Softaken Excel to vCard Converter Software.pdf
Odoo POS Development Services by CandidRoot Solutions
Design an Analysis of Algorithms II-SECS-1021-03
AI in Product Development-omnex systems
L1 - Introduction to python Backend.pptx
Online Work Permit System for Fast Permit Processing
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Materi_Pemrograman_Komputer-Looping.pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PTS Company Brochure 2025 (1).pdf.......
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Essential Infomation Tech presentation.pptx
How to Choose the Right IT Partner for Your Business in Malaysia
ManageIQ - Sprint 268 Review - Slide Deck
2025 Textile ERP Trends: SAP, Odoo & Oracle
history of c programming in notes for students .pptx
How to Migrate SBCGlobal Email to Yahoo Easily

Containerizing a REST API and Deploying to Kubernetes