Skip to content

Commit

Permalink
all kinds by default
Browse files Browse the repository at this point in the history
  • Loading branch information
jreisinger committed May 17, 2022
1 parent a6b06fd commit 0f16c10
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ used as CLI tool or as daemon (service) exposing Prometheus metrics.

## CLI tool

Count several kinds of objects in all namespaces using cluster configuration
from `KUBECONFIG` environment variable or `$HOME/.kube/config`:
Count all (supported) kinds of objects in all namespaces using cluster
configuration from `KUBECONFIG` environment variable or `$HOME/.kube/config`:

```
$ kcount -k deployment,pod,configmap,secret,ingress -A
$ kcount -A
Cluster Namespace Label selector Kind Count
------- --------- -------------- ---- -----
cluster1.example.com configmap 2736
cluster1.example.com pod 499
cluster1.example.com secret 358
cluster1.example.com deployment 78
cluster1.example.com ingress 40
cluster1.example.com service 20
-----
3711
```
Expand Down
11 changes: 9 additions & 2 deletions flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,21 @@ func parseFlags() Flags {
flag.BoolVar(&f.allNamespaces, "A", false, "count objects across all namespaces")
flag.BoolVar(&f.age, "a", false, "show also age of newest and oldest object")
flag.BoolVar(&f.daemon, "d", false, "run as daemon exposing prometheus metrics")
flag.Var(&f.kind, "k", "object kind or kinds (default pod)")
flag.Var(&f.kind, "k", "object kind or kinds (default is all supported)")
flag.StringVar(&f.labelSelector, "l", "", "label selector (e.g. env=prod)")
flag.StringVar(&f.namespace, "n", "", "namespace")

flag.Parse()

if len(f.kind) == 0 { // set default value
f.kind = append(f.kind, "pod")
f.kind = []string{
"deployment",
"pod",
"configmap",
"secret",
"ingress",
"service",
}
}

return f
Expand Down

0 comments on commit 0f16c10

Please sign in to comment.