-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Irfan Habib
committed
Sep 30, 2018
1 parent
c48de76
commit 24bdc99
Showing
17 changed files
with
344 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...etrics/kubernetes-node-metric-stats-card/kubernetes-node-metric-stats-card.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div class="kubernetes-node-metric-stats-card"> | ||
<mat-card> | ||
<mat-card-header> | ||
<mat-card-title>Summary of {{title}} Usage for Last {{period}} in {{unit}}</mat-card-title> | ||
</mat-card-header> | ||
<mat-card-content> | ||
<div class="app-metadata"> | ||
<app-kubernetes-node-simple-metric key="Mean" value="{{ mean$ | async }}"></app-kubernetes-node-simple-metric> | ||
<app-kubernetes-node-simple-metric key="Maximum" value="{{ max$ | async }}"></app-kubernetes-node-simple-metric> | ||
</div> | ||
</mat-card-content> | ||
</mat-card> | ||
</div> |
Empty file.
25 changes: 25 additions & 0 deletions
25
...ics/kubernetes-node-metric-stats-card/kubernetes-node-metric-stats-card.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { KubernetesNodeMetricStatsCardComponent } from './kubernetes-node-metric-stats-card.component'; | ||
|
||
describe('KubernetesNodeMetricStatsCardComponent', () => { | ||
let component: KubernetesNodeMetricStatsCardComponent; | ||
let fixture: ComponentFixture<KubernetesNodeMetricStatsCardComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ KubernetesNodeMetricStatsCardComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(KubernetesNodeMetricStatsCardComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
50 changes: 50 additions & 0 deletions
50
...-metrics/kubernetes-node-metric-stats-card/kubernetes-node-metric-stats-card.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Component, Input, OnInit, OnDestroy } from '@angular/core'; | ||
import { Observable, of as observableOf, Subscription } from 'rxjs'; | ||
import { KubernetesNodeService, KubeNodeMetric } from '../../../services/kubernetes-node.service'; | ||
import { MetricStatistic } from '../../../store/kube.types'; | ||
import { IMetrics } from '../../../../../store/types/base-metric.types'; | ||
|
||
@Component({ | ||
selector: 'app-kubernetes-node-metric-stats-card', | ||
templateUrl: './kubernetes-node-metric-stats-card.component.html', | ||
styleUrls: ['./kubernetes-node-metric-stats-card.component.scss'] | ||
}) | ||
export class KubernetesNodeMetricStatsCardComponent implements OnInit, OnDestroy { | ||
|
||
@Input() | ||
title = 'Memory'; | ||
|
||
@Input() | ||
metric: KubeNodeMetric; | ||
|
||
@Input() | ||
period = 'Hour'; | ||
|
||
@Input() | ||
unit: string; | ||
|
||
max$: Observable<number>; | ||
mean$: Observable<number>; | ||
subscriptions: Subscription[] = []; | ||
constructor( | ||
public kubeNodeService: KubernetesNodeService | ||
) { | ||
|
||
} | ||
|
||
ngOnInit() { | ||
|
||
const maxMetric = this.kubeNodeService.setupMetricObservable(this.metric, MetricStatistic.MAXIMUM); | ||
this.subscriptions.push(maxMetric.pollerSub); | ||
this.max$ = maxMetric.entity$; | ||
|
||
const meanMetric = this.kubeNodeService.setupMetricObservable(this.metric, MetricStatistic.AVERAGE); | ||
this.subscriptions.push(meanMetric.pollerSub); | ||
this.mean$ = meanMetric.entity$; | ||
} | ||
|
||
|
||
ngOnDestroy() { | ||
this.subscriptions.forEach(s => s.unsubscribe()); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...s-node-metrics/kubernetes-node-metrics-chart/kubernetes-node-metrics-chart.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div class="kubernetes-node-metrics-chart"> | ||
<mat-card> | ||
<mat-card-header> | ||
<mat-card-content class="kubernetes-node-metrics-chart__content"> | ||
<app-metrics-chart [title]="title" [metricsConfig]="instanceMetricConfig" [chartConfig]="instanceChartConfig"></app-metrics-chart> | ||
</mat-card-content> | ||
</mat-card-header> | ||
</mat-card> | ||
</div> | ||
|
8 changes: 8 additions & 0 deletions
8
...s-node-metrics/kubernetes-node-metrics-chart/kubernetes-node-metrics-chart.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.kubernetes-node-metrics-chart{ | ||
padding-top: 40px; | ||
width: 100%; | ||
&__content{ | ||
width: 100%; | ||
height: 300px; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ode-metrics/kubernetes-node-metrics-chart/kubernetes-node-metrics-chart.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { KubernetesNodeMetricsChartComponent } from './kubernetes-node-metrics-chart.component'; | ||
|
||
describe('KubernetesNodeMetricsChartComponent', () => { | ||
let component: KubernetesNodeMetricsChartComponent; | ||
let fixture: ComponentFixture<KubernetesNodeMetricsChartComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ KubernetesNodeMetricsChartComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(KubernetesNodeMetricsChartComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
66 changes: 66 additions & 0 deletions
66
...tes-node-metrics/kubernetes-node-metrics-chart/kubernetes-node-metrics-chart.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
|
||
import { MetricsConfig } from '../../../../../shared/components/metrics-chart/metrics-chart.component'; | ||
import { MetricsLineChartConfig } from '../../../../../shared/components/metrics-chart/metrics-chart.types'; | ||
import { IMetricMatrixResult } from '../../../../../store/types/base-metric.types'; | ||
import { IMetricApplication } from '../../../../../store/types/metric.types'; | ||
import { MetricsChartHelpers } from '../../../../../shared/components/metrics-chart/metrics.component.helpers'; | ||
import { FetchKubernetesMetricsAction } from '../../../store/kubernetes.actions'; | ||
|
||
@Component({ | ||
selector: 'app-kubernetes-node-metrics-chart', | ||
templateUrl: './kubernetes-node-metrics-chart.component.html', | ||
styleUrls: ['./kubernetes-node-metrics-chart.component.scss'] | ||
}) | ||
export class KubernetesNodeMetricsChartComponent implements OnInit { | ||
|
||
@Input() | ||
private nodeName: string; | ||
@Input() | ||
private endpointGuid: string; | ||
@Input() | ||
private yAxisLabel: string; | ||
@Input() | ||
private metricName: string; | ||
@Input() | ||
private seriesTranslation: string; | ||
@Input() | ||
public title: string; | ||
|
||
public instanceChartConfig: MetricsLineChartConfig; | ||
public instanceMetricConfig: MetricsConfig<IMetricMatrixResult<IMetricApplication>>; | ||
constructor() { } | ||
|
||
private buildChartConfig() { | ||
const lineChartConfig = new MetricsLineChartConfig(); | ||
lineChartConfig.xAxisLabel = 'Time'; | ||
lineChartConfig.yAxisLabel = this.yAxisLabel; | ||
lineChartConfig.showLegend = false; | ||
return lineChartConfig; | ||
} | ||
|
||
ngOnInit() { | ||
this.instanceChartConfig = this.buildChartConfig(); | ||
const query = `${this.metricName}{instance="${this.nodeName}"}[1h]&time=${(new Date()).getTime() / 1000}`; | ||
this.instanceMetricConfig = { | ||
getSeriesName: result => result.metric.name ? result.metric.name : result.metric.id, | ||
mapSeriesItemName: MetricsChartHelpers.getDateSeriesName, | ||
sort: MetricsChartHelpers.sortBySeriesName, | ||
mapSeriesItemValue: this.getmapSeriesItemValue(), | ||
metricsAction: new FetchKubernetesMetricsAction( | ||
this.nodeName, | ||
this.endpointGuid, | ||
query, | ||
), | ||
}; | ||
} | ||
|
||
private getmapSeriesItemValue() { | ||
switch (this.seriesTranslation) { | ||
case 'mb': | ||
return (bytes) => bytes / 1000000; | ||
default: | ||
return undefined; | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...s-node-metrics/kubernetes-node-simple-metric/kubernetes-node-simple-metric.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div class="kube-node-metric"> | ||
<div class="kube-node-metric__key"> | ||
<span class="kube-node-metric__key__span">{{ key }}</span> | ||
</div> | ||
<div class="kube-node-metric__value"> | ||
<span class="kube-node-metric__value__span">{{ value }}</span> | ||
</div> | ||
</div> | ||
|
Empty file.
25 changes: 25 additions & 0 deletions
25
...ode-metrics/kubernetes-node-simple-metric/kubernetes-node-simple-metric.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { KubernetesNodeSimpleMetricComponent } from './kubernetes-node-simple-metric.component'; | ||
|
||
describe('KubernetesNodeSimpleMetricComponent', () => { | ||
let component: KubernetesNodeSimpleMetricComponent; | ||
let fixture: ComponentFixture<KubernetesNodeSimpleMetricComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ KubernetesNodeSimpleMetricComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(KubernetesNodeSimpleMetricComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
...tes-node-metrics/kubernetes-node-simple-metric/kubernetes-node-simple-metric.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Component, OnInit, Input } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-kubernetes-node-simple-metric', | ||
templateUrl: './kubernetes-node-simple-metric.component.html', | ||
styleUrls: ['./kubernetes-node-simple-metric.component.scss'] | ||
}) | ||
export class KubernetesNodeSimpleMetricComponent implements OnInit { | ||
|
||
@Input() | ||
key: string; | ||
|
||
@Input() | ||
value: number; | ||
|
||
constructor() { } | ||
|
||
ngOnInit() { | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
...es-node-condition-card/kubernetes-node-condition/kubernetes-node-condition.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div class="kube-node-condition"> | ||
<div class="kube-node-condition__title"> | ||
<mat-icon [fontSet]="icons[condition][1]">{{ icons[condition][0] }}</mat-icon> | ||
<span class="kube-node-condition__title__span">{{ titles[condition] }}</span> | ||
</div> | ||
<app-boolean-indicator [isTrue]="(condition$ | async)?.status == 'True'" type="yes-no"></app-boolean-indicator> | ||
</div> |
14 changes: 14 additions & 0 deletions
14
...es-node-condition-card/kubernetes-node-condition/kubernetes-node-condition.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.kube-node-condition { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
margin-right: 20px; | ||
padding-top: 20px; | ||
&__title{ | ||
display: flex; | ||
justify-content: center; | ||
&__span{ | ||
margin-left: 10px; | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...node-condition-card/kubernetes-node-condition/kubernetes-node-condition.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { KubernetesNodeConditionComponent } from './kubernetes-node-condition.component'; | ||
|
||
describe('KubernetesNodeConditionComponent', () => { | ||
let component: KubernetesNodeConditionComponent; | ||
let fixture: ComponentFixture<KubernetesNodeConditionComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ KubernetesNodeConditionComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(KubernetesNodeConditionComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
45 changes: 45 additions & 0 deletions
45
...etes-node-condition-card/kubernetes-node-condition/kubernetes-node-condition.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Component, OnInit, Input } from '@angular/core'; | ||
import { ConditionType, Condition } from '../../../../../store/kube.types'; | ||
import { KubernetesNodeService } from '../../../../../services/kubernetes-node.service'; | ||
import { map, filter } from 'rxjs/operators'; | ||
import { Observable } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'app-kubernetes-node-condition', | ||
templateUrl: './kubernetes-node-condition.component.html', | ||
styleUrls: ['./kubernetes-node-condition.component.scss'] | ||
}) | ||
export class KubernetesNodeConditionComponent implements OnInit { | ||
|
||
|
||
@Input() | ||
condition: ConditionType; | ||
condition$: Observable<Condition>; | ||
|
||
public titles = { | ||
'Ready': 'Ready', | ||
'OutOfDisk': 'Out of Disk', | ||
'MemoryPressure': 'Memory Pressure', | ||
'DiskPressure': 'Disk Pressure' | ||
}; | ||
|
||
public icons = { | ||
'Ready': ['done_outline', 'material-icons'], | ||
'OutOfDisk': ['storage', 'stratos-icons'], | ||
'MemoryPressure': ['memory', 'material-icons'], | ||
'DiskPressure': ['storage', 'stratos-icons'], | ||
}; | ||
|
||
constructor( | ||
public kubeNodeService: KubernetesNodeService | ||
) { } | ||
|
||
ngOnInit() { | ||
|
||
this.condition$ = this.kubeNodeService.node$.pipe( | ||
filter(p => !!p && !!p.entity), | ||
map(p => p.entity.status.conditions), | ||
map(conditions => conditions.filter(o => o.type === this.condition)[0]) | ||
); | ||
} | ||
} |