Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.

weave-npc to check local addresses only #2979

Merged
merged 6 commits into from
May 19, 2017

Conversation

bboreham
Copy link
Contributor

@bboreham bboreham commented May 18, 2017

This branch is based off the branch for #2978, because I need the rule to contact kube-dns.
Only the last four commits are relevant to this PR.

This PR does two things: it fixes #2622 by only adding IP addresses from pods on the current node; and it then corrects a bug exposed by that change: weave-npc used to filter on the destination address at both ends of a connection.

I suspect this is the cause of #2973.

To address that, I create a new IPset which has all local pod addresses, and if a new connection comes from a local pod but does not target a local pod we let it through. In this way all the real filtering is done at the destination end of the connection.

@bboreham bboreham changed the title Issues/2622 npc local node only weave-npc to check local addresses only May 18, 2017
@@ -86,6 +89,10 @@ func (npc *controller) AddPod(obj *coreapi.Pod) error {
npc.Lock()
defer npc.Unlock()

if npc.nodeName != "" && obj.Spec.NodeName != npc.nodeName {

This comment was marked as abuse.

@@ -92,6 +92,11 @@ spec:
cpu: 10m
securityContext:
privileged: true
env:

This comment was marked as abuse.

This comment was marked as abuse.

@@ -92,6 +92,11 @@ spec:
cpu: 10m
securityContext:
privileged: true
env:
- name: MY_NODE_NAME

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

Copy link
Contributor

@marccarre marccarre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes a lot of sense and LGTM.

@marccarre
Copy link
Contributor

Note that our linter seems to complain about:
prog/weave-npc/main.go: run gofmt -s -w prog/weave-npc/main.go

@bboreham bboreham force-pushed the issues/2622-npc-local-node-only branch 2 times, most recently from af47eba to 152e9a4 Compare May 19, 2017 14:51
@bboreham bboreham force-pushed the issues/2622-npc-local-node-only branch from 152e9a4 to 8a1f8d5 Compare May 19, 2017 15:17
nodeName = os.Getenv("HOSTNAME")
}
if nodeName == "" {
common.Log.Fatalf("Must set node name via --node-name or $HOSTNAME")

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

Copy link
Contributor

@marccarre marccarre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@marccarre marccarre merged commit b44e295 into master May 19, 2017
@marccarre marccarre deleted the issues/2622-npc-local-node-only branch May 19, 2017 15:48
@bboreham bboreham added this to the 2.0 milestone May 30, 2017
@bboreham
Copy link
Contributor Author

Cherry-picked to 1.9 branch at 2d3e070

@bboreham bboreham modified the milestones: 1.9.6, 2.0 May 30, 2017
func root(cmd *cobra.Command, args []string) {
common.SetLogLevel(logLevel)
common.Log.Infof("Starting Weaveworks NPC %s", version)
if nodeName == "" {
// HOSTNAME is set by Kubernetes for pods in the host network namespace

This comment was marked as abuse.

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

Successfully merging this pull request may close these issues.

Filter ipset entries based on node
2 participants