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

cmd/observe: Add node name filter #412

Merged
merged 2 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/observe/observe.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ more.`,
"to-identity", ofilter,
"Show all flows terminating at an endpoint with the given security identity"))

observerCmd.Flags().Var(filterVar(
"node-name", ofilter,
`Show all flows which match the given node names (e.g. "k8s*", "test-cluster/*.company.com")`))

observerCmd.Flags().BoolVarP(
&jsonOutput, "json", "j", false, "Deprecated. Use '--output json' instead.",
)
Expand Down
7 changes: 7 additions & 0 deletions cmd/observe/observe_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func newObserveFilter() *observeFilter {
{"port", "from-port"},
{"identity", "to-identity"},
{"identity", "from-identity"},
{"node-name"},
},
}
}
Expand Down Expand Up @@ -431,6 +432,12 @@ func (of *observeFilter) set(f *filterTracker, name, val string, track bool) err
f.apply(func(f *pb.FlowFilter) {
f.DestinationIdentity = append(f.DestinationIdentity, identity)
})

// node name filters
case "node-name":
f.apply(func(f *pb.FlowFilter) {
f.NodeName = append(f.NodeName, val)
})
}

return nil
Expand Down
3 changes: 3 additions & 0 deletions cmd/observe/observe_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func TestFilterLeftRight(t *testing.T) {
"--not", "--http-status", "200",
"--http-method", "get",
"--http-path", "/page/\\d+",
"--node-name", "k8s*",
}))

require.NoError(t, handleArgs(f, false))
Expand All @@ -140,12 +141,14 @@ func TestFilterLeftRight(t *testing.T) {
Verdict: []pb.Verdict{pb.Verdict_DROPPED},
HttpMethod: []string{"get"},
HttpPath: []string{"/page/\\d+"},
NodeName: []string{"k8s*"},
},
{
DestinationIp: []string{"1.2.3.4", "5.6.7.8"},
Verdict: []pb.Verdict{pb.Verdict_DROPPED},
HttpMethod: []string{"get"},
HttpPath: []string{"/page/\\d+"},
NodeName: []string{"k8s*"},
},
},
f.whitelist.flowFilters(),
Expand Down
1 change: 1 addition & 0 deletions cmd/observe/observe_usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func modifyTemplate(orig string, cmd *cobra.Command) string {
"port", "to-port", "from-port",
"type", "verdict", "http-status", "http-method", "http-path", "protocol",
"identity", "to-identity", "from-identity",
"node-name",
},
},
}
Expand Down
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/cilium/hubble
go 1.14

require (
github.com/cilium/cilium v1.9.0-rc1.0.20201019085243-289e99943fb6
github.com/cilium/cilium v1.9.0-rc1.0.20201120102040-c0b68419e6d8
github.com/golang/protobuf v1.4.3
github.com/google/go-cmp v0.5.2
github.com/gordonklaus/ineffassign v0.0.0-20200809085317-e36bfde3bb78
Expand All @@ -18,13 +18,12 @@ require (
honnef.co/go/tools v0.0.1-2020.1.6
)

replace gopkg.in/yaml.v2 => gopkg.in/yaml.v2 v2.2.8 // To avoid https://github.com/go-yaml/yaml/pull/571.

// Replace directives from github.com/cilium/cilium. Keep in sync when updating Cilium!
replace (
github.com/miekg/dns => github.com/cilium/dns v1.1.4-0.20190417235132-8e25ec9a0ff3
github.com/optiopay/kafka => github.com/cilium/kafka v0.0.0-20180809090225-01ce283b732b
k8s.io/client-go => github.com/cilium/client-go v0.0.0-20200917084247-85ed8d558b9c
gopkg.in/yaml.v2 => gopkg.in/yaml.v2 v2.2.8 // To avoid https://github.com/go-yaml/yaml/pull/571.
k8s.io/client-go => github.com/cilium/client-go v0.0.0-20201116093811-e3ac748c004a
sigs.k8s.io/controller-tools => github.com/christarazi/controller-tools v0.3.1-0.20200911184030-7e668c1fb4c2
sigs.k8s.io/structured-merge-diff/v4 => github.com/christarazi/structured-merge-diff/v4 v4.0.2-0.20200917183246-1cc601931628
)
28 changes: 14 additions & 14 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 22 additions & 7 deletions vendor/github.com/cilium/cilium/AUTHORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading