k8sgpt-operator
k8sgpt-operator copied to clipboard
[BUG]: "namespace not found" when trivy integration is active
Checklist
- [X] I've searched for similar issues and couldn't find anything matching
- [X] I've included steps to reproduce the behavior
Affected Components
- [X] K8sGPT (CLI)
- [X] K8sGPT Operator
K8sGPT Version
v0.0.27
Kubernetes Version
No response
Host OS and its Version
No response
Steps to reproduce
- install trivy-operator without helm (e.g. argocd)
- install k8sgpt-operator with the following stanza in K8sGPT cr:
integrations:
trivy:
enabled: true
namespace: suxess-it-trivy
skipInstall: true
- in the k8sgpt deployment you will see logs like this
{"level":"info","ts":1704729522.83985,"caller":"server/log.go:50","msg":"request failed. rpc error: code = NotFound desc = namespace not found","duration_ms":82,"method":"/schema.v1.ServerService/ListIntegrations","request":"","remote_addr":"10.130.2.33:36380","status_code":5}
Expected behaviour
k8sgpt should just work, enable trivy integration and recognize that trivy is installed in the configured namespace
Actual behaviour
k8sgpt checks in https://github.com/k8sgpt-ai/k8sgpt/blob/5c17c240550609d9fb7771fe67fe1ab19660b4da/pkg/integration/trivy/trivy.go#L70C26-L80 if trivy is installed via helm, which is not true when trivy is deployed via argocd
Additional Information
No response
I would like to work on it .
@aryasoni98 great! If you need some additional information, feel free to ask
I had the same issue.
have you got install k8sgpt operator with trivy?
Any plans to fix this ? I am also getting the same error while using the operator way of deployment. Trivy integration works for the first time, but when PreAnalysis step is called next time, it fails with following error:
{"level":"info","ts":1728376981.8452039,"caller":"server/log.go:50","msg":"request failed. rpc error: code = NotFound desc = namespace not found","duration_ms":17,"method":"/schema.v1.ServerConfigService/ListIntegrations","request":"","remote_addr":"100.100.193.215:56946","status_code":5}
Looks like the following part of code has some issue (it has the comment as well that it does not work):
_pkg/integration/trivy/trivy.go_
// This doesnt work
func (t *Trivy) GetNamespace() (string, error) {
releases, err := t.helm.ListDeployedReleases()
if err != nil {
return "", err
}
for _, rel := range releases {
if rel.Name == ReleaseName {
return rel.Namespace, nil
}
}
return "", status.Error(codes.NotFound, "trivy release not found")
}
Steps that I followed for trivy integration:
Installed trivy manually under trivy-system namespace and have set skipInstall to true in K8sGPT.