Skip to content

Commit

Permalink
feat: Add exclusive mode
Browse files Browse the repository at this point in the history
  • Loading branch information
NoUseFreak committed Mar 18, 2024
1 parent 2544522 commit 4127e59
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ __Service__
`k8status.stenic.io/exclude`
(bool) Exclude from the report.

`k8status.stenic.io/include`
(bool) Include in the report. Only used if `--mode=exclusive` is set.

`k8status.stenic.io/description`
(string) Add additional description to the service.

Expand Down
1 change: 1 addition & 0 deletions charts/k8status/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ spec:
{{ if .Values.k8status.allNamspaces }}"--namespace", "{{ .Release.Namespace }}",{{ end }}
"--prefix", "{{ .Values.k8status.prefix }}",
"--interval", "{{ .Values.k8status.interval }}",
"--mode", "{{ .Values.k8status.mode }}",
]
ports:
- name: http
Expand Down
2 changes: 2 additions & 0 deletions charts/k8status/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ k8status:
prefix: /
# k8status.interval -- Poll interval for readiness checks
interval: 10
# k8status.mode -- Inclusive or exclusive mode
mode: "inclusive"

# imagePullSecrets -- Docker registry secret names as an array
imagePullSecrets: []
Expand Down
7 changes: 7 additions & 0 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var prefix string
var svcReps []SvcRep
var interval int
var showDegraded bool
var mode string

var nsNameCache = map[string]string{}
var (
Expand All @@ -59,6 +60,7 @@ func init() {
}
flag.StringVar(&namespace, "namespace", "", "namespace")
flag.StringVar(&prefix, "prefix", "/", "path prefix")
flag.StringVar(&mode, "mode", "inclusive", "mode: inclusive or exclusive")
flag.IntVar(&interval, "interval", 5, "readiness poll interval")
flag.BoolVar(&showDegraded, "show-degraded", false, "indicate degraded service")
}
Expand Down Expand Up @@ -181,6 +183,11 @@ func loadServiceInfo(clientset *kubernetes.Clientset, ns string) []SvcRep {
if val, ok := svc.Annotations["k8status.stenic.io/exclude"]; ok && val == "true" {
continue
}
if mode == "exclusive" {
if val, ok := svc.Annotations["k8status.stenic.io/include"]; ok && val != "true" {
continue
}
}
pods, err := clientset.CoreV1().Pods(svc.Namespace).List(ctx, v1.ListOptions{
LabelSelector: labels.SelectorFromSet(svc.Spec.Selector).String(),
})
Expand Down

0 comments on commit 4127e59

Please sign in to comment.