Skip to content

Instantly share code, notes, and snippets.

@chrislovecnm
Created March 15, 2017 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrislovecnm/6b6cb96c579fab560d5b4ded491435a5 to your computer and use it in GitHub Desktop.
Save chrislovecnm/6b6cb96c579fab560d5b4ded491435a5 to your computer and use it in GitHub Desktop.
example yaml for pod anti-affinity
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
nginx: yes
annotations:
scheduler.alpha.kubernetes.io/affinity: >
{
"nodeAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": [
{
"labelSelector": {
"matchExpressions": [
{
"key": "x-web",
"operator": "In",
"values": ["yes", "true"]
}
]
}
}
]
},
"podAntiAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": [
{
"labelSelector": {
"matchExpressions": [
{
"key": "httpd",
"operator": "Exists"
"values": ["yes", "true"]
}
]
}
}
]
}
}
spec:
containers:
- name: nginx
image: nginx
---
apiVersion: v1
kind: Pod
metadata:
name: httpd
labels:
nginx: yes
annotations:
scheduler.alpha.kubernetes.io/affinity: >
{
"nodeAffinity": {
"preferredDuringSchedulingIgnoredDuringExecution": [
{
"labelSelector": {
"matchExpressions": [
{
"key": "y-web",
"operator": "In",
"values": ["yes", "true"]
}
]
}
}
]
}
}
spec:
containers:
- name: httpd
image: httpd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment