Skip to content

Commit

Permalink
Blacklist kube-system
Browse files Browse the repository at this point in the history
  • Loading branch information
howardjohn committed Jun 27, 2019
1 parent 47ecad1 commit 46a684c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
15 changes: 15 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
type Args struct {
Namespace string
KubeConfig string
NamespaceBlacklist []string
}

func Run(args *Args) error {
Expand All @@ -36,12 +37,26 @@ func Run(args *Args) error {
return fmt.Errorf("failed to merge responses: %v", err)
}

filterBlacklist(resources, args.NamespaceBlacklist)

if err := Write(resources, args); err != nil {
return fmt.Errorf("faild to write: %v", err)
}
return nil
}

func filterBlacklist(resources map[string]*PodResource, blacklist []string) {
blMap := make(map[string]struct{})
for _, ns := range blacklist {
blMap[ns] = struct{}{}
}
for k, v := range resources {
if _, f := blMap[v.Namespace]; f {
delete(resources, k)
}
}
}

func FetchMetrics(cfg *rest.Config, ns string) (map[string]*PodResource, error) {
metricsclient, err := metrics.NewForConfig(cfg)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import (

var (
args = &client.Args{
Namespace: "",
KubeConfig: path.Join(os.Getenv("HOME"), ".kube", "config"),
Namespace: "",
KubeConfig: path.Join(os.Getenv("HOME"), ".kube", "config"),
NamespaceBlacklist: []string{"kube-system"},
}
)

Expand Down

0 comments on commit 46a684c

Please sign in to comment.