mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-25 07:40:19 +00:00
deploy: add pod anti-affinity for provisioner deployments
The added anti-affinity rules prevent provisioner operators from scheduling on the same nodes. The kubernetes scheduler will spread the pods across nodes to improve availability during node failures. Signed-off-by: Nico Berlee <nico.berlee@on2it.net>
This commit is contained in:
parent
fd4328cd53
commit
6a5f1380b0
@ -29,6 +29,16 @@ spec:
|
|||||||
labels:
|
labels:
|
||||||
app: csi-cephfsplugin-provisioner
|
app: csi-cephfsplugin-provisioner
|
||||||
spec:
|
spec:
|
||||||
|
affinity:
|
||||||
|
podAntiAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- labelSelector:
|
||||||
|
matchExpressions:
|
||||||
|
- key: app
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- csi-cephfsplugin-provisioner
|
||||||
|
topologyKey: "kubernetes.io/hostname"
|
||||||
serviceAccount: cephfs-csi-provisioner
|
serviceAccount: cephfs-csi-provisioner
|
||||||
containers:
|
containers:
|
||||||
- name: csi-provisioner
|
- name: csi-provisioner
|
||||||
|
@ -29,6 +29,16 @@ spec:
|
|||||||
labels:
|
labels:
|
||||||
app: csi-rbdplugin-provisioner
|
app: csi-rbdplugin-provisioner
|
||||||
spec:
|
spec:
|
||||||
|
affinity:
|
||||||
|
podAntiAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- labelSelector:
|
||||||
|
matchExpressions:
|
||||||
|
- key: app
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- csi-rbdplugin-provisioner
|
||||||
|
topologyKey: "kubernetes.io/hostname"
|
||||||
serviceAccount: rbd-csi-provisioner
|
serviceAccount: rbd-csi-provisioner
|
||||||
containers:
|
containers:
|
||||||
- name: csi-provisioner
|
- name: csi-provisioner
|
||||||
|
@ -63,6 +63,7 @@ func createORDeleteCephfsResouces(action string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Failf("failed to read content from %s with error %v", cephfsDirPath+cephfsProvisioner, err)
|
e2elog.Failf("failed to read content from %s with error %v", cephfsDirPath+cephfsProvisioner, err)
|
||||||
}
|
}
|
||||||
|
data = oneReplicaDeployYaml(data)
|
||||||
_, err = framework.RunKubectlInput(cephCSINamespace, data, action, ns, "-f", "-")
|
_, err = framework.RunKubectlInput(cephCSINamespace, data, action, ns, "-f", "-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Failf("failed to %s CephFS provisioner with error %v", action, err)
|
e2elog.Failf("failed to %s CephFS provisioner with error %v", action, err)
|
||||||
|
@ -70,6 +70,7 @@ func createORDeleteRbdResouces(action string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Failf("failed to read content from %s with error %v", rbdDirPath+rbdProvisioner, err)
|
e2elog.Failf("failed to read content from %s with error %v", rbdDirPath+rbdProvisioner, err)
|
||||||
}
|
}
|
||||||
|
data = oneReplicaDeployYaml(data)
|
||||||
_, err = framework.RunKubectlInput(cephCSINamespace, data, action, ns, "-f", "-")
|
_, err = framework.RunKubectlInput(cephCSINamespace, data, action, ns, "-f", "-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Failf("failed to %s rbd provisioner with error %v", action, err)
|
e2elog.Failf("failed to %s rbd provisioner with error %v", action, err)
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -492,3 +493,8 @@ func addTopologyDomainsToDSYaml(template, labels string) string {
|
|||||||
return strings.ReplaceAll(template, "# - \"--domainlabels=failure-domain/region,failure-domain/zone\"",
|
return strings.ReplaceAll(template, "# - \"--domainlabels=failure-domain/region,failure-domain/zone\"",
|
||||||
"- \"--domainlabels="+labels+"\"")
|
"- \"--domainlabels="+labels+"\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func oneReplicaDeployYaml(template string) string {
|
||||||
|
var re = regexp.MustCompile(`(\s+replicas:) \d+`)
|
||||||
|
return re.ReplaceAllString(template, `$1 1`)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user