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]: --kubeconfig doesn't work #604

Closed
3 of 4 tasks
jianzhangbjz opened this issue Aug 14, 2023 · 2 comments · Fixed by #605, #571 or #623
Closed
3 of 4 tasks

[Bug]: --kubeconfig doesn't work #604

jianzhangbjz opened this issue Aug 14, 2023 · 2 comments · Fixed by #605, #571 or #623

Comments

@jianzhangbjz
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

k8sgpt: 0.3.7 (1bc0f42), built at: unknown

Kubernetes Version

v1.27.0

Host OS and its Version

No response

Steps to reproduce

  1. In a cluster
  2. export another KUBECONFIG
  3. Run the k8sgpt --kubeconfig=/tmp/kubeconfig-3608642416 analyze -aed

Expected behaviour

It should use the KUBECONFIG when users export it.

Actual behaviour

The cluster we export.

$ oc config get-contexts
CURRENT   NAME    CLUSTER                AUTHINFO   NAMESPACE
*         admin   ci-op-1fym1gz3-564bf   admin  
$ oc whoami
system:admin

But, it still read the InClusterConfig config, not the specific KUBECONFIG

k8sgpt --kubeconfig=/tmp/kubeconfig-3608642416 analyze -aed
AI Provider: openai

Warnings : 
- [MutatingWebhookAnalyzer] mutatingwebhookconfigurations.admissionregistration.k8s.io is forbidden: User "system:serviceaccount:ci-op-1fym1gz3:aws-ipi-ovn-efs-fips-f14" cannot list resource "mutatingwebhookconfigurations" in API group "admissionregistration.k8s.io" at the cluster scope
- [NodeAnalyzer] nodes is forbidden: User "system:serviceaccount:ci-op-1fym1gz3:aws-ipi-ovn-efs-fips-f14" cannot list resource "nodes" in API group "" at the cluster scope
- [StatefulSetAnalyzer] statefulsets.apps is forbidden: User "system:serviceaccount:ci-op-1fym1gz3:aws-ipi-ovn-efs-fips-f14" cannot list resource "statefulsets" in API group "apps" at the cluster scope
- [ValidatingWebhookAnalyzer] validatingwebhookconfigurations.admissionregistration.k8s.io is forbidden: User "system:serviceaccount:ci-op-1fym1gz3:aws-ipi-ovn-efs-fips-f14" cannot list resource "validatingwebhookconfigurations" in API group "admissionregistration.k8s.io" at the cluster scope
- [PodAnalyzer] pods is forbidden: User "system:serviceaccount:ci-op-1fym1gz3:aws-ipi-ovn-efs-fips-f14" cannot list resource "pods" in API group "" at the cluster scope
- [IngressAnalyzer] ingresses.networking.k8s.io is forbidden: User "system:serviceaccount:ci-op-1fym1gz3:aws-ipi-ovn-efs-fips-f14" cannot list resource "ingresses" in API group "networking.k8s.io" at the cluster scope
- [PvcAnalyzer] persistentvolumeclaims is forbidden: User "system:serviceaccount:ci-op-1fym1gz3:aws-ipi-ovn-efs-fips-f14" cannot list resource "persistentvolumeclaims" in API group "" at the cluster scope
- [CronJobAnalyzer] cronjobs.batch is forbidden: User "system:serviceaccount:ci-op-1fym1gz3:aws-ipi-ovn-efs-fips-f14" cannot list resource "cronjobs" in API group "batch" at the cluster scope
- [ServiceAnalyzer] endpoints is forbidden: User "system:serviceaccount:ci-op-1fym1gz3:aws-ipi-ovn-efs-fips-f14" cannot list resource "endpoints" in API group "" at the cluster scope
- [ReplicaSetAnalyzer] replicasets.apps is forbidden: User "system:serviceaccount:ci-op-1fym1gz3:aws-ipi-ovn-efs-fips-f14" cannot list resource "replicasets" in API group "apps" at the cluster scope
- [DeploymentAnalyzer] deployments.apps is forbidden: User "system:serviceaccount:ci-op-1fym1gz3:aws-ipi-ovn-efs-fips-f14" cannot list resource "deployments" in API group "apps" at the cluster scope

No problems detected

Additional Information

No response

jianzhangbjz added a commit to jianzhangbjz/k8sgpt that referenced this issue Aug 15, 2023
If user specify `--kubeconfig` when running k8sgpt, it should use the
kubeconfig file to login the corresponding cluster instead of getting auth info via SA.

Closes k8sgpt-ai#604

Signed-off-by: Jian Zhang <jiazha@redhat.com>
@jianzhangbjz jianzhangbjz changed the title [Question]: --kubeconfig doesn't work when it in a cluster. [Question]: --kubeconfig doesn't work Aug 15, 2023
@jianzhangbjz jianzhangbjz changed the title [Question]: --kubeconfig doesn't work [Bug]: --kubeconfig doesn't work Aug 15, 2023
@jianzhangbjz
Copy link
Contributor Author

/kind bug

AlexsJones pushed a commit that referenced this issue Aug 19, 2023
If user specify `--kubeconfig` when running k8sgpt, it should use the
kubeconfig file to login the corresponding cluster instead of getting auth info via SA.

Closes #604

Signed-off-by: Jian Zhang <jiazha@redhat.com>
@arbreezy
Copy link
Member

@jianzhangbjz , I tried to reproduce.

From my tests when you specify --kubeconfig or/and --context is working fine.

I realized that you want to connect from within a cluster to an external one and yes this is not doable atm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
2 participants