|
2 | 2 |
|
3 | 3 | ## Minimal Setup
|
4 | 4 |
|
5 |
| -1. Go to plugins/kiali |
| 5 | +1. Run `yarn install` from the project root (For the first time setup) |
6 | 6 |
|
7 |
| -2. Execute yarn start |
| 7 | +2. Go to `plugins/kiali` |
8 | 8 |
|
9 |
| -3. Go to `http://localhost:3000/kiali` |
| 9 | +3. Execute `yarn start` |
| 10 | + |
| 11 | +4. Go to `http://localhost:3000/kiali` |
10 | 12 |
|
11 | 13 | ## Full Setup
|
12 | 14 |
|
|
21 | 23 | - Add to packages/backend/package.json
|
22 | 24 |
|
23 | 25 | ```yaml title="packages/backend/package.json"
|
24 |
| - '@janus-idp/backstage-plugin-kiali-backend': 'link:../../plugins/kiali-backend' |
| 26 | + "@janus-idp/backstage-plugin-kiali-backend": "link:../../plugins/kiali-backend", |
25 | 27 | ```
|
26 | 28 |
|
27 | 29 | 2. Enable the **Kiali** tab on the entity view page using the `packages/app/src/components/catalog/EntityPage.tsx` file:
|
|
44 | 46 |
|
45 | 47 | 3. Create a file called `kiali.ts` inside `packages/backend/src/plugins/` and add the following:
|
46 | 48 |
|
47 |
| -```ts |
48 |
| -/* highlight-add-start */ |
49 |
| -import { Router } from 'express'; |
50 |
| -
|
51 |
| -import { createRouter } from '@janus-idp/backstage-plugin-kiali-backend'; |
52 |
| -
|
53 |
| -import { PluginEnvironment } from '../types'; |
54 |
| -
|
55 |
| -export default async function createPlugin( |
56 |
| - env: PluginEnvironment, |
57 |
| -): Promise<Router> { |
58 |
| - return await createRouter({ |
59 |
| - logger: env.logger, |
60 |
| - config: env.config, |
61 |
| - }); |
62 |
| -} |
63 |
| -/* highlight-add-end */ |
64 |
| -``` |
65 |
| - |
66 |
| -5. import the plugin to `packages/backend/src/index.ts`. There are three lines of code you'll need to add, and they should be added near similar code in your existing Backstage backend. |
67 |
| - |
68 |
| -```typescript title="packages/backend/src/index.ts" |
69 |
| -// .. |
70 |
| -/* highlight-add-next-line */ |
71 |
| -import kiali from './plugins/kiali'; |
72 |
| -
|
73 |
| -async function main() { |
74 |
| - // ... |
75 |
| - /* highlight-add-next-line */ |
76 |
| - const kialiEnv = useHotMemoize(module, () => createEnv('kiali')); |
77 |
| - // ... |
78 |
| - /* highlight-add-next-line */ |
79 |
| - apiRouter.use('/kiali', await kiali(kialiEnv)); |
80 |
| -``` |
81 |
| - |
82 |
| -6. Configure you `app-config.local.yaml` with kiali configuration |
83 |
| - |
84 |
| -```yaml |
85 |
| -catalog: |
86 |
| - providers: |
87 |
| - # highlight-add-start |
88 |
| - kiali: |
89 |
| - # Required. Kiali endpoint |
90 |
| - url: ${KIALI_ENDPOINT} |
91 |
| - # Optional. Required by token authentication |
92 |
| - serviceAccountToken: ${KIALI_SERVICE_ACCOUNT_TOKEN} |
93 |
| - # Optional. defaults false |
94 |
| - skipTLSVerify: true |
95 |
| - # Optional |
96 |
| - caData: ${KIALI_CONFIG_CA_DATA} |
97 |
| - # Optional. Local path to CA file |
98 |
| - caFile: '' |
99 |
| - # Optional. Time in seconds that session is enabled, defaults to 1 minute. |
100 |
| - sessionTime: 60 |
101 |
| - # highlight-add-end |
102 |
| -``` |
103 |
| - |
104 |
| -7. Add catalog |
105 |
| - |
106 |
| -Add to locations in `app-config.local.yaml` |
107 |
| - |
108 |
| -```yaml |
109 |
| -locations: |
110 |
| - # Local example data for Kiali plugin |
111 |
| - - type: file |
112 |
| - target: ../../plugins/kiali/catalog-demo.yaml |
113 |
| -``` |
| 49 | + ```ts title="packages/backend/src/plugins/kiali.tsx" |
| 50 | + /* highlight-add-start */ |
| 51 | + import { Router } from 'express'; |
| 52 | +
|
| 53 | + // .. |
| 54 | + import { createRouter } from '@janus-idp/backstage-plugin-kiali-backend'; |
| 55 | +
|
| 56 | + import { PluginEnvironment } from '../types'; |
| 57 | +
|
| 58 | + export default async function createPlugin( |
| 59 | + env: PluginEnvironment, |
| 60 | + ): Promise<Router> { |
| 61 | + return await createRouter({ |
| 62 | + logger: env.logger, |
| 63 | + config: env.config, |
| 64 | + }); |
| 65 | + } |
| 66 | + // .. |
| 67 | + /* highlight-add-end */ |
| 68 | + ``` |
| 69 | + |
| 70 | +4. import the plugin to `packages/backend/src/index.ts`. There are three lines of code you'll need to add, and they should be added near similar code in your existing Backstage backend. |
| 71 | + |
| 72 | + ```typescript title="packages/backend/src/index.ts" |
| 73 | + // .. |
| 74 | + /* highlight-add-next-line */ |
| 75 | + import kiali from './plugins/kiali'; |
| 76 | +
|
| 77 | + async function main() { |
| 78 | + // ... |
| 79 | + /* highlight-add-next-line */ |
| 80 | + const kialiEnv = useHotMemoize(module, () => createEnv('kiali')); |
| 81 | + // ... |
| 82 | + /* highlight-add-next-line */ |
| 83 | + apiRouter.use('/kiali', await kiali(kialiEnv)); |
| 84 | + // ... |
| 85 | + } |
| 86 | + ``` |
| 87 | + |
| 88 | +5. Configure you `app-config.local.yaml` with kiali configuration |
| 89 | + |
| 90 | + ```yaml |
| 91 | + catalog: |
| 92 | + providers: |
| 93 | + # highlight-add-start |
| 94 | + kiali: |
| 95 | + # Required. Kiali endpoint |
| 96 | + url: ${KIALI_ENDPOINT} |
| 97 | + # Optional. Required by token authentication |
| 98 | + serviceAccountToken: ${KIALI_SERVICE_ACCOUNT_TOKEN} |
| 99 | + # Optional. defaults false |
| 100 | + skipTLSVerify: true |
| 101 | + # Optional |
| 102 | + caData: ${KIALI_CONFIG_CA_DATA} |
| 103 | + # Optional. Local path to CA file |
| 104 | + caFile: '' |
| 105 | + # Optional. Time in seconds that session is enabled, defaults to 1 minute. |
| 106 | + sessionTime: 60 |
| 107 | + # highlight-add-end |
| 108 | + ``` |
| 109 | + |
| 110 | +6. Add catalog |
| 111 | + |
| 112 | + Add to locations in `app-config.local.yaml` |
| 113 | + |
| 114 | + ```yaml |
| 115 | + locations: |
| 116 | + # Local example data for Kiali plugin |
| 117 | + - type: file |
| 118 | + target: ../../plugins/kiali/catalog-demo.yaml |
| 119 | + ``` |
| 120 | + |
| 121 | +7. Run `yarn start:backstage` from the project root. |
| 122 | +8. After create a new component, the Kiali tab should be enabled: |
| 123 | + |
| 124 | + |
114 | 125 |
|
115 | 126 | ## Configure auth
|
116 | 127 |
|
117 | 128 | ### Token authentication
|
118 | 129 |
|
119 | 130 | 1. Set the parameters in app-config.local.yaml
|
120 | 131 |
|
121 |
| -```yaml |
122 |
| -catalog: |
123 |
| - providers: |
124 |
| - # highlight-add-start |
125 |
| - kiali: |
126 |
| - # Required. Kiali endpoint |
127 |
| - url: ${KIALI_ENDPOINT} |
128 |
| - # Optional. Required by token authentication |
129 |
| - serviceAccountToken: ${KIALI_SERVICE_ACCOUNT_TOKEN} |
130 |
| - # Optional. defaults false |
131 |
| - skipTLSVerify: true |
132 |
| - # Optional |
133 |
| -``` |
| 132 | + ```yaml |
| 133 | + catalog: |
| 134 | + providers: |
| 135 | + # highlight-add-start |
| 136 | + kiali: |
| 137 | + # Required. Kiali endpoint |
| 138 | + url: ${KIALI_ENDPOINT} |
| 139 | + # Optional. Required by token authentication |
| 140 | + serviceAccountToken: ${KIALI_SERVICE_ACCOUNT_TOKEN} |
| 141 | + # Optional. defaults false |
| 142 | + skipTLSVerify: true |
| 143 | + # Optional |
| 144 | + ``` |
134 | 145 |
|
135 | 146 | 2. To get `KIALI_SERVICE_ACCOUNT_TOKEN` create your service account and create the token
|
136 | 147 |
|
137 |
| -```bash |
138 |
| -kubectl create token $KIALI_SERVICE_ACCOUNT |
139 |
| -``` |
| 148 | + ```bash |
| 149 | + kubectl create token $KIALI_SERVICE_ACCOUNT |
| 150 | + ``` |
140 | 151 |
|
141 |
| -or if you installed kiali with the operator then execute |
| 152 | + or if you installed kiali with the operator then execute |
142 | 153 |
|
143 |
| -```bash |
144 |
| -export KIALI_SERVICE_ACCOUNT_TOKEN=$(kubectl describe secret $(kubectl get secret -n istio-system | grep kiali-service-account-token | cut -d" " -f1) -n istio-system | grep token: | cut -d ":" -f2 | sed 's/^ *//') |
145 |
| -``` |
| 154 | + ```bash |
| 155 | + export KIALI_SERVICE_ACCOUNT_TOKEN=$(kubectl describe secret $(kubectl get secret -n istio-system | grep kiali-service-account-token | cut -d" " -f1) -n istio-system | grep token: | cut -d ":" -f2 | sed 's/^ *//') |
| 156 | + ``` |
0 commit comments