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

IndexError: list index out of range while running krs health for GKE workload #10

Open
ajeetraina opened this issue Jun 13, 2024 · 2 comments

Comments

@ajeetraina
Copy link
Contributor

ajeetraina commented Jun 13, 2024

I installed Nginx Pod on GKE workload by following this guide.

krs init
Services initialized and scanner loaded.

I was able to scan the GKE cluster successfully.

krs scan

Scanning your cluster...

Cluster scanned successfully...

Extracted tools used in cluster...


The cluster is using the following tools:

+-------------+--------+-----------------------------+---------------+
| Tool Name   |   Rank | Category                    | CNCF Status   |
+=============+========+=============================+===============+
| autoscaler  |      5 | Cluster with Core CLI tools | unlisted      |
+-------------+--------+-----------------------------+---------------+
| fluentbit   |      4 | Logging and Tracing         | unlisted      |
+-------------+--------+-----------------------------+---------------+
 krs recommend

Our recommended tools for this deployment are:

+-----------------------------+------------------+-------------+---------------+
| Category                    | Recommendation   | Tool Name   | CNCF Status   |
+=============================+==================+=============+===============+
| Cluster with Core CLI tools | Recommended tool | k9s         | unlisted      |
+-----------------------------+------------------+-------------+---------------+
| Logging and Tracing         | Recommended tool | elk         | unlisted      |
+-----------------------------+------------------+-------------+---------------+
git clone https://github.com/benc-uk/kubeview
Cloning into 'kubeview'...
remote: Enumerating objects: 1386, done.
remote: Counting objects: 100% (397/397), done.
remote: Compressing objects: 100% (112/112), done.
remote: Total 1386 (delta 337), reused 285 (delta 285), pack-reused 989
Receiving objects: 100% (1386/1386), 5.14 MiB | 10.14 MiB/s, done.
Resolving deltas: 100% (775/775), done.
cd kubeview/charts/
helm install kubeview kubeview
NAME: kubeview
LAST DEPLOYED: Thu Jun 13 15:01:08 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
=====================================
==== KubeView has been deployed! ====
=====================================
  To get the external IP of your application, run the following:

  export SERVICE_IP=$(kubectl get svc --namespace default kubeview -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
  echo http://$SERVICE_IP

  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        You can watch the status of by running 'kubectl get --namespace default svc -w kubeview'
 krs scan


Scanning your cluster...

Cluster scanned successfully...

Extracted tools used in cluster...


The cluster is using the following tools:

+-------------+--------+-----------------------------+---------------+
| Tool Name   |   Rank | Category                    | CNCF Status   |
+=============+========+=============================+===============+
| kubeview    |     30 | Cluster with Core CLI tools | unlisted      |
+-------------+--------+-----------------------------+---------------+
|             |      3 | Cluster Management          | unlisted      |
+-------------+--------+-----------------------------+---------------+
| autoscaler  |      5 | Cluster with Core CLI tools | unlisted      |
+-------------+--------+-----------------------------+---------------+
| fluentbit   |      4 | Logging and Tracing         | unlisted      |
+-------------+--------+-----------------------------+---------------+
wget https://github.com/sozercan/kubectl-ai/releases/download/v0.0.10/kubectl-ai_linux_amd64.tar.gz

--2024-06-13 15:03:31--  https://github.com/sozercan/kubectl-ai/releases/download/v0.0.10/kubectl-ai_linux_amd64.tar.gz
Resolving github.com (github.com)... 20.207.73.82
Connecting to github.com (github.com)|20.207.73.82|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/615891862/b0d8d775-54a8-409b-bc85-0909814266ad?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20240613%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240613T093331Z&X-Amz-Expires=300&X-Amz-Signature=96aa314950f3223f55232d174d850398f5f1f35fb686c62acaed4e1f0e3444c7&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=615891862&response-content-disposition=attachment%3B%20filename%3Dkubectl-ai_linux_amd64.tar.gz&response-content-type=application%2Foctet-stream [following]
--2024-06-13 15:03:32--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/615891862/b0d8d775-54a8-409b-bc85-0909814266ad?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20240613%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240613T093331Z&X-Amz-Expires=300&X-Amz-Signature=96aa314950f3223f55232d174d850398f5f1f35fb686c62acaed4e1f0e3444c7&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=615891862&response-content-disposition=attachment%3B%20filename%3Dkubectl-ai_linux_amd64.tar.gz&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11986631 (11M) [application/octet-stream]
Saving to: ‘kubectl-ai_linux_amd64.tar.gz’

kubectl-ai_linux_amd64.tar.gz            100%[===============================================================================>]  11.43M  16.5MB/s    in 0.7s

2024-06-13 15:03:37 (16.5 MB/s) - ‘kubectl-ai_linux_amd64.tar.gz’ saved [11986631/11986631]
kubectl ai "Create a namespace called ns1 and deploy a Nginx Pod"
✨ Attempting to apply the following manifest:
apiVersion: v1
kind: Namespace
metadata:
  name: ns1

---

apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
  namespace: ns1
spec:
  containers:
  - name: nginx-container
    image: nginx:latest
    ports:
    - containerPort: 80
✔ Apply
 kubectl get po -n ns1
NAME        READY   STATUS    RESTARTS   AGE
nginx-pod   1/1     Running   0          45s
krs health

Starting interactive terminal...


Do you want to continue fixing the previously selected pod ? (y/n): >> n

Loading LLM State..

Model:  gpt-3.5-turbo

Namespaces in the cluster:

1. default
2. gke-managed-system
3. gmp-public
4. gmp-system
5. kube-node-lease
6. kube-public
7. kube-system
8. ns1

Which namespace do you want to check the health for? Select a namespace by entering its number: >> 8

Pods in the namespace ns1:

1. nginx-pod

Which pod from ns1 do you want to check the health for? Select a pod by entering its number: >> 1

Checking status of the pod...

Extracting logs and events from the pod...
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /opt/homebrew/lib/python3.11/site-packages/krs/krs.py:80 in health                               │
│                                                                                                  │
│    77 │   """                                                                                    │
│    78 │   check_initialized()                                                                    │
│    79 │   typer.echo("\nStarting interactive terminal...\n")                                     │
│ ❱  80 │   krs.health_check(change_model)                                                         │
│    81                                                                                            │
│    82 @app.command()                                                                             │
│    83 def export():                                                                              │
│                                                                                                  │
│ ╭─────── locals ───────╮                                                                         │
│ │ change_model = False │                                                                         │
│ ╰──────────────────────╯                                                                         │
│                                                                                                  │
│ /opt/homebrew/lib/python3.11/site-packages/krs/main.py:231 in health_check                       │
│                                                                                                  │
│   228 │   │   │                                                                                  │
│   229 │   │   │   print("\nExtracting logs and events from the pod...")                          │
│   230 │   │   │                                                                                  │
│ ❱ 231 │   │   │   logs_from_pod = self.get_logs_from_pod(self.selected_namespace_index, self.s   │
│   232 │   │   │                                                                                  │
│   233 │   │   │   self.logs_extracted = extract_log_entries(logs_from_pod)                       │
│   234                                                                                            │
│                                                                                                  │
│ ╭────────────────────────────────────── locals ──────────────────────────────────────╮           │
│ │           change_model = False                                                     │           │
│ │ continue_previous_chat = 'n'                                                       │           │
│ │                      i = 1                                                         │           │
│ │           krsllmclient = <krs.utils.llm_client.KrsGPTClient object at 0x1060cff50> │           │
│ │              namespace = 'ns1'                                                     │           │
│ │          namespace_len = 8                                                         │           │
│ │             namespaces = [                                                         │           │
│ │                          │   'default',                                            │           │
│ │                          │   'gke-managed-system',                                 │           │
│ │                          │   'gmp-public',                                         │           │
│ │                          │   'gmp-system',                                         │           │
│ │                          │   'kube-node-lease',                                    │           │
│ │                          │   'kube-public',                                        │           │
│ │                          │   'kube-system',                                        │           │
│ │                          │   'ns1'                                                 │           │
│ │                          ]                                                         │           │
│ │                    pod = 'nginx-pod'                                               │           │
│ │                pod_len = 1                                                         │           │
│ │               pod_list = ['nginx-pod']                                             │           │
│ │                   self = <krs.main.KrsMain object at 0x102f05a10>                  │           │
│ ╰────────────────────────────────────────────────────────────────────────────────────╯           │
│                                                                                                  │
│ /opt/homebrew/lib/python3.11/site-packages/krs/main.py:247 in get_logs_from_pod                  │
│                                                                                                  │
│   244 │   │   try:                                                                               │
│   245 │   │   │   namespace_index -= 1                                                           │
│   246 │   │   │   pod_index -= 1                                                                 │
│ ❱ 247 │   │   │   namespace = list(self.pod_info.keys())[namespace_index]                        │
│   248 │   │   │   return list(self.pod_info[namespace][pod_index]['info']['Logs'].values())[0]   │
│   249 │   │   except KeyError as e:                                                              │
│   250 │   │   │   print("\nKindly enter a value from the available namespaces and pods")         │
│                                                                                                  │
│ ╭────────────────────────── locals ──────────────────────────╮                                   │
│ │ namespace_index = 7                                        │                                   │
│ │       pod_index = 0                                        │                                   │
│ │            self = <krs.main.KrsMain object at 0x102f05a10> │                                   │
│ ╰────────────────────────────────────────────────────────────╯                                   │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
IndexError: list index out of range

@ajeetraina
Copy link
Contributor Author

@karanveersingh5623 I noticed that fluentd is listed in CNCF but there it is not listed.

@abhimazu
Copy link
Contributor

@ajeetraina Check the cncf json that is created, if there is a name mismatch, it will show unlisted. As I am pulling from CNCF directly, I cannot edit the names in between, as they would be considered synthetic then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants