diff --git a/README.md b/README.md index a35a3bf8dd..db20194a4e 100644 --- a/README.md +++ b/README.md @@ -233,6 +233,32 @@ _Anonymize during explain_ k8sgpt analyze --explain --filter=Service --output=json --anonymize ``` +With this option, the data is anonymized before being sent to the AI Backend. During the analysis execution, `k8sgpt` retrieves sensitive data (Kubernetes object names, labels, etc.). This data is masked when sent to the AI backend and replaced by a key that can be used to de-anonymize the data when the solution is returned to the user. + +For example: + +1. Error reported during analysis: +```bash +Error: HorizontalPodAutoscaler uses StatefulSet/fake-deployment as ScaleTargetRef which does not exist. +``` + +2. Payload sent to the AI backend: +```bash +Error: HorizontalPodAutoscaler uses StatefulSet/tGLcCRcHa1Ce5Rs as ScaleTargetRef which does not exist. +``` + +3. Payload returned by the AI: +```bash +The Kubernetes system is trying to scale a StatefulSet named tGLcCRcHa1Ce5Rs using the HorizontalPodAutoscaler, but it cannot find the StatefulSet. The solution is to verify that the StatefulSet name is spelled correctly and exists in the same namespace as the HorizontalPodAutoscaler. +``` + +4. Payload returned to the user: +```bash +The Kubernetes system is trying to scale a StatefulSet named fake-deployment using the HorizontalPodAutoscaler, but it cannot find the StatefulSet. The solution is to verify that the StatefulSet name is spelled correctly and exists in the same namespace as the HorizontalPodAutoscaler. +``` + +**Anonymization does not currently apply to events.** + ## Upcoming major milestones - [ ] Multiple AI backend support diff --git a/pkg/analyzer/hpa.go b/pkg/analyzer/hpa.go index 2d0387cfdf..d8b7b2e7e9 100644 --- a/pkg/analyzer/hpa.go +++ b/pkg/analyzer/hpa.go @@ -48,7 +48,7 @@ func (HpaAnalyzer) Analyze(a Analyzer) ([]Result, error) { } default: failures = append(failures, Failure{ - Text: fmt.Sprintf("HorizontalPodAutoscaler uses %s as ScaleTargetRef which does not possible option.", scaleTargetRef.Kind), + Text: fmt.Sprintf("HorizontalPodAutoscaler uses %s as ScaleTargetRef which is not an option.", scaleTargetRef.Kind), Sensitive: []Sensitive{}, }) } @@ -57,7 +57,7 @@ func (HpaAnalyzer) Analyze(a Analyzer) ([]Result, error) { failures = append(failures, Failure{ Text: fmt.Sprintf("HorizontalPodAutoscaler uses %s/%s as ScaleTargetRef which does not exist.", scaleTargetRef.Kind, scaleTargetRef.Name), Sensitive: []Sensitive{ - Sensitive{ + { Unmasked: scaleTargetRef.Name, Masked: util.MaskString(scaleTargetRef.Name), }, diff --git a/pkg/analyzer/hpaAnalyzer_test.go b/pkg/analyzer/hpaAnalyzer_test.go index 883a2a4a50..612fba2437 100644 --- a/pkg/analyzer/hpaAnalyzer_test.go +++ b/pkg/analyzer/hpaAnalyzer_test.go @@ -101,7 +101,7 @@ func TestHPAAnalyzerWithUnsuportedScaleTargetRef(t *testing.T) { var errorFound bool for _, analysis := range analysisResults { for _, err := range analysis.Error { - if strings.Contains(err.Text, "does not possible option.") { + if strings.Contains(err.Text, "which is not an option.") { errorFound = true break }