From 7eb2bb45f449c5846c157224d500e06b610706cf Mon Sep 17 00:00:00 2001 From: Vincent Fiduccia Date: Fri, 9 Dec 2016 18:51:05 -0700 Subject: [PATCH] Upgrade loadbalancer image --- app/admin-tab/audit-logs/template.hbs | 2 +- app/components/new-balancer/component.js | 19 ++++++++++++++ app/components/new-balancer/template.hbs | 11 ++++++++ app/components/stack-section/component.js | 6 ++++- app/components/stack-section/template.hbs | 17 +++++++++---- app/k8s-tab/dashboard/route.js | 31 +++++++++++++++++++++++ app/k8s-tab/dashboard/template.hbs | 20 +++++++++++++++ app/models/loadbalancerservice.js | 10 +++++++- app/models/service.js | 5 ++-- app/models/template.js | 2 +- app/service/new-balancer/controller.js | 3 ++- app/service/new-balancer/route.js | 6 +++++ app/service/new-balancer/template.hbs | 1 + app/styles/components/_catalog-box.scss | 10 +++++--- app/styles/pages/_stack.scss | 7 +++-- app/utils/constants.js | 2 +- app/utils/navigation-tree.js | 13 ++++++++++ translations/en-us.yaml | 9 +++++++ 18 files changed, 152 insertions(+), 22 deletions(-) create mode 100644 app/k8s-tab/dashboard/route.js create mode 100644 app/k8s-tab/dashboard/template.hbs diff --git a/app/admin-tab/audit-logs/template.hbs b/app/admin-tab/audit-logs/template.hbs index d2189452c..2c3acd5d0 100644 --- a/app/admin-tab/audit-logs/template.hbs +++ b/app/admin-tab/audit-logs/template.hbs @@ -55,7 +55,7 @@ {{date-from-now log.created}} - {{log.eventType}} + {{log.eventType}} {{#if log.description}}{{log.description}}{{else}}None{{/if}} diff --git a/app/components/new-balancer/component.js b/app/components/new-balancer/component.js index d0595358c..5db73c0ef 100644 --- a/app/components/new-balancer/component.js +++ b/app/components/new-balancer/component.js @@ -12,6 +12,7 @@ export default Ember.Component.extend(NewOrEdit, { allHosts : null, allServices : null, allCertificates : null, + upgradeImage : null, isGlobal : null, isRequestedHost : null, @@ -212,6 +213,10 @@ export default Ember.Component.extend(NewOrEdit, { return false; } + if ( this.get('upgradeImage')+'' === 'true' ) { + return true; + } + // Label arrays are updated one at a time and make this flap, // so ignore them until they're all set if ( !this.get('labelsReady') ) { @@ -222,9 +227,23 @@ export default Ember.Component.extend(NewOrEdit, { let neu = removeKeys(this.get('service.launchConfig.labels'),C.LABELS_TO_IGNORE); return arrayToStr(old) !== arrayToStr(neu); }.property( + 'editing', + 'upgradeImage', 'service.launchConfig.labels' ), + upgradeInfo: function() { + let from = (this.get('existing.launchConfig.imageUuid')||'').replace(/^docker:/,''); + let to = (this.get('service.launchConfig.imageUuid')||'').replace(/^docker:/,''); + + if ( this.get('upgradeImage')+'' === 'true' ) { + return Ember.Object.create({ + from: from, + to: to, + }); + } + }.property('existing.launchConfig.imageUuid','service.launchConfig.imageUuid'), + // ---------------------------------- // Labels // ---------------------------------- diff --git a/app/components/new-balancer/template.hbs b/app/components/new-balancer/template.hbs index d1a23ad05..cf2c44dce 100644 --- a/app/components/new-balancer/template.hbs +++ b/app/components/new-balancer/template.hbs @@ -92,5 +92,16 @@ {{/select-tab}} +{{#if upgradeInfo}} + +{{/if}} + {{top-errors errors=errors}} {{save-cancel editing=editing editLabel=editLabel save="save" cancel="cancel"}} diff --git a/app/components/stack-section/component.js b/app/components/stack-section/component.js index bb382c926..b0150e971 100644 --- a/app/components/stack-section/component.js +++ b/app/components/stack-section/component.js @@ -40,9 +40,13 @@ export default Ember.Component.extend({ this.get('prefs').set(C.PREFS.EXPANDED_STACKS, list); }, - addtlInfo: function(service) { + addtlInfo(service) { this.sendAction('showAddtlInfo', service); }, + + upgradeImage(service) { + service.send('upgrade','true'); + } }, init() { diff --git a/app/components/stack-section/template.hbs b/app/components/stack-section/template.hbs index 98367103d..c5c387574 100644 --- a/app/components/stack-section/template.hbs +++ b/app/components/stack-section/template.hbs @@ -96,12 +96,19 @@ {{#if service.showTransitioningMessage}} ({{service.transitioningMessage}}) {{/if}} - - {{#if service.isError}} - {{#link-to "service.log" service.stackId service.id class="btn-link"}}{{/link-to}} - {{/if}} + {{~#if service.imageUpgradeAvailable~}} + {{#tooltip-element type="tooltip-basic" model=(t 'stackSection.upgradeImage') tooltipTemplate="tooltip-static" aria-describedby="tooltip-base" tooltipFor="upgradeImage"}} + + {{/tooltip-element}} + {{~/if~}} + {{~#if service.isError~}} + {{#link-to "service.log" service.stackId service.id class="btn-link service-icon-button"}}{{/link-to}} + {{~/if~}} {{service.displayDetail}}{{service.displayPorts}} diff --git a/app/k8s-tab/dashboard/route.js b/app/k8s-tab/dashboard/route.js new file mode 100644 index 000000000..b120b0101 --- /dev/null +++ b/app/k8s-tab/dashboard/route.js @@ -0,0 +1,31 @@ +import Ember from 'ember'; +import C from 'ui/utils/constants'; + +export default Ember.Route.extend({ + k8s: Ember.inject.service(), + + model() { + return this.get('k8s').getServices().then((services) => { + let svc = services.find(function(x) { + return x && x.metadata && x.metadata.labels && x.metadata.labels[C.LABEL.K8S_DASHBOARD]; + }); + + if ( svc ) + { + let port = svc.spec.ports[0]; + let dashboard; + if ( port ) { + dashboard = 'http://' + this.get('k8s.clusterIp') +'/'+ port.nodePort; + } + + return Ember.Object.create({ + dashboardUrl: dashboard, + }); + } + else + { + return Ember.RSVP.reject('Unable to find kubernetes-dashbaord service'); + } + }); + }, +}); diff --git a/app/k8s-tab/dashboard/template.hbs b/app/k8s-tab/dashboard/template.hbs new file mode 100644 index 000000000..a73d8c5a7 --- /dev/null +++ b/app/k8s-tab/dashboard/template.hbs @@ -0,0 +1,20 @@ +
+

{{t 'k8sTab.dashboard.header'}}

+
+ +
+
+
+
+ +
+

{{t 'k8sTab.dashboard.dashboard.header'}}

+

{{t 'k8sTab.dashboard.dashboard.content'}}

+ {{#if model.dashboardUrl}} + {{t 'k8sTab.dashboard.dashboard.button'}} + {{else}} + + {{/if}} +
+
+
diff --git a/app/models/loadbalancerservice.js b/app/models/loadbalancerservice.js index 9d78ee534..303679cc4 100644 --- a/app/models/loadbalancerservice.js +++ b/app/models/loadbalancerservice.js @@ -18,7 +18,9 @@ function specToPort(spec) { var LoadBalancerService = Service.extend({ type: 'loadBalancerService', - intl : Ember.inject.service(), + + intl: Ember.inject.service(), + settings: Ember.inject.service(), initPorts() { let rules = this.get('lbConfig.portRules')||[]; @@ -122,6 +124,12 @@ var LoadBalancerService = Service.extend({ return out.htmlSafe(); }.property('consumedServicesWithNames.@each.{name,service}', 'intl._locale'), + + imageUpgradeAvailable: function() { + let cur = this.get('launchConfig.imageUuid').replace(/^docker:/,''); + let available = this.get(`settings.${C.SETTING.BALANCER_IMAGE}`); + return cur !== available && !!this.get('actionLinks.upgrade'); + }.property('launchConfig.imageUuid',`settings.${C.SETTING.BALANCER_IMAGE}`,'actionLinks.upgrade'), }); export default LoadBalancerService; diff --git a/app/models/service.js b/app/models/service.js index 5b8b2f249..d06f725f7 100644 --- a/app/models/service.js +++ b/app/models/service.js @@ -79,7 +79,7 @@ var Service = Resource.extend({ } }, - upgrade() { + upgrade(upgradeImage='false') { var route = 'service.new'; if ( (this.get('launchConfig.kind')||'').toLowerCase() === 'virtualmachine') { route = 'service.new-virtualmachine'; @@ -90,6 +90,7 @@ var Service = Resource.extend({ this.get('application').transitionToRoute(route, {queryParams: { serviceId: this.get('id'), upgrade: true, + upgradeImage: upgradeImage, stackId: this.get('stackId'), }}); }, @@ -386,8 +387,6 @@ var Service = Resource.extend({ return Util.formatSi(this.get('launchConfig.memoryReservation'), 1024, 'iB', 'B'); } }), - - }); export function activeIcon(service) diff --git a/app/models/template.js b/app/models/template.js index 480594430..6360d80c1 100644 --- a/app/models/template.js +++ b/app/models/template.js @@ -79,7 +79,7 @@ export default Resource.extend({ } if ( str === C.LABEL.CERTIFIED_RANCHER && this.get('catalogId') === C.CATALOG.LIBRARY_KEY ) { - return 'badge-certified'; + return 'badge-rancher'; } else if ( str === C.LABEL.CERTIFIED_PARTNER ) { return 'badge-partner'; } else { diff --git a/app/service/new-balancer/controller.js b/app/service/new-balancer/controller.js index e4e77a315..04cd02e86 100644 --- a/app/service/new-balancer/controller.js +++ b/app/service/new-balancer/controller.js @@ -1,11 +1,12 @@ import Ember from 'ember'; export default Ember.Controller.extend({ - queryParams: ['stackId','serviceId','tab','upgrade'], + queryParams: ['stackId','serviceId','tab','upgrade','upgradeImage'], stackId: null, serviceId: null, tab: 'ssl', upgrade: null, + upgradeImage: 'false', actions: { done() { diff --git a/app/service/new-balancer/route.js b/app/service/new-balancer/route.js index 782fe4ac0..aaa5d2834 100644 --- a/app/service/new-balancer/route.js +++ b/app/service/new-balancer/route.js @@ -24,6 +24,11 @@ export default Ember.Route.extend({ if ( hash.existingService ) { if ( params.upgrade+'' === 'true' ) { service = hash.existingService.clone(); + + if ( params.upgradeImage+'' === 'true' ) { + service.set('launchConfig.imageUuid', 'docker:' + this.get(`settings.${C.SETTING.BALANCER_IMAGE}`)); + } + hash.existing = hash.existingService; } else { service = hash.existingService.cloneForNew(); @@ -74,6 +79,7 @@ export default Ember.Route.extend({ controller.set('stackId', null); controller.set('serviceId', null); controller.set('upgrade', null); + controller.set('upgradeImage', null); } }, diff --git a/app/service/new-balancer/template.hbs b/app/service/new-balancer/template.hbs index f694bdd4b..c45a1e188 100644 --- a/app/service/new-balancer/template.hbs +++ b/app/service/new-balancer/template.hbs @@ -2,6 +2,7 @@ service=model.service existing=model.existing editing=upgrade + upgradeImage=upgradeImage allHosts=model.allHosts allServices=model.allServices allCertificates=model.allCertificates diff --git a/app/styles/components/_catalog-box.scss b/app/styles/components/_catalog-box.scss index 39fda8819..05e84446e 100644 --- a/app/styles/components/_catalog-box.scss +++ b/app/styles/components/_catalog-box.scss @@ -172,8 +172,9 @@ $lines-to-show: 4; @extend .badge-rancher; background-color: $greenTwo; - &:after { - border-color: $greenTwo; + &:before { + border-color: $greenTwo; + border-left-color: transparent; } } @@ -181,8 +182,9 @@ $lines-to-show: 4; @extend .badge-rancher; background-color: $blueTwo; - &:after { - border-color: $blueTwo; + &:before { + border-color: $blueTwo; + border-left-color: transparent; } } diff --git a/app/styles/pages/_stack.scss b/app/styles/pages/_stack.scss index a6b976b48..ddf140b3b 100644 --- a/app/styles/pages/_stack.scss +++ b/app/styles/pages/_stack.scss @@ -478,11 +478,10 @@ $light-yellow: #FFBE18; background-image: url('images/hexagon-kubernetes.svg'); } -.addtl-info-trigger { +.service-icon-button { cursor: pointer; - margin-left: 3px; - position: relative; - top: 1px; + padding-left: 3px; + padding-right: 3px; } .service-detail { diff --git a/app/utils/constants.js b/app/utils/constants.js index 8cf12a5c2..23c680b5e 100644 --- a/app/utils/constants.js +++ b/app/utils/constants.js @@ -131,7 +131,7 @@ var C = { K8S_POD_NAMESPACE: 'io.kubernetes.pod.namespace', K8S_POD_NAME: 'io.kubernetes.pod.name', K8S_KUBECTL: 'io.rancher.k8s.kubectld', - K8S_DASHBOARD: 'io.rancher.k8s.dashboard', + K8S_DASHBOARD: 'io.rancher.k8s.kubernetes-dashboard', ORCHESTRATION_SUPPORTED: 'io.rancher.orchestration.supported', CERTIFIED: 'io.rancher.certified', CERTIFIED_RANCHER: 'rancher', diff --git a/app/utils/navigation-tree.js b/app/utils/navigation-tree.js index 7ad9e2491..73e922249 100644 --- a/app/utils/navigation-tree.js +++ b/app/utils/navigation-tree.js @@ -105,6 +105,9 @@ const navTree = [ ctx: [getProjectId, getNamespaceId], condition: k8sReady, }, + { + divider: true, + }, { id: 'k8s-cli', localizedLabel: 'nav.k8s.cli', @@ -113,6 +116,16 @@ const navTree = [ ctx: [getProjectId], condition: k8sReady, }, + /* + { + id: 'k8s-dashboard', + localizedLabel: 'nav.k8s.dashboard', + icon: 'icon icon-external-link', + route: 'k8s-tab.dashboard', + ctx: [getProjectId], + condition: k8sReady, + }, + */ { id: 'k8s-notready', icon: 'icon icon-spinner icon-spin', diff --git a/translations/en-us.yaml b/translations/en-us.yaml index 74e87424e..8e4118b85 100644 --- a/translations/en-us.yaml +++ b/translations/en-us.yaml @@ -703,6 +703,13 @@ k8sTab: petset: Pet Set pod: Pod + dashboard: + header: Kubernetes Dashboard + dashboard: + header: Dashboard + content: Kubernetes Dashboard is a general purpose, web-based UI for Kubernetes clusters. It allows users to manage applications running in the cluster and troubleshoot them, as well as manage the cluster itself. + button: Kubernetes UI + kubectl: header: kubectl stepOne: @@ -946,6 +953,7 @@ servicePage: description: placeholder: e.g. Current version of MyApp newBalancer: + upgradeImage: "The balancer software image will be upgraded from {from} to {to}." form: name: placeholder: e.g. website @@ -3010,6 +3018,7 @@ stackSection: details: Details containers: Containers actions: Actions + upgradeImage: Upgrade Container Image snapshotSection: