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

Route flannel via existing wireguard interface #178

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

voron
Copy link
Contributor

@voron voron commented Aug 25, 2018

Untested
Closes #139

@voron
Copy link
Contributor Author

voron commented Aug 25, 2018

@xetys @mavimo @JohnnyQQQQ pls advise how to pass codeclimate 4 return statements limit

@mavimo
Copy link
Collaborator

mavimo commented Aug 26, 2018

@voron IMHO codeclimate check should be ignored in this case. We should "bypass" the check removing the last if and return err, if no error it return nil. This should work but make code less comprehensible so I prefer to keep it as is.
I just suggest to move the wireguard setup in a separate function as we do for flannel.
Other possible solution is to create a new function prepareNetwork that invoke flannel config and wireguard config creating only one return value (but still a workaround)

@xetys
Copy link
Owner

xetys commented Aug 26, 2018 via email

@mavimo
Copy link
Collaborator

mavimo commented Aug 26, 2018

@xetys IMHO this rule is too strict in Golang context where the early return approach is a standard, especially for error returning.

Aside the above opinion, on the previous comment my last proposal was:

func (provisioner *NodeProvisioner) preparePackages() error {
	// ...
	err = provisioner.prepareNetwork()
	if err != nil {
		return err
	}

	return nil
}

func (provisioner *NodeProvisioner) prepareNetwork() error {
	err = provisioner.prepareFlannel()
	if err != nil {
		return err
	}

	err = provisioner.prepareWireguard()
	if err != nil {
		return err
	}
	return nil
}

but after consideration I think we should invoke prepareNetwork in the main function and not into preparePackage function, since is not a package but a service configuration, @voron @xetys WDYT?

@voron
Copy link
Contributor Author

voron commented Aug 27, 2018

@mavimo @xetys I tried to implement some function separation, but I had to cheat anyway, as prepareAndInstall() already had 4 returns :(
Codeclimate just changed an error anyway. It doesn't like too much returns and doesn't like when I spread returns to functions :)
I'm going to postpone climate for now and test PR instead.

@xetys
Copy link
Owner

xetys commented Aug 28, 2018

report your test results then please

@voron
Copy link
Contributor Author

voron commented Aug 28, 2018

Manual cluster create looks good with 1 master and 1 worker : TX offload disabled on flannel.1, flanneld works via wg0.
But after add-worker / add-external-worker flannel ifaces are missing, I suppose due to wg0 re-creation. We need to add something like kubectl -n kube-system delete pod -l 'app=flannel' after SetupEncryptedNetwork() or maybe inside SetupEncryptedNetwork()

@voron
Copy link
Contributor Author

voron commented Aug 28, 2018

Here is corresponding flannel issue. flannel healthz check doesn't look useful too.

I added to PR and tested "delete flannel pod" work-around, now add-worker/add-external-worker perform as expected. But it's just a work-around.

@voron
Copy link
Contributor Author

voron commented Aug 30, 2018

@mavimo @xetys WDYT
I don't like options like local PostUp wireguard hook similar to pkill flannel. It may be useful for those who needs to re-configure wg0 frequently, but it's out of project scope.

@xetys
Copy link
Owner

xetys commented Oct 17, 2018

Hi,

wanna refresh the state on this PR. Is it ready to be reviewed? Does it work for you as expected?

@voron
Copy link
Contributor Author

voron commented Oct 17, 2018

@xetys

Is it ready to be reviewed?

Yes, the only issue is codeclimate IDK how to avoid.

Does it work for you as expected?

Yes

@itsmepetrov
Copy link

Any updates?

@mavimo
Copy link
Collaborator

mavimo commented Aug 5, 2019

@itsmepetrov we are working to change the way we create internal network to use the Hetzner network feature.

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

Successfully merging this pull request may close these issues.

Routing of Flannel traffic over wireguard
4 participants