diff --git a/src/app/backend/apihandler.go b/src/app/backend/apihandler.go index 3f0f4109c1813a6f1f2ed4f916d5e49aa4d4d6a2..2049bf2db52289000390b21242b355a51e4a92b6 100644 --- a/src/app/backend/apihandler.go +++ b/src/app/backend/apihandler.go @@ -37,14 +37,14 @@ func CreateHttpApiHandler(client *client.Client) http.Handler { Writes(AppDeployment{})) wsContainer.Add(deployWs) - microserviceListWs := new(restful.WebService) - microserviceListWs.Path("/api/microservice"). + replicaSetListWs := new(restful.WebService) + replicaSetListWs.Path("/api/replicaset"). Produces(restful.MIME_JSON) - microserviceListWs.Route( - microserviceListWs.GET(""). - To(apiHandler.handleGetMicroserviceList). - Writes(MicroserviceList{})) - wsContainer.Add(microserviceListWs) + replicaSetListWs.Route( + replicaSetListWs.GET(""). + To(apiHandler.handleGetReplicaSetList). + Writes(ReplicaSetList{})) + wsContainer.Add(replicaSetListWs) return wsContainer } @@ -68,11 +68,11 @@ func (apiHandler *ApiHandler) handleDeploy(request *restful.Request, response *r response.WriteHeaderAndEntity(http.StatusCreated, cfg) } -// Handles get microservice list API call. -func (apiHandler *ApiHandler) handleGetMicroserviceList( +// Handles get Replica Set list API call. +func (apiHandler *ApiHandler) handleGetReplicaSetList( request *restful.Request, response *restful.Response) { - result, err := GetMicroserviceList(apiHandler.client) + result, err := GetReplicaSetList(apiHandler.client) if err != nil { handleInternalError(response, err) return diff --git a/src/app/backend/microservicelist.go b/src/app/backend/replicasetlist.go similarity index 55% rename from src/app/backend/microservicelist.go rename to src/app/backend/replicasetlist.go index bac73387e97c28f9cbabf9e01e90bc58e063938e..cb306e3472333ddc1cf0cf4a82b742a05444e4a9 100644 --- a/src/app/backend/microservicelist.go +++ b/src/app/backend/replicasetlist.go @@ -21,25 +21,18 @@ import ( "k8s.io/kubernetes/pkg/labels" ) -// List of microservices in the cluster. -type MicroserviceList struct { - // Unordered list of microservices. - Microservices []Microservice `json:"microservices"` +// List of Replica Sets in the cluster. +type ReplicaSetList struct { + // Unordered list of Replica Sets. + ReplicaSets []ReplicaSet `json:"replicaSets"` } -// Microservice is a Kubernetes replica set plus zero or more Kubernetes services. -type Microservice struct { - // Name of the microservice, derived from the replica set. +// Kubernetes Replica Set (aka. Replication Controller) plus zero or more Kubernetes services that +// target the Replica Set. +type ReplicaSet struct { + // Name of the Replica Set. Name string `json:"name"` - // Replica set that represents the microservice. - ReplicaSet ReplicaSet `json:"replicaSet"` - - // TODO(bryk): Add service field here. -} - -// Replica set model to represent in the user interface. -type ReplicaSet struct { // Number of pods that are currently running. PodsRunning int `json:"podsRunning"` @@ -48,10 +41,12 @@ type ReplicaSet struct { // Container images of the replica set. ContainerImages []string `json:"containerImages"` + + // TODO(bryk): Add service information here. } -// Returns a list of all microservices in the cluster. -func GetMicroserviceList(client *client.Client) (*MicroserviceList, error) { +// Returns a list of all Replica Sets in the cluster. +func GetReplicaSetList(client *client.Client) (*ReplicaSetList, error) { list, err := client.ReplicationControllers(api.NamespaceAll). List(labels.Everything(), fields.Everything()) @@ -59,24 +54,22 @@ func GetMicroserviceList(client *client.Client) (*MicroserviceList, error) { return nil, err } - microserviceList := &MicroserviceList{} + replicaSetList := &ReplicaSetList{} - for _, element := range list.Items { + for _, replicaSet := range list.Items { var containerImages []string - for _, container := range element.Spec.Template.Spec.Containers { + for _, container := range replicaSet.Spec.Template.Spec.Containers { containerImages = append(containerImages, container.Image) } - microserviceList.Microservices = append(microserviceList.Microservices, Microservice{ - Name: element.ObjectMeta.Name, - ReplicaSet: ReplicaSet{ - ContainerImages: containerImages, - PodsRunning: element.Status.Replicas, - PodsDesired: element.Spec.Replicas, - }, + replicaSetList.ReplicaSets = append(replicaSetList.ReplicaSets, ReplicaSet{ + Name: replicaSet.ObjectMeta.Name, + ContainerImages: containerImages, + PodsRunning: replicaSet.Status.Replicas, + PodsDesired: replicaSet.Spec.Replicas, }) } - return microserviceList, nil + return replicaSetList, nil } diff --git a/src/app/externs/backendapi.js b/src/app/externs/backendapi.js index bca1010b109051198c0a52b76ad6d2406f853c4d..a651ac3fe5a39dc813c31eeefd64d9fb7b96b39e 100644 --- a/src/app/externs/backendapi.js +++ b/src/app/externs/backendapi.js @@ -50,20 +50,18 @@ backendApi.AppDeployment; /** * @typedef {{ - * microservices: !Array + * replicaSets: !Array * }} */ -backendApi.MicroserviceList; +backendApi.ReplicaSetList; /** * @typedef {{ * name: string, - * replicaSet: { - * podsRunning: number, - * podsDesired: number, - * containerImages: !Array - * } + * podsRunning: number, + * podsDesired: number, + * containerImages: !Array * }} */ -backendApi.Microservice; +backendApi.ReplicaSet; diff --git a/src/app/frontend/index.module.js b/src/app/frontend/index.module.js index dc30c78cd8a5d1f3ae8fcc4853fe33562809812f..be6fc37c3b1e20487d6626afd2d0109d5d0f2563 100644 --- a/src/app/frontend/index.module.js +++ b/src/app/frontend/index.module.js @@ -19,8 +19,8 @@ import chromeModule from './chrome/chrome.module'; import deployModule from './deploy/deploy.module'; import indexConfig from './index.config'; +import replicaSetListModule from './replicasetlist/replicasetlist.module'; import routeConfig from './index.route'; -import microserviceListModule from './microservicelist/microservicelist.module'; import zerostateModule from './zerostate/zerostate.module'; @@ -36,7 +36,7 @@ export default angular.module( 'ui.router', chromeModule.name, deployModule.name, - microserviceListModule.name, + replicaSetListModule.name, zerostateModule.name, ]) .config(indexConfig) diff --git a/src/app/frontend/microservicelist/microservicelist.scss b/src/app/frontend/microservicelist/microservicelist.scss deleted file mode 100644 index f409d89ec93d36f71272e308739c417f17ad0bd8..0000000000000000000000000000000000000000 --- a/src/app/frontend/microservicelist/microservicelist.scss +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 Google Inc. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -.kd-microservice-card { - padding-top: 0; - width: 400px; -} - -.kd-microservice-card-menu { - max-width: 48px; -} diff --git a/src/app/frontend/microservicelist/microservicelist.controller.js b/src/app/frontend/replicasetlist/replicasetlist.controller.js similarity index 64% rename from src/app/frontend/microservicelist/microservicelist.controller.js rename to src/app/frontend/replicasetlist/replicasetlist.controller.js index cda98b5859400304cd7bb229aba542f8cb863b5d..ccb2297e805f6dfc7b3e5f81253ed58e78b5d31e 100644 --- a/src/app/frontend/microservicelist/microservicelist.controller.js +++ b/src/app/frontend/replicasetlist/replicasetlist.controller.js @@ -14,19 +14,19 @@ /** - * Controller for the service list view. + * Controller for the replica set list view. * * @final */ -export default class MicroserviceListController { +export default class ReplicaSetListController { /** * @param {!angular.$log} $log * @param {!angular.$resource} $resource * @ngInject */ constructor($log, $resource) { - /** @export {!Array} */ - this.microservices = []; + /** @export {!Array} */ + this.replicaSets = []; this.initialize_($log, $resource); } @@ -37,14 +37,14 @@ export default class MicroserviceListController { * @private */ initialize_($log, $resource) { - /** @type {!angular.Resource} */ - let resource = $resource('/api/microservice'); + /** @type {!angular.Resource} */ + let resource = $resource('/api/replicaset'); - resource.get((microserviceList) => { - $log.info('Successfully fetched microservice list: ', microserviceList); - this.microservices = microserviceList.microservices; + resource.get((replicaSetList) => { + $log.info('Successfully fetched Replica Set list: ', replicaSetList); + this.replicaSets = replicaSetList.replicaSets; }, (err) => { - $log.error('Error fetching microservice list: ', err); + $log.error('Error fetching Replica Set list: ', err); }); } } diff --git a/src/app/frontend/microservicelist/microservicelist.html b/src/app/frontend/replicasetlist/replicasetlist.html similarity index 74% rename from src/app/frontend/microservicelist/microservicelist.html rename to src/app/frontend/replicasetlist/replicasetlist.html index 21096e0cb5c5e6cea96e6f6fb5dac48d017d5956..52a75ac7bcb8a67595cf1d1e3996cf412487d0f5 100644 --- a/src/app/frontend/microservicelist/microservicelist.html +++ b/src/app/frontend/replicasetlist/replicasetlist.html @@ -15,16 +15,16 @@ limitations under the License. -->
- - + +
- {{microservice.name}} - + {{replicaSet.name}} + more_vert
- {{microservice.replicaSet.podsRunning}} pods running + {{replicaSet.podsRunning}} pods running
diff --git a/src/app/frontend/microservicelist/microservicelist.module.js b/src/app/frontend/replicasetlist/replicasetlist.module.js similarity index 76% rename from src/app/frontend/microservicelist/microservicelist.module.js rename to src/app/frontend/replicasetlist/replicasetlist.module.js index d55f01a8612e82736cfdb9e59fbf7555a48f7af0..53dd1618cf3fdefad3a0d6f56b252216ac43f530 100644 --- a/src/app/frontend/microservicelist/microservicelist.module.js +++ b/src/app/frontend/replicasetlist/replicasetlist.module.js @@ -12,16 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -import stateConfig from './microservicelist.state'; +import stateConfig from './replicasetlist.state'; /** - * Angular module for the microservice list view. + * Angular module for the Replica Set list view. * - * The view shows microservices running in the cluster and allows to manage them. + * The view shows Replica Sets running in the cluster and allows to manage them. */ export default angular.module( - 'kubernetesDashboard.microserviceList', + 'kubernetesDashboard.replicaSetList', [ 'ngMaterial', 'ui.router', diff --git a/src/app/frontend/replicasetlist/replicasetlist.scss b/src/app/frontend/replicasetlist/replicasetlist.scss new file mode 100644 index 0000000000000000000000000000000000000000..8032ef446a50a8dfa0ab041e9b92701b394f3e1f --- /dev/null +++ b/src/app/frontend/replicasetlist/replicasetlist.scss @@ -0,0 +1,23 @@ +// Copyright 2015 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +.kd-replicaset-card { + padding-top: 0; + width: 400px; +} + +.kd-replicaset-card-menu { + max-width: 48px; +} + diff --git a/src/app/frontend/microservicelist/microservicelist.state.js b/src/app/frontend/replicasetlist/replicasetlist.state.js similarity index 76% rename from src/app/frontend/microservicelist/microservicelist.state.js rename to src/app/frontend/replicasetlist/replicasetlist.state.js index 850066fea814fa1b13aafb6ab4a823381e2eeca1..cb9bd9dc372f7fe27dd5dceb9043d400259733c2 100644 --- a/src/app/frontend/microservicelist/microservicelist.state.js +++ b/src/app/frontend/replicasetlist/replicasetlist.state.js @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import MicroserviceListController from './microservicelist.controller'; +import ReplicaSetListController from './replicasetlist.controller'; /** @@ -22,10 +22,10 @@ import MicroserviceListController from './microservicelist.controller'; * @ngInject */ export default function stateConfig($stateProvider) { - $stateProvider.state('microservicelist', { - controller: MicroserviceListController, + $stateProvider.state('replicasetlist', { + controller: ReplicaSetListController, controllerAs: 'ctrl', - url: '/microservicelist', - templateUrl: 'microservicelist/microservicelist.html', + url: '/replicasetlist', + templateUrl: 'replicasetlist/replicasetlist.html', }); }