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] In kubernetes access to logs not work with pod with ID not found error #581

Open
lenglet-k opened this issue Jul 28, 2023 · 3 comments
Assignees
Labels
bug Something isn't working kubernetes Kubernetes integration ui Web UI

Comments

@lenglet-k
Copy link

Description
On bunkerweb-ui when i try to see the logs i have this error:

{
  "message": "Pod with ID bunkerweb-wgcq6 not found!",
  "status": "ko"
}

The pod with bunkerweb-wgcq6 name exist

How to reproduce
Start a kubernetes bunkerweb stack
Show logs from the logs menu

Logs

HTTP CALL, 404 response:

GET https://my-fqdn.tld/logs/bunkerweb-wgcq6?from_date=1690495200000&to_date=1690495200000

and the response:

{
  "message": "Pod with ID bunkerweb-wgcq6 not found!",
  "status": "ko"
}
@lenglet-k lenglet-k added the bug Something isn't working label Jul 28, 2023
@fl0ppy-d1sk fl0ppy-d1sk added kubernetes Kubernetes integration ui Web UI labels Aug 1, 2023
@fl0ppy-d1sk fl0ppy-d1sk added this to 1.5.2 in 1.5.X Aug 1, 2023
@fl0ppy-d1sk fl0ppy-d1sk moved this from 1.5.2 to 1.5.3 in 1.5.X Sep 10, 2023
@fl0ppy-d1sk fl0ppy-d1sk removed this from 1.5.3 in 1.5.X Oct 16, 2023
@TheophileDiot
Copy link
Member

Hi @lenglet-k, I'm digging up this issue to let you know that this is fixed on our end. Can you confirm ? Thank you !

@lenglet-k
Copy link
Author

Hi, i have the same behavior in 1.5.7.

@lenglet-k
Copy link
Author

lenglet-k commented Jul 23, 2024

@TheophileDiot I have test with 1.5.9.

The first problem is rbac:

We need to add pods/log ressource in bunkerweb clusterrole:

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  labels:
    app.kubernetes.io/instance: bunkerweb
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: bunkerweb
    helm.sh/chart: bunkerweb-0-master
  name: bunkerweb
rules:
- apiGroups:
  - ""
  resources:
  - services
  - pods
  - pods/log
  - configmaps
  - secrets
  verbs:
  - get
  - watch
  - list
- apiGroups:
  - networking.k8s.io
  resources:
  - ingresses
  verbs:
  - get
  - watch
  - list

After i have this error:

[2024-07-23 07:45:26 +0000] [UI] [11] [❌] - Could not get logs for pod bunkerweb-v5krt
Traceback (most recent call last):
  File "/usr/share/bunkerweb/ui/main.py", line 2058, in logs_container
    kubernetes_logs = kubernetes_client.read_namespaced_pod_log(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/bunkerweb/deps/python/kubernetes/client/api/core_v1_api.py", line 23957, in read_namespaced_pod_log
    return self.read_namespaced_pod_log_with_http_info(name, namespace, **kwargs)  # noqa: E501
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/bunkerweb/deps/python/kubernetes/client/api/core_v1_api.py", line 24076, in read_namespaced_pod_log_with_http_info
    return self.api_client.call_api(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/bunkerweb/deps/python/kubernetes/client/api_client.py", line 348, in call_api
    return self.__call_api(resource_path, method,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/bunkerweb/deps/python/kubernetes/client/api_client.py", line 180, in __call_api
    response_data = self.request(
                    ^^^^^^^^^^^^^
  File "/usr/share/bunkerweb/deps/python/kubernetes/client/api_client.py", line 373, in request
    return self.rest_client.GET(url,
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/bunkerweb/deps/python/kubernetes/client/rest.py", line 244, in GET
    return self.request("GET", url,
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/bunkerweb/deps/python/kubernetes/client/rest.py", line 238, in request
    raise ApiException(http_resp=r)
kubernetes.client.exceptions.ApiException: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({'Audit-Id': '74c628e8-21f8-46fe-a76c-a3b418aed614', 'Cache-Control': 'no-cache, private', 'Content-Type': 'application/json', 'Date': 'Tue, 23 Jul 2024 07:45:26 GMT', 'Content-Length': '198'})
HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"pods \"bunkerweb-v5krt\" not found","reason":"NotFound","details":{"name":"bunkerweb-v5krt","kind":"pods"},"code":404}

Ok i have found, this error is due to this code: https://github.com/bunkerity/bunkerweb/blob/v1.5.9/src/ui/main.py#L2058 i had not the KUBERNETES_NAMESPACE environment variable.
I have added like that, in bunkerweb-ui deployment:

        - name: KUBERNETES_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace

Theses update in clusterrole and bunkerwebui deployment need update of helm charts. I have done here: #1340

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

No branches or pull requests

3 participants