Skip to content

Instantly share code, notes, and snippets.

@coresolve
Created February 23, 2018 19:45
Show Gist options
  • Save coresolve/ebcbe6beac454eda3a68db639cce36b5 to your computer and use it in GitHub Desktop.
Save coresolve/ebcbe6beac454eda3a68db639cce36b5 to your computer and use it in GitHub Desktop.
test anti affinity of pods.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
creationTimestamp: null
labels:
run: slam
name: slam
spec:
replicas: 30
selector:
matchLabels:
run: slam
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
run: slam
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: run #I am using the labels set on the nodes of this deployment.
operator: In
values:
- slam
topologyKey: kubernetes.io/hostname
containers:
- image: quay.io/dcooley/simple-app:plain
name: slam
resources: {}
status: {}
$ kubectl get pods -o jsonpath={..spec.nodeName} | tr ' ' '\n' | sort | uniq -c
  15 ip-10-0-34-210.us-west-1.compute.internal
  15 ip-10-0-61-157.us-west-1.compute.internal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment