Skip to content

Commit 9835ca1

Browse files
feat: bring back kubecost table (#124)
Bring back kubecost table Updated readme with specific instructions
1 parent 5eef1a0 commit 9835ca1

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,23 @@ requires an environment variable (`KF_USER_ID`) to specify the current user –
2626
this is passed to the API server as an HTTP header.
2727

2828

29-
The following can be pasted in a script and executed.
29+
The following can be pasted in a script and executed. This uses the latest node lts version(v16.16.0).
3030
**NOTE**: `user` is when using vagrant. Use the email adress if it is the dev cluser (please never connect to prod directly)
3131
```
3232
cd frontend/common/kubeflow-common-lib
33-
npm i
33+
npm i
3434
npm run build
3535
cd dist/kubeflow
3636
npm link
3737
3838
cd ../../../../jupyter
3939
npm i
40-
npm link kubeflow
40+
npm link kubeflow --legacy-peer-deps
4141
KF_USER_ID=user npm start
4242
```
4343

44+
For the kubecost data to be retrievable, the following will need to be executed `kubectl port-forward -n kubecost-system deployment/kubecost-cost-analyzer 9090`
45+
4446
### Older instructions
4547
1. ~Change directory to front-end folder: `cd frontend`~
4648
2. ~Install dependencies: `npm install`~

frontend/jupyter/src/app/pages/index/index-default/index-default.component.html

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,11 @@
1414
(actionsEmitter)="reactVolumeToAction($event)"
1515
></lib-resource-table>
1616

17-
<!-- todo: Fix kubecost -->
18-
<!-- <lib-resource-table *ngIf="this.getCostStatus() == true; else error"
17+
<lib-resource-table *ngIf="this.getCostStatus() == true; else error"
1918
[config]="costConfig"
2019
[data]="processedCostData"
2120
[trackByFn]="costTrackByFn"
22-
></lib-resource-table> -->
23-
24-
<div class="center-flex ">
25-
<p>{{ 'jupyter.costTable.kubeCostError' | translate }}</p>
26-
</div>
21+
></lib-resource-table>
2722

2823
<ng-template #error>
2924
<div *ngIf="this.getCostStatus() == false" class="center-flex costerror">

frontend/jupyter/src/app/pages/index/index-default/index-default.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class IndexDefaultComponent implements OnInit, OnDestroy {
5353
pvcsWaitingViewer = new Set<string>();
5454
costConfig = defaultCostConfig;
5555
rawCostData: AggregateCostResponse = null;
56-
processedCostData: AggregateCostObject = null;
56+
processedCostData: AggregateCostObject[] = [];
5757

5858
constructor(
5959
public ns: NamespaceService,
@@ -98,7 +98,7 @@ export class IndexDefaultComponent implements OnInit, OnDestroy {
9898
if (!isEqual(this.rawCostData, aggCost)) {
9999
this.rawCostData = aggCost;
100100

101-
this.processedCostData = this.processIncomingCostData(aggCost);
101+
this.processedCostData = [this.processIncomingCostData(aggCost)];
102102
this.poller.reset();
103103
}
104104
},
@@ -416,7 +416,7 @@ export class IndexDefaultComponent implements OnInit, OnDestroy {
416416
});
417417
}
418418
public costTrackByFn(index: number, cost: AggregateCostObject) {
419-
return `${cost.cpuCost}/${cost.gpuCost}/${cost.pvCost}/${cost.total}`;
419+
return `${cost.cpuCost}/${cost.gpuCost}/${cost.pvCost}/${cost.totalCost}`;
420420
}
421421

422422
public getCostStatus() {
@@ -434,14 +434,14 @@ export class IndexDefaultComponent implements OnInit, OnDestroy {
434434
const resp = JSON.parse(
435435
JSON.stringify(cost),
436436
) as AggregateCostResponse;
437-
437+
438438
let costCopy: AggregateCostObject = {};
439439

440440
if (resp.data[this.currNamespace]) {
441441
costCopy.cpuCost = this.formatCost(resp.data[this.currNamespace].cpuCost + resp.data[this.currNamespace].ramCost);
442442
costCopy.gpuCost = this.formatCost(resp.data[this.currNamespace].gpuCost);
443443
costCopy.pvCost = this.formatCost(resp.data[this.currNamespace].pvCost);
444-
costCopy.total = this.formatCost(resp.data[this.currNamespace].totalCost);
444+
costCopy.totalCost = this.formatCost(resp.data[this.currNamespace].totalCost);
445445
}
446446

447447
return costCopy;

frontend/jupyter/src/app/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,5 +301,5 @@ export interface AggregateCostObject {
301301
cpuCost?: string;
302302
gpuCost?: string;
303303
pvCost?: string;
304-
total?: string;
304+
totalCost?: string;
305305
};

0 commit comments

Comments
 (0)