Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: "namespace not found" when trivy integration is active #311

Open
4 tasks done
jkleinlercher opened this issue Jan 8, 2024 · 5 comments
Open
4 tasks done
Assignees
Labels
bug Something isn't working

Comments

@jkleinlercher
Copy link
Contributor

Checklist

  • I've searched for similar issues and couldn't find anything matching
  • I've included steps to reproduce the behavior

Affected Components

  • K8sGPT (CLI)
  • K8sGPT Operator

K8sGPT Version

v0.0.27

Kubernetes Version

No response

Host OS and its Version

No response

Steps to reproduce

  1. install trivy-operator without helm (e.g. argocd)
  2. install k8sgpt-operator with the following stanza in K8sGPT cr:
  integrations:
    trivy:
      enabled: true
      namespace: suxess-it-trivy
      skipInstall: true
  1. 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

@aryasoni98
Copy link

I would like to work on it .

@arbreezy arbreezy added the bug Something isn't working label Jan 16, 2024
@jkleinlercher
Copy link
Contributor Author

@aryasoni98 great! If you need some additional information, feel free to ask

@intonet
Copy link

intonet commented Mar 27, 2024

I had the same issue.

@dirac34
Copy link

dirac34 commented Aug 30, 2024

have you got install k8sgpt operator with trivy?

@Hemant-Sadana
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants