doc: add troubleshoot md for kubernetes

Signed-off-by: gazandi <gazandi@ruangguru.com>
This commit is contained in:
Gazandi
2021-03-01 23:17:20 +07:00
committed by gazandi
parent e8a794b5d0
commit c8b37f93bd
@@ -0,0 +1,92 @@
---
id: troubleshooting-k8s
title: Troubleshooting Kubernetes
sidebar_label: Troubleshooting
description: Troubleshooting for Kubernetes
---
## Kubernetes is not showing up on Service Entities
How to test your k8s cluster are already connected to backstage
```curl
# curl request
curl --location --request POST '{{backstage-backend-url}}:{{backstage-backend-port}}/api/kubernetes/services/:service-entity-name' \
--header 'Content-Type: application/json' \
--data-raw '{
"entity": {
"metadata": {
"name": <service-entity-name>
}
}
}
'
```
The curl response should have resources from kubernetes
```json
# curl response
{
"items": [
{
"cluster": {
"name": <cluster-name>
},
"resources": [
{
"type": "services",
"resources": [
{
"metadata": {
"creationTimestamp": "2022-03-13T13:52:46.000Z",
"labels": {
"app": <service-entity-name>,
"backstage": <selector>,
"backstage.io/kubernetes-id": <service-entity-name>
},
"name": <service-entity-name>,
"namespace": <namespace>
},
....
}
]
},
....
{
"type": "pods",
"resources": [
,,,,
]
}
],
"errors": []
}
]
}
```
Kubernetes will not be showing anything if annotations not match with annotations
on k8s service.yaml / deployment.yaml / k8s related yaml. We recommend you for
using label selector with adding two labels:
`backstage: <selector>` and `backstage.io/kubernetes-id: <entity-service-name>`.
```yaml
# k8s related yaml (service.yaml, deployment.yaml, ingress.yaml)
metadata: {
creationTimestamp: "2022-03-13T13:52:46.000Z",
labels: {
"app": <entity-service-name>,
"backstage": <selector>,
"backstage.io/kubernetes-id": <entity-service-name>
},
"name": <service-entity-name>,
"namespace": <namespace>
}
```
and the catalog info annotations would use label selector:
```yaml
# catalog-info.yaml (backstage)
annotations:
backstage.io/kubernetes-label-selector: 'backstage=<selectors'
```