Add pod anti-affinity and a disruption budget to cockroachdb example

pull/6/head
Alex Robinson 2016-12-21 16:02:30 -05:00
parent 953488e909
commit ff2ddbf208
3 changed files with 31 additions and 2 deletions

View File

@ -116,7 +116,7 @@ Because all of the resources in this example have been tagged with the label `ap
we can clean up everything that we created in one quick command using a selector on that label:
```shell
kubectl delete statefulsets,pods,persistentvolumes,persistentvolumeclaims,services -l app=cockroachdb
kubectl delete statefulsets,persistentvolumes,persistentvolumeclaims,services,poddisruptionbudget -l app=cockroachdb
```

View File

@ -54,6 +54,18 @@ spec:
selector:
app: cockroachdb
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: cockroachdb-budget
labels:
app: cockroachdb
spec:
selector:
matchLabels:
app: cockroachdb
minAvailable: 67%
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
@ -66,6 +78,22 @@ spec:
labels:
app: cockroachdb
annotations:
scheduler.alpha.kubernetes.io/affinity: >
{
"podAntiAffinity": {
"preferredDuringSchedulingIgnoredDuringExecution": [{
"weight": 100,
"labelSelector": {
"matchExpressions": [{
"key": "app",
"operator": "In",
"values": ["cockroachdb"]
}]
},
"topologyKey": "kubernetes.io/hostname"
}]
}
}
# Init containers are run only once in the lifetime of a pod, before
# it's started up for the first time. It has to exit successfully
# before the pod's main containers are allowed to start.
@ -80,6 +108,7 @@ spec:
{
"name": "bootstrap",
"image": "cockroachdb/cockroach-k8s-init:0.1",
"imagePullPolicy": "IfNotPresent",
"args": [
"-on-start=/on-start.sh",
"-service=cockroachdb"

View File

@ -29,7 +29,7 @@
set -exuo pipefail
# Clean up anything from a prior run:
kubectl delete statefulsets,pods,persistentvolumes,persistentvolumeclaims,services -l app=cockroachdb
kubectl delete statefulsets,persistentvolumes,persistentvolumeclaims,services,poddisruptionbudget -l app=cockroachdb
# Make persistent volumes and (correctly named) claims. We must create the
# claims here manually even though that sounds counter-intuitive. For details