Skip to Content
Kubernetes
book

Kubernetes

by David K. Rensin
September 2015
Intermediate to advanced
50 pages
56m
English
O'Reilly Media, Inc.
Content preview from Kubernetes

Chapter 3. Organize, Grow, and Go

Once you start creating pods, you’ll quickly discover how important it is to organize them. As your clusters grow in size and scope, you’ll need to use this organization to manage things effectively. More than that, however, you will need a way to find pods that have been created for a specific purpose and route requests and data to them. In an environment where things are being created and destroyed with some frequency, that’s harder than you think!

Better Living through Labels, Annotations, and Selectors

Kubernetes provides two basic ways to document your infrastructure—labels and annotations.

Labels

A label is a key/value pair that you assign to a Kubernetes object (a pod in this case). You can use pretty well any name you like for your label, as long as you follow some basic naming rules. In this case, the label will decorate a pod and will be part of the pod.yaml file you might create to define your pods and containers.

Let’s use an easy example to demonstrate. Suppose you wanted to identify a pod as being part of the front-end tier of your application. You might create a label named tier and assign it a value of frontend—like so:

“labels”: {

“tier”: “frontend”

}

The text “tier” is the key, and the text “frontend” is the value.

Keys are a combination of zero or more prefixes followed by a “/” character followed by a name string. The prefix and slash are optional. Two examples:

“application.game.awesome-game/tier”

“tier”

In the first case, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Extending Kubernetes

Extending Kubernetes

Gianluca Arbezzano
Hands-on Kubernetes

Hands-on Kubernetes

Sander van Vugt
Kubernetes Microservices

Kubernetes Microservices

Richard Chesterwood
DevOps with Kubernetes

DevOps with Kubernetes

Hideto Saito, Hui-Chuan Chloe Lee, Cheng-Yang Wu

Publisher Resources

ISBN: 9781492048718Errata Page