-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 60: Data protection / High availability #92
Changes from 33 commits
dfe8fd9
03a91d6
f5dedba
62b41d6
2eb0ffe
6d74a06
72bebfa
d563a31
641c6dd
8330e6c
7a3076c
c5bdeca
be07e84
bb125b7
a0bf459
1a4abf4
7c0bac9
516dbba
9308bb3
cbe2bd1
5898411
f6e0caf
01a0bac
504bfbb
23f459e
b552b95
3b00b0d
75dbf31
6f33b83
3941faf
022d224
7b5e535
181112b
34b0edc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ import ( | |
"github.com/pravega/pravega-operator/pkg/util" | ||
appsv1 "k8s.io/api/apps/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
policyv1beta1 "k8s.io/api/policy/v1beta1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/util/intstr" | ||
) | ||
|
@@ -127,6 +128,7 @@ func makeSegmentstorePodSpec(pravegaCluster *api.PravegaCluster) corev1.PodSpec | |
}, | ||
}, | ||
}, | ||
Affinity: util.PodAntiAffinity("pravega-segmentstore", pravegaCluster.Name), | ||
} | ||
|
||
if pravegaSpec.SegmentStoreServiceAccountName != "" { | ||
|
@@ -141,6 +143,9 @@ func makeSegmentstorePodSpec(pravegaCluster *api.PravegaCluster) corev1.PodSpec | |
func MakeSegmentstoreConfigMap(pravegaCluster *api.PravegaCluster) *corev1.ConfigMap { | ||
javaOpts := []string{ | ||
"-Dpravegaservice.clusterName=" + pravegaCluster.Name, | ||
"-Dbookkeeper.bkEnsembleSize=2", | ||
"-Dbookkeeper.bkAckQuorumSize=2", | ||
"-Dbookkeeper.bkWriteQuorumSize=2", | ||
} | ||
|
||
for name, value := range pravegaCluster.Spec.Pravega.Options { | ||
|
@@ -326,3 +331,30 @@ func MakeSegmentStoreExternalServices(pravegaCluster *api.PravegaCluster) []*cor | |
} | ||
return services | ||
} | ||
|
||
func MakeSegmentstorePodDisruptionBudget(pravegaCluster *api.PravegaCluster) *policyv1beta1.PodDisruptionBudget { | ||
var maxUnavailable intstr.IntOrString | ||
|
||
if pravegaCluster.Spec.Pravega.SegmentStoreReplicas == int32(1) { | ||
maxUnavailable = intstr.FromInt(0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if we should remove this if clause. If there is a single instance, then in principle we never want it down. At the same time, it is not possible to guarantee it. As the PDB policy is a soft policy, the pod will be brought down anyway in the case k8s needs to do it, so we might as well remove the if and leave it at:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PDB protects pods from planned disruptions, such as a node eviction. In such case, if we have 1 Segment Store replica and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand this comment:
How does the user know it is being given time to increase the replica count? Also, is it saying that we can have multiple instances temporarily? That might be worse than having none temporarily and then one back because that will multiple temporarily will induce two rebalances of the segment containers. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Due to the PDB, Kubernetes will put the eviction on hold until the affected pod is deleted. It's up to the user to decide what to do, they can increase the replica count to avoid down time; or they can just delete the pod altogether and let Kubernetes reschedule it.
Yes, but not necessarily, the user can just delete the pod and avoid having multiple instances temporarily. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused about how the user knows that a pod needs to be deleted. I'm assuming that the eviction is part of some automated process and K8s is applying a policy to decide how to bring specific pods down. |
||
} else { | ||
maxUnavailable = intstr.FromInt(1) | ||
} | ||
|
||
return &policyv1beta1.PodDisruptionBudget{ | ||
TypeMeta: metav1.TypeMeta{ | ||
Kind: "PodDisruptionBudget", | ||
APIVersion: "policy/v1beta1", | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: util.PdbNameForSegmentstore(pravegaCluster.Name), | ||
Namespace: pravegaCluster.Namespace, | ||
}, | ||
Spec: policyv1beta1.PodDisruptionBudgetSpec{ | ||
MaxUnavailable: &maxUnavailable, | ||
Selector: &metav1.LabelSelector{ | ||
MatchLabels: util.LabelsForSegmentStore(pravegaCluster), | ||
}, | ||
}, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove these lines, and probably give a way to the user to set these values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I'll remove those lines as the default value is already set to
2
and this way we will allow users to override the default values using theoptions
CR section.