Skip to content

Commit 64b321a

Browse files
Sebastian FlorekSebastian Florek
authored andcommitted
Add initial version of service list and service details pages (#726)
1 parent 4104146 commit 64b321a

32 files changed

+704
-115
lines changed

src/app/backend/resource/replicationcontroller/replicationcontrollerdetail.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,11 @@ func UpdateReplicasCount(client k8sClient.Interface, namespace, name string,
203203
// Returns detailed information about service from given service
204204
func getService(service api.Service, replicationController api.ReplicationController,
205205
pods []api.Pod, nodes []api.Node) resourceService.Service {
206-
return resourceService.Service{
207-
ObjectMeta: common.CreateObjectMeta(service.ObjectMeta),
208-
TypeMeta: common.CreateTypeMeta(service.TypeMeta),
209-
InternalEndpoint: common.GetInternalEndpoint(service.Name, service.Namespace,
210-
service.Spec.Ports),
211-
ExternalEndpoints: getExternalEndpoints(replicationController, pods, service, nodes),
212-
Selector: service.Spec.Selector,
213-
}
206+
207+
result := resourceService.GetServiceDetails(&service);
208+
result.ExternalEndpoints = getExternalEndpoints(replicationController, pods, service, nodes)
209+
210+
return result;
214211
}
215212

216213
// Returns array of external endpoints for a replication controller.

src/app/backend/resource/service/services.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ type Service struct {
3737

3838
// Label selector of the service.
3939
Selector map[string]string `json:"selector"`
40+
41+
// Type determines how the service will be exposed. Valid options: ClusterIP, NodePort, LoadBalancer
42+
Type api.ServiceType `json:"type"`
43+
44+
// ClusterIP is usually assigned by the master. Valid values are None, empty string (""), or
45+
// a valid IP address. None can be specified for headless services when proxying is not required
46+
ClusterIP string `json:"clusterIP"`
4047
}
4148

4249
// ServiceList contains a list of services in the cluster.
@@ -55,7 +62,7 @@ func GetService(client client.Interface, namespace, name string) (*Service, erro
5562
return nil, err
5663
}
5764

58-
service := getServices(serviceData)
65+
service := GetServiceDetails(serviceData)
5966
return &service, nil
6067
}
6168

@@ -74,18 +81,21 @@ func GetServiceList(client client.Interface) (*ServiceList, error) {
7481

7582
serviceList := &ServiceList{Services: make([]Service, 0)}
7683
for _, service := range services.Items {
77-
serviceList.Services = append(serviceList.Services, getServices(&service))
84+
serviceList.Services = append(serviceList.Services, GetServiceDetails(&service))
7885
}
7986

8087
return serviceList, nil
8188
}
8289

83-
func getServices(service *api.Service) Service {
90+
// GetServiceDetails returns api service object based on kubernetes service object
91+
func GetServiceDetails(service *api.Service) Service {
8492
return Service{
8593
ObjectMeta: common.CreateObjectMeta(service.ObjectMeta),
8694
TypeMeta: common.CreateTypeMeta(service.TypeMeta),
8795
InternalEndpoint: common.GetInternalEndpoint(service.Name, service.Namespace, service.Spec.Ports),
8896
// TODO(maciaszczykm): Fill ExternalEndpoints with data.
89-
Selector: service.Spec.Selector,
97+
Selector: service.Spec.Selector,
98+
ClusterIP: service.Spec.ClusterIP,
99+
Type: service.Spec.Type,
90100
}
91101
}

src/app/externs/backendapi.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ backendApi.TypeMeta;
214214
* containerImages: !Array<string>,
215215
* podInfo: !backendApi.PodInfo,
216216
* pods: !backendApi.PodList,
217-
* services: !Array<!backendApi.Service>,
217+
* services: !Array<!backendApi.ServiceDetail>,
218218
* hasMetrics: boolean
219219
* }}
220220
*/
@@ -253,10 +253,20 @@ backendApi.Pod;
253253
* typeMeta: !backendApi.TypeMeta,
254254
* internalEndpoint: !backendApi.Endpoint,
255255
* externalEndpoints: !Array<!backendApi.Endpoint>,
256-
* selector: !Object<string, string>
256+
* selector: !Object<string, string>,
257+
* labels: !Object<string, string>,
258+
* clusterIP: string,
259+
* type: string
257260
* }}
258261
*/
259-
backendApi.Service;
262+
backendApi.ServiceDetail;
263+
264+
/**
265+
* @typedef {{
266+
* services: !Array<backendApi.ServiceDetail>
267+
* }}
268+
*/
269+
backendApi.ServiceList;
260270

261271
/**
262272
* @typedef {{

src/app/frontend/index_module.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@
1818
*/
1919
import chromeModule from './chrome/chrome_module';
2020
import deployModule from './deploy/deploy_module';
21+
import deprecatedReplicationControllerListModule from './replicationcontrollerlistdeprecated/replicationcontrollerlist_module';
2122
import errorModule from './error/error_module';
2223
import indexConfig from './index_config';
23-
import routeConfig from './index_route';
2424
import logsModule from './logs/logs_module';
25+
import replicaSetListModule from './replicasetlist/replicasetlist_module';
2526
import replicationControllerDetailModule from './replicationcontrollerdetail/replicationcontrollerdetail_module';
2627
import replicationControllerListModule from './replicationcontrollerlist/replicationcontrollerlist_module';
27-
import deprecatedReplicationControllerListModule from './replicationcontrollerlistdeprecated/replicationcontrollerlist_module';
28-
import replicaSetListModule from './replicasetlist/replicasetlist_module';
28+
import routeConfig from './index_route';
29+
import serviceDetailModule from './servicedetail/servicedetail_module';
30+
import serviceListModule from './servicelist/servicelist_module';
2931
import workloadsModule from './workloads/workloads_module';
3032

3133
export default angular
@@ -48,6 +50,8 @@ export default angular
4850
deprecatedReplicationControllerListModule.name,
4951
replicaSetListModule.name,
5052
workloadsModule.name,
53+
serviceDetailModule.name,
54+
serviceListModule.name,
5155
])
5256
.config(indexConfig)
5357
.config(routeConfig);

src/app/frontend/podlist/podcardlist.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
limitations under the License.
1515
-->
1616

17-
<kd-resource-card-list selectable="false" with-statuses="false" ng-if="::$ctrl.podList.pods">
17+
<kd-resource-card-list selectable="::$ctrl.selectable" with-statuses="::$ctrl.withStatuses"
18+
ng-if="::$ctrl.podList.pods">
1819
<kd-resource-card-header-columns>
1920
<kd-resource-card-header-column size="medium" grow="4">Name</kd-resource-card-header-column>
2021
<kd-resource-card-header-column>Status</kd-resource-card-header-column>

src/app/frontend/podlist/podcardlist_component.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,9 @@ export const podCardListComponent = {
5454
'podList': '<',
5555
/** {!function({pod: !backendApi.Pod}): string} */
5656
'logsHrefFn': '&',
57+
/** {boolean} */
58+
'selectable': '<',
59+
/** {boolean} */
60+
'withStatuses': '<',
5761
},
5862
};

src/app/frontend/podlist/podlist_module.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import stateConfig from './podlist_stateconfig';
1616
import {podCardListComponent} from './podcardlist_component';
1717

1818
/**
19-
* Module containing endpoint components.
19+
* Angular module for the Pods list view.
20+
*
21+
* The view shows Pods running in the cluster and allows to manage them.
2022
*/
2123
export default angular
2224
.module(

src/app/frontend/replicasetlist/replicasetlist_module.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import {replicaSetCardListComponent} from './replicasetcardlist_component';
2020
import replicaSetDetailModule from 'replicasetdetail/replicasetdetail_module';
2121

2222
/**
23-
* Angular module for the Replication Controller list view.
23+
* Angular module for the Replica Set list view.
2424
*
25-
* The view shows Replication Controllers running in the cluster and allows to manage them.
25+
* The view shows Replica Set running in the cluster and allows to manage them.
2626
*/
2727
export default angular
2828
.module(

src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail.html

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,22 @@
1818
<md-content>
1919
<md-tabs md-border-bottom md-dynamic-height>
2020
<md-tab label="Overview">
21-
<kd-replication-controller-info details="::ctrl.replicationControllerDetail">
21+
<kd-replication-controller-info replication-controller="::ctrl.replicationControllerDetail">
2222
</kd-replication-controller-info>
2323

24-
<kd-replication-controller-services services="::ctrl.replicationControllerDetail.services">
25-
</kd-replication-controller-services>
24+
<kd-content-card ng-if="::ctrl.replicationControllerDetail.services">
25+
<kd-title>Services</kd-title>
26+
<kd-content>
27+
<kd-service-card-list services="::ctrl.replicationControllerDetail.services">
28+
</kd-service-card-list>
29+
</kd-content>
30+
</kd-content-card>
2631

2732
<kd-content-card>
28-
<kd-title>
29-
Pods
30-
</kd-title>
33+
<kd-title>Pods</kd-title>
3134
<kd-content>
3235
<kd-pod-card-list pod-list="::ctrl.replicationControllerDetail.pods"
33-
logs-href-fn="::ctrl.getPodLogsHref(pod)">
36+
logs-href-fn="::ctrl.getPodLogsHref(pod)">
3437
</kd-pod-card-list>
3538
</kd-content>
3639
</kd-content-card>

src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail_module.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import componentsModule from './../common/components/components_module';
1616
import filtersModule from 'common/filters/filters_module';
1717
import logsModule from 'logs/logs_module';
1818
import podListModule from 'podlist/podlist_module';
19+
import serviceListModule from 'servicelist/servicelist_module';
1920
import stateConfig from './replicationcontrollerdetail_stateconfig';
2021
import {replicationControllerEventsComponent} from './replicationcontrollerevents_component';
2122
import {replicationControllerInfoComponent} from './replicationcontrollerinfo_component';
2223
import {ReplicationControllerService} from './replicationcontroller_service';
23-
import {replicationControllerServicesComponent} from './replicationcontrollerservices_component';
2424

2525
/**
2626
* Angular module for the Replication Controller details view.
@@ -38,9 +38,9 @@ export default angular
3838
filtersModule.name,
3939
logsModule.name,
4040
podListModule.name,
41+
serviceListModule.name,
4142
])
4243
.config(stateConfig)
4344
.component('kdReplicationControllerInfo', replicationControllerInfoComponent)
44-
.component('kdReplicationControllerServices', replicationControllerServicesComponent)
4545
.component('kdReplicationControllerEvents', replicationControllerEventsComponent)
4646
.service('kdReplicationControllerService', ReplicationControllerService);

0 commit comments

Comments
 (0)