liveBook · Manning

Topology key

As explained in Google Anthos in Action

A topology key is a Kubernetes pod-affinity field that identifies the node-label domain, such as a hostname or zone, used for comparing placement.

A topology key is the node-label key that defines where Kubernetes compares Pods for a Pod affinity or anti-affinity rule. The Pod label selector identifies existing Pods; the topology key sets the placement domain, such as a node or zone. section 3.2.7

Keep licensed Pods on one node

To avoid buying another per-node license, select existing Pods labeled license=widgets and set topologyKey to kubernetes.io/hostname. A required Pod affinity rule then places the new Pod on a node hosting a match. An anti-affinity rule can instead use a zone label to prefer separation. section 3.2.7

apiVersion: v1
kind: Pod
metadata:
name: widgets-license-example
spec:
affinity:
 podAffinity:
  requiredDuringSchedulingIgnoredDuringExecution:
  - labelSelector:
    matchExpressions:
    - key: license
     operator: In
     values:
     - widgets
   topologyKey: kubernetes.io/hostname
containers:
- name: nginx-widgets
 image: nginx-widgets

The Pod manifest shows the label selector and topologyKey together in a required affinity rule. section 3.2.7

How Google Anthos in Action covers it

How deep it goes
Explains the field through required hostname affinity and preferred zone anti-affinity, without detailing scheduler internals.
Examples
Uses a per-node software license and manifests with hostname and zone topology keys.
What it assumes
Assumes familiarity with Pod specifications, labels, and scheduling rules.
What you can do after
Operate/configure it to group matching Pods on one node or prefer separation across zones.
How it connects
Connects Pod label selectors, node labels, Pod affinity, and Pod anti-affinity.

Also explained in

Compare how 2 books explain topology key →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Google Anthos in Action. The section links point to the parts of the book it draws on.