Skip to content

Commit

Permalink
feat: bring back kubecost table (#124)
Browse files Browse the repository at this point in the history
Bring back kubecost table
Updated readme with specific instructions
  • Loading branch information
mathis-marcotte authored Aug 18, 2022
1 parent 5eef1a0 commit 9835ca1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,23 @@ requires an environment variable (`KF_USER_ID`) to specify the current user –
this is passed to the API server as an HTTP header.


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

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`

### Older instructions
1. ~Change directory to front-end folder: `cd frontend`~
2. ~Install dependencies: `npm install`~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,11 @@
(actionsEmitter)="reactVolumeToAction($event)"
></lib-resource-table>

<!-- todo: Fix kubecost -->
<!-- <lib-resource-table *ngIf="this.getCostStatus() == true; else error"
<lib-resource-table *ngIf="this.getCostStatus() == true; else error"
[config]="costConfig"
[data]="processedCostData"
[trackByFn]="costTrackByFn"
></lib-resource-table> -->

<div class="center-flex ">
<p>{{ 'jupyter.costTable.kubeCostError' | translate }}</p>
</div>
></lib-resource-table>

<ng-template #error>
<div *ngIf="this.getCostStatus() == false" class="center-flex costerror">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class IndexDefaultComponent implements OnInit, OnDestroy {
pvcsWaitingViewer = new Set<string>();
costConfig = defaultCostConfig;
rawCostData: AggregateCostResponse = null;
processedCostData: AggregateCostObject = null;
processedCostData: AggregateCostObject[] = [];

constructor(
public ns: NamespaceService,
Expand Down Expand Up @@ -98,7 +98,7 @@ export class IndexDefaultComponent implements OnInit, OnDestroy {
if (!isEqual(this.rawCostData, aggCost)) {
this.rawCostData = aggCost;

this.processedCostData = this.processIncomingCostData(aggCost);
this.processedCostData = [this.processIncomingCostData(aggCost)];
this.poller.reset();
}
},
Expand Down Expand Up @@ -416,7 +416,7 @@ export class IndexDefaultComponent implements OnInit, OnDestroy {
});
}
public costTrackByFn(index: number, cost: AggregateCostObject) {
return `${cost.cpuCost}/${cost.gpuCost}/${cost.pvCost}/${cost.total}`;
return `${cost.cpuCost}/${cost.gpuCost}/${cost.pvCost}/${cost.totalCost}`;
}

public getCostStatus() {
Expand All @@ -434,14 +434,14 @@ export class IndexDefaultComponent implements OnInit, OnDestroy {
const resp = JSON.parse(
JSON.stringify(cost),
) as AggregateCostResponse;

let costCopy: AggregateCostObject = {};

if (resp.data[this.currNamespace]) {
costCopy.cpuCost = this.formatCost(resp.data[this.currNamespace].cpuCost + resp.data[this.currNamespace].ramCost);
costCopy.gpuCost = this.formatCost(resp.data[this.currNamespace].gpuCost);
costCopy.pvCost = this.formatCost(resp.data[this.currNamespace].pvCost);
costCopy.total = this.formatCost(resp.data[this.currNamespace].totalCost);
costCopy.totalCost = this.formatCost(resp.data[this.currNamespace].totalCost);
}

return costCopy;
Expand Down
2 changes: 1 addition & 1 deletion frontend/jupyter/src/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,5 +301,5 @@ export interface AggregateCostObject {
cpuCost?: string;
gpuCost?: string;
pvCost?: string;
total?: string;
totalCost?: string;
};

0 comments on commit 9835ca1

Please sign in to comment.