Skip to content

Instantly share code, notes, and snippets.

@CalvinHartwell
Created February 8, 2018 00:57
Show Gist options
  • Select an option

  • Save CalvinHartwell/fe78709add3deab6d469dc8847bb40ab to your computer and use it in GitHub Desktop.

Select an option

Save CalvinHartwell/fe78709add3deab6d469dc8847bb40ab to your computer and use it in GitHub Desktop.
k8s-pod-affinity-rules
...pod webserver
$ cat webserver.yaml
apiVersion: v1
kind: Pod
metadata:
name: webserver
labels:
appname: "webapp"
spec:
containers:
- name: nginx
image: nginx
... pod database
$ cat database.yaml
apiVersion: v1
kind: Pod
metadata:
name: database
spec:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: appname
operator: In
values:
- "webapp"
topologyKey: kubernetes.io/hostname
containers:
- name: pod-affinity
image: mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment