SlideShare a Scribd company logo
An API Intro:
Driving containerd
operations with
gRPC
WHO AM I?
Phil Estes
Senior Technical Staff, Office of the CTO, IBM Cloud
Maintainer, Docker engine
Maintainer, containerd
Contributor, OCI/runc
Docker Captains program member
Blog: https://integratedcode.us
Twitter: @estesp
1.
What is gRPC?
YOU PROBABLY ALREADY HAVE AN IDEA OF WHAT A CLIENT IS
▸ Command-line client (e.g. runc)
▸ REST/HTTP client (e.g. docker -> dockerd)
▸ Web/HTTP client (e.g. curl, your web browser)
gRPC is simply a client-server method execution model
built on the long-standing “remote procedure call”
(RPC) style interface.
gRPC is an open source project created by Google and a
full toolkit is available for many platforms:
https://github.com/grpc/grpc | https://grpc.io
“In gRPC a client application can directly call methods
on a server application on a different machine as if it
was a local object, making it easier for you to create
distributed applications and services. As in many RPC
systems, gRPC is based around the idea of defining a
service, specifying the methods that can be called
remotely with their parameters and return types.
FROM: http://www.grpc.io/docs/guides/ :
IMPORTANT CONCEPTS: SERVICES & PROTOCOL BUFFERS
▸ A gRPC API has service definitions.
▸ These service definitions have rpc methods.
▸ These rpc methods have “protobuf” defined
message content (request & response)
“Protocol buffers are a flexible, efficient, automated
mechanism for serializing structured data – think XML,
but smaller, faster, and simpler. You define how you
want your data to be structured once, then you can use
special generated source code to easily write and read
your structured data to and from a variety of data
streams and using a variety of languages. You can even
update your data structure without breaking deployed
programs that are compiled against the "old" format.
FROM:
https://developers.google.com/protocol-buffers/docs/overview :
OK, FINE, BUT WHY gRPC+PROTOBUFS OVER JSON+HTTP/etc?
Code Generation
No more writing
clients by hand!
Generators convert
.proto files into
language-specific
bindings for client
and server.
Speed & Size
Protobuf binary
packed format
marshalled from
clients<-->servers is
smaller than JSON or
XML and better
performing for
serialization &
deserialization.
Commonality
gRPC and protobufs
are growing in
popularity. gRPC is
used in Docker
Swarm, Kubernetes,
etcd, and adopted by
companies like
CoreOS, Netflix,
Square and others.
MORE gRPC BENEFITS
▸ gRPC Connection support & options are rich and
completely built-in to the implementation
▹ Less time writing or finding server code to
handle special socket options, HTTP2,
authentication, streaming, etc.
gRPC Connect Example:
2.
How is
containerd
using gRPC?
MAJOR API COMPONENTS
▸ Current gRPC services:
▹ Execution, Shim, and Content
▸ Go 1.8 provides plugin support
▹ Expect gRPC services to be pluggable
Execution
- Create
- Start
- Delete
- List
- Events
Shim
- Create
- Start
- Delete
- Exec
- Pty
- Events
- State
- Pause
- Resume
- Exit
Content
- Info
- Read
- Status
- Write
SERVICE API/PROTOBUF DEFINITIONS
▸ Each service has a .proto file with all definitions
▸ Common definitions (e.g. types) can be included
▸ Protobuf compiler generates appropriate
language binding (e.g. Go code)
api/services/shim/shim.proto
CODE GENERATION: FROM PROTO -> GO SOURCES
*WARNING: NOT FOR THE FAINT OF HEART!
commit 83e7610194170c794752088d54b0c3673b311811
Author: Stephen J Day <stephen.day@docker.com>
Date: Tue Feb 14 16:48:36 2017 -0800
cmd/ctrd-protobuild: create proper command for building protos
After trying to explain the complexities of developing with protobuf, I
have now created a command that correctly calculates the import paths
for each package and runs the protobuf command.
▸ make protos uses go generate tooling*
▸ <service>.pb.go files are created with the Go bindings
▸ Only required when changing (add/remove/modify) API
or message/type definitions
3.
Create your own
gRPC service
and/or client
`CTR LIST` AS AN EXAMPLE: SERVER SIDE (GENERATED)
▸ Generated execution.pb.go has interface for
server as well as handler which calls List method
func _ContainerService_List_Handler(srv interface{}, ctx context.Context, dec
func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
…
return srv.(ContainerServiceServer).List(ctx, in)
…
}
api/services/execution/execution.pb.go
`CTR LIST` AS AN EXAMPLE: SERVER SIDE (IMPLEMENTED)
▸ We implement the ContainerServiceServer.List
method to perform the operation and return the
appropriate gRPC message response:
`CTR LIST` AS AN EXAMPLE: CLIENT SIDE
▸ The client code to call the gRPC method is already
created for us during protobuf generation
▸ We only need to connect our client command to this
generated client stub:
var listCommand = cli.Command{
Name: "list",
Action: func(context *cli.Context) error {
containers, err := getExecutionService(context)
response, err := containers.List(gocontext.Background(),
&execution.ListRequest{})
for _, c := range response.Containers {
// print container information
}
return nil
},
}
cmd/ctr/list.go
TAKING THE
NEXT STEP
CONSUME CONTAINERD VIA gRPC CLIENT
HELP IMPROVE/DEFINE NEW AREAS OF
CORE CONTAINERD API
ADD SERVICE VIA GO 1.8 PLUGINS + gRPC
PROTO SERVICE DEFINITION
4.
Summary
Expected that consumers of containerd
will use the gRPC API. The ctr tool is a
development/admin resource.
gRPC benefits outweigh any added
complexity with protobufs for defining and
implementing the API layer.
The API is under heavy development
and will stabilize leading up to the
1.0 release of containerd. Post 1.0,
gRPC versioning will allow us to
retain backwards compatibility.
CREDITS
Special thanks to all the people who made and released these
awesome resources for free:
▸ Simple line icons by Mirko Monti
▸ E-commerce icons by Virgil Pana
▸ Streamline iconset by Webalys
▸ Presentation template by SlidesCarnival

More Related Content

PDF
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
PDF
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...
PDF
CI with Gitlab & Docker
PDF
Kubernetes scheduling and QoS
PDF
Webinar - Unbox GitLab CI/CD
PDF
Kubernetes Introduction
PDF
Simple and Scalable Microservices: Using NATS with Docker Compose and Swarm
PDF
[KubeCon EU 2021] Introduction and Deep Dive Into Containerd
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...
CI with Gitlab & Docker
Kubernetes scheduling and QoS
Webinar - Unbox GitLab CI/CD
Kubernetes Introduction
Simple and Scalable Microservices: Using NATS with Docker Compose and Swarm
[KubeCon EU 2021] Introduction and Deep Dive Into Containerd

What's hot (20)

ODP
containerD
PPTX
PDF
Ansible container
PPTX
Containerd internals: building a core container runtime
PDF
MongoDB WiredTiger Internals: Journey To Transactions
PDF
Designing a complete ci cd pipeline using argo events, workflow and cd products
PDF
NGINX Ingress Controller for Kubernetes
PPTX
Introduction to Cryptography & PGP
PDF
Services in kubernetes-KnolX .pdf
PDF
Xen Project Contributor Training Part 3 - Communication v1.0
PPTX
Prometheus design and philosophy
PDF
Linking Metrics to Logs using Loki
ODP
OpenGurukul : Database : PostgreSQL
PDF
PostgreSQL High Availability in a Containerized World
PDF
[KubeCon EU 2022] Running containerd and k3s on macOS
PPTX
Git n git hub
PDF
Introduction to gRPC: A general RPC framework that puts mobile and HTTP/2 fir...
ODP
OpenStack Oslo Messaging RPC API Tutorial Demo Call, Cast and Fanout
PPTX
Kubernetes & Google Kubernetes Engine (GKE)
PDF
Pulsar summit asia 2021: Designing Pulsar for Isolation
containerD
Ansible container
Containerd internals: building a core container runtime
MongoDB WiredTiger Internals: Journey To Transactions
Designing a complete ci cd pipeline using argo events, workflow and cd products
NGINX Ingress Controller for Kubernetes
Introduction to Cryptography & PGP
Services in kubernetes-KnolX .pdf
Xen Project Contributor Training Part 3 - Communication v1.0
Prometheus design and philosophy
Linking Metrics to Logs using Loki
OpenGurukul : Database : PostgreSQL
PostgreSQL High Availability in a Containerized World
[KubeCon EU 2022] Running containerd and k3s on macOS
Git n git hub
Introduction to gRPC: A general RPC framework that puts mobile and HTTP/2 fir...
OpenStack Oslo Messaging RPC API Tutorial Demo Call, Cast and Fanout
Kubernetes & Google Kubernetes Engine (GKE)
Pulsar summit asia 2021: Designing Pulsar for Isolation
Ad

Similar to Driving containerd operations with gRPC (20)

PDF
Up and Running with gRPC & Cloud Career [GDG-Cloud-Dhaka-IO/2022}
PDF
Running gRPC Services for Serving Legacy API on Kubernetes
PPTX
Demystifying gRPC in .Net by John Staveley
PDF
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
PPTX
The new (is it really ) api stack
PPTX
Ingress overview
PDF
Microservices Communication Patterns with gRPC
PPTX
Salesforce Developer User Group, Oslo, Norway - Salesforce PubSub API and gRP...
PDF
gRPC and Microservices
PDF
202107 - Orion introduction - COSCUP
PDF
KrakenD API Gateway
PPTX
CocoaConf: The Language of Mobile Software is APIs
PPTX
What is gRPC introduction gRPC Explained
PDF
Kubernetes: The Next Research Platform
PPTX
Modern webservices using gRPC and Protocol Buffers in Golang
PDF
Cloud native IPC for Microservices Workshop @ Containerdays 2022
PDF
Creating microservices architectures using node.js and Kubernetes
PPTX
ASP.NET Core 3.0 Deep Dive
PPT
Introduction to Thrift
PDF
Kubernetes for the PHP developer
Up and Running with gRPC & Cloud Career [GDG-Cloud-Dhaka-IO/2022}
Running gRPC Services for Serving Legacy API on Kubernetes
Demystifying gRPC in .Net by John Staveley
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
The new (is it really ) api stack
Ingress overview
Microservices Communication Patterns with gRPC
Salesforce Developer User Group, Oslo, Norway - Salesforce PubSub API and gRP...
gRPC and Microservices
202107 - Orion introduction - COSCUP
KrakenD API Gateway
CocoaConf: The Language of Mobile Software is APIs
What is gRPC introduction gRPC Explained
Kubernetes: The Next Research Platform
Modern webservices using gRPC and Protocol Buffers in Golang
Cloud native IPC for Microservices Workshop @ Containerdays 2022
Creating microservices architectures using node.js and Kubernetes
ASP.NET Core 3.0 Deep Dive
Introduction to Thrift
Kubernetes for the PHP developer
Ad

More from Docker, Inc. (20)

PDF
Containerize Your Game Server for the Best Multiplayer Experience
PDF
How to Improve Your Image Builds Using Advance Docker Build
PDF
Build & Deploy Multi-Container Applications to AWS
PDF
Securing Your Containerized Applications with NGINX
PDF
How To Build and Run Node Apps with Docker and Compose
PDF
Hands-on Helm
PDF
Distributed Deep Learning with Docker at Salesforce
PDF
The First 10M Pulls: Building The Official Curl Image for Docker Hub
PDF
Monitoring in a Microservices World
PDF
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
PDF
Predicting Space Weather with Docker
PDF
Become a Docker Power User With Microsoft Visual Studio Code
PDF
How to Use Mirroring and Caching to Optimize your Container Registry
PDF
Monolithic to Microservices + Docker = SDLC on Steroids!
PDF
Kubernetes at Datadog Scale
PDF
Labels, Labels, Labels
PDF
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
PDF
Build & Deploy Multi-Container Applications to AWS
PDF
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
PDF
Developing with Docker for the Arm Architecture
Containerize Your Game Server for the Best Multiplayer Experience
How to Improve Your Image Builds Using Advance Docker Build
Build & Deploy Multi-Container Applications to AWS
Securing Your Containerized Applications with NGINX
How To Build and Run Node Apps with Docker and Compose
Hands-on Helm
Distributed Deep Learning with Docker at Salesforce
The First 10M Pulls: Building The Official Curl Image for Docker Hub
Monitoring in a Microservices World
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
Predicting Space Weather with Docker
Become a Docker Power User With Microsoft Visual Studio Code
How to Use Mirroring and Caching to Optimize your Container Registry
Monolithic to Microservices + Docker = SDLC on Steroids!
Kubernetes at Datadog Scale
Labels, Labels, Labels
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
Build & Deploy Multi-Container Applications to AWS
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
Developing with Docker for the Arm Architecture

Recently uploaded (20)

PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Encapsulation theory and applications.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Empathic Computing: Creating Shared Understanding
PPT
Teaching material agriculture food technology
PDF
Machine learning based COVID-19 study performance prediction
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Mobile App Security Testing_ A Comprehensive Guide.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
NewMind AI Monthly Chronicles - July 2025
Encapsulation theory and applications.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Unlocking AI with Model Context Protocol (MCP)
Per capita expenditure prediction using model stacking based on satellite ima...
The AUB Centre for AI in Media Proposal.docx
Understanding_Digital_Forensics_Presentation.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Empathic Computing: Creating Shared Understanding
Teaching material agriculture food technology
Machine learning based COVID-19 study performance prediction
The Rise and Fall of 3GPP – Time for a Sabbatical?
20250228 LYD VKU AI Blended-Learning.pptx

Driving containerd operations with gRPC

  • 1. An API Intro: Driving containerd operations with gRPC
  • 2. WHO AM I? Phil Estes Senior Technical Staff, Office of the CTO, IBM Cloud Maintainer, Docker engine Maintainer, containerd Contributor, OCI/runc Docker Captains program member Blog: https://integratedcode.us Twitter: @estesp
  • 4. YOU PROBABLY ALREADY HAVE AN IDEA OF WHAT A CLIENT IS ▸ Command-line client (e.g. runc) ▸ REST/HTTP client (e.g. docker -> dockerd) ▸ Web/HTTP client (e.g. curl, your web browser) gRPC is simply a client-server method execution model built on the long-standing “remote procedure call” (RPC) style interface. gRPC is an open source project created by Google and a full toolkit is available for many platforms: https://github.com/grpc/grpc | https://grpc.io
  • 5. “In gRPC a client application can directly call methods on a server application on a different machine as if it was a local object, making it easier for you to create distributed applications and services. As in many RPC systems, gRPC is based around the idea of defining a service, specifying the methods that can be called remotely with their parameters and return types. FROM: http://www.grpc.io/docs/guides/ :
  • 6. IMPORTANT CONCEPTS: SERVICES & PROTOCOL BUFFERS ▸ A gRPC API has service definitions. ▸ These service definitions have rpc methods. ▸ These rpc methods have “protobuf” defined message content (request & response)
  • 7. “Protocol buffers are a flexible, efficient, automated mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages. You can even update your data structure without breaking deployed programs that are compiled against the "old" format. FROM: https://developers.google.com/protocol-buffers/docs/overview :
  • 8. OK, FINE, BUT WHY gRPC+PROTOBUFS OVER JSON+HTTP/etc? Code Generation No more writing clients by hand! Generators convert .proto files into language-specific bindings for client and server. Speed & Size Protobuf binary packed format marshalled from clients<-->servers is smaller than JSON or XML and better performing for serialization & deserialization. Commonality gRPC and protobufs are growing in popularity. gRPC is used in Docker Swarm, Kubernetes, etcd, and adopted by companies like CoreOS, Netflix, Square and others.
  • 9. MORE gRPC BENEFITS ▸ gRPC Connection support & options are rich and completely built-in to the implementation ▹ Less time writing or finding server code to handle special socket options, HTTP2, authentication, streaming, etc. gRPC Connect Example:
  • 11. MAJOR API COMPONENTS ▸ Current gRPC services: ▹ Execution, Shim, and Content ▸ Go 1.8 provides plugin support ▹ Expect gRPC services to be pluggable Execution - Create - Start - Delete - List - Events Shim - Create - Start - Delete - Exec - Pty - Events - State - Pause - Resume - Exit Content - Info - Read - Status - Write
  • 12. SERVICE API/PROTOBUF DEFINITIONS ▸ Each service has a .proto file with all definitions ▸ Common definitions (e.g. types) can be included ▸ Protobuf compiler generates appropriate language binding (e.g. Go code) api/services/shim/shim.proto
  • 13. CODE GENERATION: FROM PROTO -> GO SOURCES *WARNING: NOT FOR THE FAINT OF HEART! commit 83e7610194170c794752088d54b0c3673b311811 Author: Stephen J Day <stephen.day@docker.com> Date: Tue Feb 14 16:48:36 2017 -0800 cmd/ctrd-protobuild: create proper command for building protos After trying to explain the complexities of developing with protobuf, I have now created a command that correctly calculates the import paths for each package and runs the protobuf command. ▸ make protos uses go generate tooling* ▸ <service>.pb.go files are created with the Go bindings ▸ Only required when changing (add/remove/modify) API or message/type definitions
  • 14. 3. Create your own gRPC service and/or client
  • 15. `CTR LIST` AS AN EXAMPLE: SERVER SIDE (GENERATED) ▸ Generated execution.pb.go has interface for server as well as handler which calls List method func _ContainerService_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { … return srv.(ContainerServiceServer).List(ctx, in) … } api/services/execution/execution.pb.go
  • 16. `CTR LIST` AS AN EXAMPLE: SERVER SIDE (IMPLEMENTED) ▸ We implement the ContainerServiceServer.List method to perform the operation and return the appropriate gRPC message response:
  • 17. `CTR LIST` AS AN EXAMPLE: CLIENT SIDE ▸ The client code to call the gRPC method is already created for us during protobuf generation ▸ We only need to connect our client command to this generated client stub: var listCommand = cli.Command{ Name: "list", Action: func(context *cli.Context) error { containers, err := getExecutionService(context) response, err := containers.List(gocontext.Background(), &execution.ListRequest{}) for _, c := range response.Containers { // print container information } return nil }, } cmd/ctr/list.go
  • 18. TAKING THE NEXT STEP CONSUME CONTAINERD VIA gRPC CLIENT HELP IMPROVE/DEFINE NEW AREAS OF CORE CONTAINERD API ADD SERVICE VIA GO 1.8 PLUGINS + gRPC PROTO SERVICE DEFINITION
  • 19. 4. Summary Expected that consumers of containerd will use the gRPC API. The ctr tool is a development/admin resource. gRPC benefits outweigh any added complexity with protobufs for defining and implementing the API layer. The API is under heavy development and will stabilize leading up to the 1.0 release of containerd. Post 1.0, gRPC versioning will allow us to retain backwards compatibility.
  • 20. CREDITS Special thanks to all the people who made and released these awesome resources for free: ▸ Simple line icons by Mirko Monti ▸ E-commerce icons by Virgil Pana ▸ Streamline iconset by Webalys ▸ Presentation template by SlidesCarnival