Skip to content
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

EIP not reassociate when pod moves #9

Closed
TrueTechy opened this issue Apr 1, 2021 · 5 comments
Closed

EIP not reassociate when pod moves #9

TrueTechy opened this issue Apr 1, 2021 · 5 comments

Comments

@TrueTechy
Copy link

When a node is terminated and our pod was moved to another node the EIP didn't update to follow the pod by name to the new node. I noticed the spec is updated to include the Pods IP when it's created but then when the new pod came up with a new IP that wasn't updated in the EIP config.

Our EIP yaml is

apiVersion: aws.k8s.logmein.com/v1alpha1
kind: EIP
metadata:
  name: test-eip
spec:
  publicIPAddress: <EIP IP>
  assignment:
    podName: eip-test-pod

Is there a way we can get the EIP to follow the pod when it's rescheduled? I found by removing the privateIPAddress from the assignment using kubectl edit eip test-eip then the controller detected that and assigned the EIP as expected but ideally this would happen without intervention

@alfredkrohmer
Copy link
Collaborator

Unfortunately with the current logic, it's not easy to detect when the corresponding pod gets deleted / recreated / rescheduled, we would need to add a separate pod controller that checks for every pod that is created if an EIP is attached and then trigger the reconciliation for this EIP. Since you expect this to happen automatically, I assume your pod name stays constant, hence you are using singel pods or a StatefulSet, is that correct?

@alfredkrohmer
Copy link
Collaborator

I just created a pull request #10 with a potential fix. Would you mind trying this out from my branch?

@TrueTechy
Copy link
Author

Hi there, first off thank you so much for the work you've done on this it's helped us solve some problems I'm not sure we would've otherwise.

We are using a stateful set so the name will stay the same between the same between rescheduling. I tested out your PR branch and it detected the pod has been rescheduled, but it seems to have put the private IP in the spec as well as the status of the object so it threw an error about only specifying one of the assignment options

2021-04-05T23:46:08.243Z        ERROR   controller-runtime.controller   Reconciler error        {"controller": "eip", "request": "default/test-eip", "error": "exactly one of podName, eni or privateIPAddress needs to be given in assignment"}

I removed the privateIpAddress like before from the EIP spec and then it assigned to the new pod without issue

@TrueTechy
Copy link
Author

I'll preface this by saying I've not written much in Go, just enough to be dangerous kind of thing.

I found that when the status is set to the spec (eip_controller.go#L377) they seem to become linked, so then on L378 when the privateIP address is set in the status, it's also set in the EIP spec. I tried setting #L377 to eip.Status.Assignment = eip.Spec.Assignment.DeepCopy() which then stopped the spec being updated with the privateIP of the pod, however the comparison logic at eip_controller.go#L103 then meant the controller kept seeing the EIP as having been updated and trying to reconcile it, haven't quite figured out the best way to get around that one

@alfredkrohmer
Copy link
Collaborator

This should be solved via #16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants