-
Notifications
You must be signed in to change notification settings - Fork 740
Conversation
Can one of the admins verify this patch? |
2 similar comments
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can you guys also help on this PR. As a side note, I noticed the SAP fork of etcd operator. Now etcd operator can already work with swift through its s3 compatible API. We want to get PV in. We want to put some love in the project to move everyone back to upstream. |
@etcd-bot ok to test |
@hongchaodeng , can you explain a bit, what is the node partition case? |
LGTM. |
i have not really looked into the code. but want to mention that if PV is enabled, etcd operator should
|
pkg/apis/etcd/v1beta2/cluster.go
Outdated
|
||
// By default, kubernetes will mount a service account token into the etcd pods. | ||
// AutomountServiceAccountToken indicates whether pods running with the service account should have an API token automatically mounted. | ||
AutomountServiceAccountToken *bool `json:"automountServiceAccountToken,omitempty"` |
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.
Can you remove the changes related to AutomountServiceAccountToken
?
This PR should be about PersistentVolumeClaimSpec
.
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.
Sure thing
@@ -219,6 +219,7 @@ func (r *Restore) createSeedMember(ec *api.EtcdCluster, svcAddr, clusterName str | |||
} | |||
ms := etcdutil.NewMemberSet(m) | |||
backupURL := backupapi.BackupURLForRestore("http", svcAddr, clusterName) | |||
|
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.
remove blank line
pkg/util/k8sutil/k8sutil.go
Outdated
@@ -264,10 +295,12 @@ func newEtcdPod(m *etcdutil.Member, initialCluster []string, clusterName, state, | |||
livenessProbe, | |||
readinessProbe) | |||
|
|||
volumes := []v1.Volume{ | |||
{Name: "etcd-data", VolumeSource: v1.VolumeSource{EmptyDir: &v1.EmptyDirVolumeSource{}}}, | |||
if cs.Pod != nil { |
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.
This changes aren't needed?
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.
It is taken care by function AddEtcdVolumeToPod
in the same file.
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.
Sorry. I don't understand your comment?
Why add this change here?
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.
Here is
func AddEtcdVolumeToPod(pod *v1.Pod, pvc *v1.PersistentVolumeClaim) {
vol := v1.Volume{Name: etcdVolumeName}
if pvc != nil {
vol.VolumeSource = v1.VolumeSource{
PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{ClaimName: pvc.Name},
}
} else {
vol.VolumeSource = v1.VolumeSource{EmptyDir: &v1.EmptyDirVolumeSource{}}
}
pod.Spec.Volumes = append(pod.Spec.Volumes, vol)
}
If it is not PV, it will just append the EmptyDir.
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.
I still don't understand it.
Why is this related to PV or emptyDir? This is what I saw on this PR on github:
if cs.Pod != nil {
container = containerWithRequirements(container, cs.Pod.Resources)
}
It only deals with resources.
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.
Ah, i thought you are asking line 267 & 268.
This line I don't think it has anything to do with this PR scope. It was there mostly because of my cherry pick from the old PR.
I do think it is a nice thing to have. But not belong to this PR's scope. I can remove it though
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.
Please remove this.
It's duplicate. Resource requirements/pod policy are applied outside this func:
etcd-operator/pkg/util/k8sutil/k8sutil.go
Line 338 in 7880638
applyPodPolicy(clusterName, pod, cs.Pod) |
it seems that this PR only adds the PV as the non-stable storage (same as empty dir) for etcd pod, not use PV as a stable storage? if we consider PV as stable storage, we should not add/remove members if the size field is not changed. if one pod dies, we should create another pod with the same FQDN + PV. no member changes need to be involved. when size is changed, we need to add/remove member as before. |
@xiang90 you are right. It is treated as non-stable storage. We should make it as a stable storage. |
i am fine marking this as alpha which uses PV as temp storage. then we can iterate on it. |
@rjtsdl
|
Gopkg.lock
Outdated
@@ -328,6 +328,6 @@ | |||
[solve-meta] | |||
analyzer-name = "dep" | |||
analyzer-version = 1 | |||
inputs-digest = "ff4a4b53ef454edf0ae2ec3bc497baf74d561af328faa123eb472d87954a906c" | |||
inputs-digest = "b19769641bf117041022e3de0c490313047f3b7aaef54e00a7354573fff9b738" |
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.
No need to change this?
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.
It is updated automatically after I ran update_vendor.sh
. Do I need to revert?
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.
yes
it is unfair to say this PR does not handle it. this PR adds PV as non-stable storage. if the node goes down, the operator will still remove the member and add a new one as the empty-dir case, no? |
I'm fine to use it to replace ephemeral storage initially. |
just to be clear. not to replace current ephemeral storage, but another ephemeral storage options besides current empty-dir, right? eventually we should make PV a stable storage option. |
@xiang90 |
That would be awesome. I will address comments, then we can merge it as initial step. |
this patch implements part 1 of the etcd data on persistent volumes design. when pod pvsource is defined in the spec it'll create a PVC for every etcd member and use it as the volume for etcd data. pvc without a member will be removed during the reconcile.
f2852d0
to
2f8dc0d
Compare
pkg/cluster/cluster.go
Outdated
@@ -375,9 +375,26 @@ func (c *Cluster) setupServices() error { | |||
return k8sutil.CreatePeerService(c.config.KubeCli, c.cluster.Name, c.cluster.Namespace, c.cluster.AsOwner()) | |||
} | |||
|
|||
func (c *Cluster) IsPodPVEnabled() bool { |
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.
please add doc string on public method.
pkg/util/k8sutil/k8sutil.go
Outdated
@@ -78,6 +78,10 @@ func GetPodNames(pods []*v1.Pod) []string { | |||
return res | |||
} | |||
|
|||
func PVCNameFromMemberName(memberName string) string { |
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.
please add doc string on public method.
pkg/util/k8sutil/k8sutil.go
Outdated
@@ -209,6 +213,18 @@ func newEtcdServiceManifest(svcName, clusterName, clusterIP string, ports []v1.S | |||
return svc | |||
} | |||
|
|||
func AddEtcdVolumeToPod(pod *v1.Pod, pvc *v1.PersistentVolumeClaim) { |
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.
please add doc string on public method.
pkg/util/k8sutil/k8sutil.go
Outdated
@@ -231,6 +249,19 @@ func NewSeedMemberPod(clusterName string, ms etcdutil.MemberSet, m *etcdutil.Mem | |||
return pod | |||
} | |||
|
|||
func NewEtcdPodPVC(m *etcdutil.Member, pvcSpec v1.PersistentVolumeClaimSpec, clusterName, namespace string, owner metav1.OwnerReference) *v1.PersistentVolumeClaim { |
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.
please add doc string on public method.
pkg/apis/etcd/v1beta2/cluster.go
Outdated
@@ -138,6 +138,9 @@ type PodPolicy struct { | |||
// bootstrap the cluster (for example `--initial-cluster` flag). | |||
// This field cannot be updated. | |||
EtcdEnv []v1.EnvVar `json:"etcdEnv,omitempty"` | |||
|
|||
// PersistentVolumeClaimSpec ... |
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.
complete the comment?
34c3ac4
to
296b27c
Compare
lgtm defer to @hongchaodeng |
pkg/apis/etcd/v1beta2/cluster.go
Outdated
|
||
// PersistentVolumeClaimSpec is the spec to describe PVC for the etcd container | ||
// This field is optional. If no PVC spec, etcd container will use emptyDir as volume | ||
PersistentVolumeClaimSpec *v1.PersistentVolumeClaimSpec `json:"persistentVolumeClaimSpec,omitempty"` |
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.
Please mention that this field is alpha, and not use PV as stable storage as it should yet.
pkg/util/k8sutil/k8sutil.go
Outdated
@@ -78,6 +78,11 @@ func GetPodNames(pods []*v1.Pod) []string { | |||
return res | |||
} | |||
|
|||
// PVCNameFromMemberName the way we get PVC name from the member name | |||
func PVCNameFromMemberName(memberName string) string { |
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.
PVCNameFromMemberName -> PVCNameFromMember
pkg/util/k8sutil/k8sutil.go
Outdated
@@ -264,10 +295,12 @@ func newEtcdPod(m *etcdutil.Member, initialCluster []string, clusterName, state, | |||
livenessProbe, | |||
readinessProbe) | |||
|
|||
volumes := []v1.Volume{ | |||
{Name: "etcd-data", VolumeSource: v1.VolumeSource{EmptyDir: &v1.EmptyDirVolumeSource{}}}, | |||
if cs.Pod != nil { |
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.
I still don't understand it.
Why is this related to PV or emptyDir? This is what I saw on this PR on github:
if cs.Pod != nil {
container = containerWithRequirements(container, cs.Pod.Resources)
}
It only deals with resources.
pkg/util/k8sutil/self_hosted.go
Outdated
DNSPolicy: v1.DNSClusterFirstWithHostNet, | ||
Hostname: m.Name, | ||
Subdomain: clusterName, | ||
AutomountServiceAccountToken: func(b bool) *bool { return &b }(false), |
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.
revert this. It is not related to this PR.
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.
I need to delete AutomountServiceAccountToken
. That is basically all the change here.
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.
I need to delete AutomountServiceAccountToken
What's the reason for it?
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.
Because we want to
Can you remove the changes related to AutomountServiceAccountToken?
This PR should be about PersistentVolumeClaimSpec.
The comment from your previous review.
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.
Can you explain why AutomountServiceAccountToken is related to PV?
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.
I just get it back.
I deleted it while I was trying to remove changes to AutomountServiceAccountToken. Apparently, it shouldn't be removed here.
7801efc
to
458bc6a
Compare
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.
lgtm after nit
pkg/util/k8sutil/k8sutil.go
Outdated
@@ -264,10 +295,12 @@ func newEtcdPod(m *etcdutil.Member, initialCluster []string, clusterName, state, | |||
livenessProbe, | |||
readinessProbe) | |||
|
|||
volumes := []v1.Volume{ | |||
{Name: "etcd-data", VolumeSource: v1.VolumeSource{EmptyDir: &v1.EmptyDirVolumeSource{}}}, | |||
if cs.Pod != nil { |
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.
Please remove this.
It's duplicate. Resource requirements/pod policy are applied outside this func:
etcd-operator/pkg/util/k8sutil/k8sutil.go
Line 338 in 7880638
applyPodPolicy(clusterName, pod, cs.Pod) |
@hongchaodeng thx for explaining. Removed the line. |
Successor of #1695
Copy the plan:
Behavior: first, it will has the eviction behavior. After that, when the nodes back. The Unknown pod(s) would disappear in the pod list.
Behavior: the pod(s) scheduled on the evicted node will become Unknown after a certain period. Then another pod(s) will be scheduled on the healthy nodes to reach the desired replica count. The Unknown will not disappear though.