Skip to content

Commit fd9a8aa

Browse files
authored
fix(kiali): add corner cases, fix some issues and improve dev env (#1202)
* fix(kiali): add corner cases, fix some issues and improve dev env * Fix error loading and docs * remove console
1 parent c6e2663 commit fd9a8aa

17 files changed

+252
-82
lines changed

plugins/kiali/README.md

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The Kiali plugin has the following capabilities:
1212
- Health by namespace
1313
- Canary info
1414
- Istio Config warnings
15+
- Worklist
1516

1617
## For administrators
1718

@@ -21,58 +22,22 @@ The Kiali plugin has the following capabilities:
2122

2223
- The following annotation is added to the entity's `catalog-info.yaml` file to identify whether an entity contains the Kubernetes resources:
2324

24-
```yaml
25-
annotations:
26-
...
27-
28-
backstage.io/kubernetes-id: <BACKSTAGE_ENTITY_NAME>
29-
```
30-
31-
You can also add the `backstage.io/kubernetes-namespace` annotation to identify the Kubernetes resources using the defined namespace.
32-
3325
```yaml
3426
annotations:
3527
...
3628

3729
backstage.io/kubernetes-namespace: <RESOURCE_NS>
3830
```
3931
40-
- The following annotation is added to the `catalog-info.yaml` file of entity to view the latest `PipelineRun` in the CI/CD tab of the application:
41-
42-
```yaml
43-
annotations:
44-
...
45-
46-
janus-idp.io/kiali-enabled : 'true'
47-
```
48-
49-
- A custom label selector can be added, which Backstage uses to find the Kubernetes resources. The label selector takes precedence over the ID annotations.
32+
For now we support kubernetes-namespace due Kiali works in namespace level. We expect to support `kubernetes-label-selector` and `kubernetes-id`
5033

51-
```yaml
52-
annotations:
53-
...
54-
55-
backstage.io/kubernetes-label-selector: 'app=my-app,component=front-end'
56-
```
57-
58-
- The following label is added to the resources so that the Kubernetes plugin gets the Kubernetes resources from the requested entity:
34+
- The following annotation is added to the `catalog-info.yaml` file of entity to view the latest `PipelineRun` in the CI/CD tab of the application:
5935

6036
```yaml
61-
labels:
62-
...
63-
64-
backstage.io/kubernetes-id: <BACKSTAGE_ENTITY_NAME>`
37+
janus-idp.io/kiali-enabled: 'true'
6538
```
6639

67-
***
68-
69-
**NOTE**
70-
71-
When using the label selector, the mentioned labels must be present on the resource.
72-
73-
***
74-
75-
#### Setting up the OCM frontend package
40+
#### Setting up the Kiali frontend package
7641

7742
1. Install the Kiali plugin using the following commands:
7843

@@ -166,8 +131,8 @@ Authentication methods:
166131
The following table describes the parameters that you can configure to enable the plugin under `catalog.providers.keycloakOrg.<ENVIRONMENT_NAME>` object in the `app-config.yaml` file:
167132

168133
| Name | Description | Default Value | Required |
169-
| --------------------- | -------------------------------------------------------------------------------------------------------------------- | ------------- | --------------------------------------- | --- |
170-
| `url` | Location of the kIALI server, such as `https://localhost:4000` | "" | Yes | |
134+
| --------------------- | -------------------------------------------------------------------------------------------------------------------- | ------------- | --------------------------------------- |
135+
| `url` | Location of the Kiali server, such as `https://localhost:4000` | "" | Yes |
171136
| `serviceAccountToken` | Service Account Token which is used for querying data from Kiali | "" | Yes if using token based authentication |
172137
| `skipTLSVerify` | Skip TLS certificate verification presented by the API server | false | No |
173138
| `caData` | Base64-encoded certificate authority bundle in PEM format | "" | No |
@@ -178,20 +143,24 @@ The following table describes the parameters that you can configure to enable th
178143

179144
1. Open your Backstage application and select a component from the **Catalog** page.
180145

181-
![catalog-list](./images/catalog-list.png)
146+
![catalog-list](./images/janus/catalog-list.png)
182147

183148
2. Check that you entity has the annotations.
184149

185-
![entity](./images/entity.png)
150+
![entity](./images/janus/entity.png)
186151

187152
3. Go to the **Kiali** tab.
188153

189154
The **Kiali** tab displays the Overview view associated to a Servicemesh.
190155

191-
![overview-tab](./images/overview_tab.png)
156+
![overview-tab](./images/janus/overview_tab.png)
192157

193158
There is also a **Go To Kiali Graph** option at the bottom of each card, which redirects you to the **Graph in the Kiali Standalone**.
194159

160+
## Red Hat Developer Hub
161+
162+
If you want to know more about Kiali in Red Hat Developer Hub follow [these instructions](./RHDH.md)
163+
195164
## Development
196165

197166
To develop/contribute in kiali plugin follow [these instructions](./DEVELOPMENT.md)

plugins/kiali/RHDH.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Kiali Plugin in Red Hat Developer hub
2+
3+
The Kiali plugin is in the Red Hat Developer Hub for OpenShift users of Istio/OSSM. It is Technology Preview and provides early access to potential product features, enabling users to test features and provide feedback during the development process. Because this is a brand new offering, there are some things you should consider:
4+
5+
It is based on the new dynamic plugin-in framework.
6+
Because it is currently a Technology Preview, we are not yet ready to provide official support, and it is not subject Red Hat production service level agreements (SLAs).
7+
With that said, the Kiali team hopes that the community will try out the new Kiali Plugin in Red Hat Developer Hub and provide feedback. We thank you for joining the effort to provide Kiali/Service Mesh observability features directly to the Red Hat Developer Hub.
8+
9+
## Install
10+
11+
To install Kiali we need to modify the helm chart and add these values under global > dynamic > plugins
12+
13+
```yaml
14+
global:
15+
dynamic:
16+
includes:
17+
- dynamic-plugins.default.yaml
18+
plugins:
19+
- disabled: false
20+
integrity: <Checksum>
21+
package: '@janus-idp/backstage-plugin-kiali@<version>'
22+
pluginConfig:
23+
dynamicPlugins:
24+
frontend:
25+
janus-idp.backstage-plugin-kiali:
26+
appIcons:
27+
- importName: KialiIcon
28+
name: kialiIcon
29+
dynamicRoutes:
30+
- importName: KialiPage
31+
menuItem:
32+
icon: kialiIcon
33+
text: Kiali
34+
path: /kiali
35+
- disabled: falseName of the contact in Engineering
36+
integrity: <Checksum>
37+
package: '@janus-idp/backstage-plugin-kiali-backend-dynamic@<version>'
38+
pluginConfig:
39+
catalog:
40+
providers:
41+
kiali:
42+
skipTLSVerify: true
43+
url: '${KIALI_ENDPOINT}'
44+
serviceAccountToken: '${KIALI_SERVICE_ACCOUNT_TOKEN}'
45+
```
46+
47+
_integrity: required for external packages) An integrity checksum in the format of <alg>-<digest> specific to the package. Supported algorithms include sha256, sha384, and sha512._
48+
49+
We can calculate the integrity with the next bash commands (Example with version 1.9.0).
50+
51+
```bash
52+
53+
npm pack @janus-idp/[email protected]
54+
echo "sha512-$(cat janus-idp-backstage-plugin-kiali-backend-dynamic-1.9.0.tgz | openssl dgst -sha512 -binary | openssl base64 -A)"
55+
56+
```
57+
58+
_The mountPoints configuration is not available in the tech preview, we’ll use this to configure the kiali view by entity_
59+
60+
## Kiali Page
61+
62+
### Overview Page
63+
64+
![overview](./images/rhdh/RHDH_kiali_page_overview.png)
65+
66+
### Workloads List
67+
68+
![workloads](./images/rhdh/RHDH_kiali_page_workloads.png)
69+
70+
### Video Demo
71+
72+
[![RHDH-demo](https://img.youtube.com/vi/jCExpeXl9A8/0.jpg)](https://youtu.be/jCExpeXl9A8)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"verify": false,
3+
"missingAttributes": ["serviceAccountToken"],
4+
"message": "Attribute 'serviceAccountToken' is not in the backstage configuration",
5+
"helper": "For more information follow the steps in https://janus-idp.io/plugins/kiali",
6+
"authData": { "strategy": "token", "sessionInfo": {} }
7+
}

plugins/kiali/dev/index.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { KialiNoPath } from '../src/pages/Kiali';
1212
import { KialiHeader } from '../src/pages/Kiali/Header/KialiHeader';
1313
import { KialiHeaderEntity } from '../src/pages/Kiali/Header/KialiHeaderEntity';
1414
import { KialiEntity } from '../src/pages/Kiali/KialiEntity';
15+
import { KialiNoAnnotation } from '../src/pages/Kiali/KialiNoAnnotation';
16+
import { KialiNoResources } from '../src/pages/Kiali/KialiNoResources';
1517
import { OverviewPage } from '../src/pages/Overview/OverviewPage';
1618
import { WorkloadListPage } from '../src/pages/WorkloadList/WorkloadListPage';
1719
import { KialiApi, kialiApiRef } from '../src/services/Api';
@@ -50,7 +52,7 @@ import {
5052
} from '../src/types/Workload';
5153
import { filterNsByAnnotation } from '../src/utils/entityFilter';
5254
import { kialiData } from './__fixtures__';
53-
import { mockEntity } from './mockEntity';
55+
import { mockEntity, mockEntityAnnotationNoNamespace } from './mockEntity';
5456

5557
class MockKialiClient implements KialiApi {
5658
private entity?: Entity;
@@ -284,6 +286,7 @@ class MockKialiClient implements KialiApi {
284286

285287
interface Props {
286288
children?: React.ReactNode;
289+
entity?: Entity;
287290
isEntity?: boolean;
288291
}
289292

@@ -321,7 +324,7 @@ const RoutesList = () => (
321324

322325
const MockProvider = (props: Props) => {
323326
const content = (
324-
<KialiProvider entity={mockEntity}>
327+
<KialiProvider entity={props.entity || mockEntity}>
325328
<BrowserRouter>
326329
<Page themeId="tool">
327330
{!props.isEntity && (
@@ -357,12 +360,22 @@ createDevApp()
357360
.registerPlugin(kialiPlugin)
358361
.addPage({
359362
element: <MockProvider />,
360-
title: 'Kiali Overview',
363+
title: 'KialiPage',
361364
path: '/overview',
362365
})
363366
.addPage({
364367
element: <MockProvider isEntity />,
365-
title: 'Kiali Entity',
368+
title: 'Entity',
366369
path: '/kiali',
367370
})
371+
.addPage({
372+
element: <KialiNoResources entity={mockEntityAnnotationNoNamespace} />,
373+
title: 'No resource',
374+
path: '/no-resource',
375+
})
376+
.addPage({
377+
element: <KialiNoAnnotation />,
378+
title: 'No Annotation',
379+
path: '/no-annotation',
380+
})
368381
.render();

plugins/kiali/dev/mockEntity.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,38 @@ export const mockEntity: Entity = {
1717
owner: 'user:guest',
1818
},
1919
};
20+
21+
export const mockEntityNoAnnotation: Entity = {
22+
apiVersion: 'backstage.io/v1alpha1',
23+
kind: 'Component',
24+
metadata: {
25+
name: 'backstage',
26+
description: 'backstage.io',
27+
annotations: {
28+
'backstage.io/my-annotation': 'no annotation',
29+
'backstage.io/another-annotation': 'no other annotation',
30+
},
31+
},
32+
spec: {
33+
lifecycle: 'production',
34+
type: 'service',
35+
owner: 'user:guest',
36+
},
37+
};
38+
39+
export const mockEntityAnnotationNoNamespace: Entity = {
40+
apiVersion: 'backstage.io/v1alpha1',
41+
kind: 'Component',
42+
metadata: {
43+
name: 'backstage',
44+
description: 'backstage.io',
45+
annotations: {
46+
'backstage.io/kubernetes-namespace': 'no-namespace',
47+
},
48+
},
49+
spec: {
50+
lifecycle: 'production',
51+
type: 'service',
52+
owner: 'user:guest',
53+
},
54+
};
Loading
Loading
Loading
Loading
Loading

plugins/kiali/src/Router.tsx

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,15 @@ import React from 'react';
22
import { Route, Routes } from 'react-router-dom';
33

44
import { Entity } from '@backstage/catalog-model';
5-
import {
6-
Content,
7-
MissingAnnotationEmptyState,
8-
Page,
9-
} from '@backstage/core-components';
5+
import { Content, Page } from '@backstage/core-components';
106
import { useEntity } from '@backstage/plugin-catalog-react';
117

12-
import { Button } from '@material-ui/core';
13-
148
import { KialiNoPath } from './pages/Kiali';
159
import { KialiHeader } from './pages/Kiali/Header/KialiHeader';
1610
import { KialiHeaderEntity } from './pages/Kiali/Header/KialiHeaderEntity';
1711
import { KialiTabs } from './pages/Kiali/Header/KialiTabs';
1812
import { KialiEntity } from './pages/Kiali/KialiEntity';
13+
import { KialiNoAnnotation } from './pages/Kiali/KialiNoAnnotation';
1914
import { OverviewPage } from './pages/Overview/OverviewPage';
2015
import { WorkloadListPage } from './pages/WorkloadList/WorkloadListPage';
2116
import { KialiProvider } from './store/KialiProvider';
@@ -25,14 +20,16 @@ export const KUBERNETES_NAMESPACE = 'backstage.io/kubernetes-namespace';
2520
export const KUBERNETES_LABEL_SELECTOR_QUERY_ANNOTATION =
2621
'backstage.io/kubernetes-label-selector';
2722

23+
export const ANNOTATION_SUPPORTED = [KUBERNETES_NAMESPACE];
24+
2825
const validateAnnotation = (entity: Entity) => {
29-
return (
30-
Boolean(entity.metadata.annotations?.[KUBERNETES_NAMESPACE]) ||
31-
Boolean(entity.metadata.annotations?.[KUBERNETES_ANNOTATION]) ||
32-
Boolean(
33-
entity.metadata.annotations?.[KUBERNETES_LABEL_SELECTOR_QUERY_ANNOTATION],
34-
)
35-
);
26+
let validated = false;
27+
ANNOTATION_SUPPORTED.forEach(key => {
28+
if (Boolean(entity.metadata.annotations?.[key])) {
29+
validated = true;
30+
}
31+
});
32+
return validated;
3633
};
3734

3835
/*
@@ -41,22 +38,10 @@ const validateAnnotation = (entity: Entity) => {
4138

4239
export const EmbeddedRouter = () => {
4340
const { entity } = useEntity();
44-
if (!validateAnnotation(entity)) {
45-
return (
46-
<>
47-
<MissingAnnotationEmptyState annotation={KUBERNETES_ANNOTATION} />
48-
<h1>
49-
Or use a label selector query, which takes precedence over the
50-
previous annotation.
51-
</h1>
52-
<Button variant="contained" color="primary" href="#">
53-
Read Kiali Plugin Docs
54-
</Button>
55-
</>
56-
);
57-
}
5841

59-
return (
42+
return !validateAnnotation(entity) ? (
43+
<KialiNoAnnotation />
44+
) : (
6045
<KialiProvider entity={entity}>
6146
<KialiHeaderEntity />
6247
<Routes>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
3+
import {
4+
Content,
5+
MissingAnnotationEmptyState,
6+
Page,
7+
} from '@backstage/core-components';
8+
9+
import { ANNOTATION_SUPPORTED } from '../../Router';
10+
11+
export const KialiNoAnnotation = () => {
12+
return (
13+
<Page themeId="tool">
14+
<Content>
15+
<MissingAnnotationEmptyState
16+
annotation={ANNOTATION_SUPPORTED}
17+
readMoreUrl="https://github.com/janus-idp/backstage-plugins/blob/main/plugins/kiali/README.md"
18+
/>
19+
</Content>
20+
</Page>
21+
);
22+
};

0 commit comments

Comments
 (0)