-
Notifications
You must be signed in to change notification settings - Fork 828
Feature/add kubernetes deployment migration #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
chengyumeng
merged 26 commits into
Qihoo360:master
from
wilhelmguo:feature/add_kubernetes_deployment_migration
Dec 7, 2018
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
dedc0b4
backend: Sortby slice to string
wilhelmguo 5fb93f0
backend: base api pageSize and pageNo must bigger than zero
wilhelmguo 50ca792
backend: add kubernetes resource dataselector for backend paging
wilhelmguo 5c26fcd
backend: add kubernetes deployment list
wilhelmguo 2d9c02b
backend: abstraction base controller
wilhelmguo 2f75143
Merge branch 'master' of github.com:Qihoo360/wayne into feature/add_k…
wilhelmguo 7277e57
backend: remove deployment debug logs
wilhelmguo 8da44cd
Merge branch 'master' of github.com:Qihoo360/wayne into feature/add_k…
wilhelmguo e9176a7
backend: update auditlog model Action size 255 to 256
wilhelmguo f33fe16
backend: update kubernetes deployment cluster & namespace param to path
wilhelmguo 451ebe4
backend: add get kube deployment api
wilhelmguo d601685
backend: get kubernetes list return DeploymentList Object
wilhelmguo 03cb40e
frontend: move tpl-detail to shared
wilhelmguo 699621f
frontend: add kubernetes deployment management
wilhelmguo c847355
merge master
wilhelmguo a6db772
backend: update kubernetes deployment createOrUpdate strategy
wilhelmguo de1bfa4
frontend: update deployment tpl generate rules
wilhelmguo 42e4b03
frontend: move tpl-detail to shared
wilhelmguo 4fe613b
backend: deal with Resources already exist error.
wilhelmguo 319f604
frontend: add kubernetes deployment migration
wilhelmguo b84aed2
frontend: update lib version
wilhelmguo 95b5bb9
frontend: migration deployment showcolumns key to lower case
wilhelmguo 453de6b
Merge branch 'master' of github.com:Qihoo360/wayne into feature/add_k…
wilhelmguo de6e641
Merge branch 'master' into feature/add_kubernetes_deployment_migration
42dedf4
backend: remove unused newline
wilhelmguo 07c8c93
Merge branch 'feature/add_kubernetes_deployment_migration' of https:/…
wilhelmguo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
frontend: add kubernetes deployment migration
- Loading branch information
commit 319f604ce144964c5ca79478c6faa34798c66d13
There are no files selected for viewing
This file contains hidden or 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
18 changes: 18 additions & 0 deletions
18
src/frontend/src/app/admin/kubernetes/deployment/kube-deployment.component.html
This file contains hidden or 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 |
|---|---|---|
| @@ -1,13 +1,31 @@ | ||
| <div class="row"> | ||
| <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> | ||
| <div class="table-search"> | ||
| <div class="table-search-left"> | ||
| <wayne-filter-box (confirm)="confirmEvent()" (cancel)="cancelEvent()"> | ||
| <wayne-checkbox-group [(ngModel)]="showList"> | ||
| <wayne-checkbox value="Name">名称</wayne-checkbox> | ||
| <wayne-checkbox value="Label">Label</wayne-checkbox> | ||
| <wayne-checkbox value="Containers">镜像</wayne-checkbox> | ||
| <wayne-checkbox value="Status">容器状态</wayne-checkbox> | ||
| <wayne-checkbox value="Age">Age</wayne-checkbox> | ||
| </wayne-checkbox-group> | ||
| </wayne-filter-box> | ||
| </div> | ||
| </div> | ||
| <kube-list-deployment | ||
| [deployments]="changedDeployments" | ||
| [page]="pageState.page" | ||
| (detail)="detail($event)" | ||
| (migration)="migration($event)" | ||
| [showState]="showState" | ||
| (paginate)="retrieve($event)"></kube-list-deployment> | ||
| </div> | ||
| </div> | ||
| <kube-migration-deployment></kube-migration-deployment> | ||
|
|
||
| <wayne-float-window value="{{cluster}}"> | ||
| <wayne-float-window-item *ngFor="let cluster of clusters" [value]="cluster" | ||
| (click)="jumpTo(cluster)"></wayne-float-window-item> | ||
| </wayne-float-window> | ||
|
|
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
45 changes: 45 additions & 0 deletions
45
...nd/src/app/admin/kubernetes/deployment/migration/kube-migration-deployment.component.html
This file contains hidden or 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 @@ | ||
| <clr-modal [(clrModalOpen)]="modalOpened" [clrModalSize]="'xl'" #modal> | ||
| <h3 class="modal-title">迁移部署到机房: [{{cluster}}] | ||
| <wayne-modal-operate [modal]="modal" *ngIf="modalOpened"></wayne-modal-operate> | ||
| </h3> | ||
| <div class="modal-body"> | ||
| <div class="alert alert-warning" *ngIf="warningMsg"> | ||
| <div class="alert-items"> | ||
| <div class="alert-item static"> | ||
| <div class="alert-icon-wrapper"> | ||
| <clr-icon class="alert-icon" shape="exclamation-circle"></clr-icon> | ||
| </div> | ||
| <span class="alert-text"> | ||
| {{warningMsg}} | ||
| </span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <form #ngForm="ngForm"> | ||
| <section class="form-block"> | ||
| <div class="form-group" style="padding-left: 135px;"> | ||
| <label for="deployment_app" class="col-md-3 form-group-label-override required">应用</label> | ||
| <div class="select form-control"> | ||
| <select [(ngModel)]="selectedApp" | ||
| id="deployment_app" | ||
| name="deployment_app"> | ||
| <option *ngFor="let app of apps" [ngValue]="app">{{app.name}} | ||
| </option> | ||
| </select> | ||
| </div> | ||
| </div> | ||
| <div class="form-group" style="padding-left: 135px;"> | ||
| <label for="deployment_metadata" class="col-md-3 form-group-label-override">部署模版</label> | ||
| <wayne-ace-editor-box id="deployment_metadata"></wayne-ace-editor-box> | ||
|
|
||
| </div> | ||
| </section> | ||
| </form> | ||
| <div class="modal-footer"> | ||
|
|
||
| <button type="button" class="btn btn-outline" (click)="onCancel()">{{'BUTTON.CANCEL' | translate}}</button> | ||
| <button type="button" class="btn btn-primary" [disabled]="!isValid" | ||
| (click)="onSubmit()">{{'BUTTON.SUBMIT' | translate}}</button> | ||
| </div> | ||
| </div> | ||
| </clr-modal> |
139 changes: 139 additions & 0 deletions
139
...tend/src/app/admin/kubernetes/deployment/migration/kube-migration-deployment.component.ts
This file contains hidden or 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,139 @@ | ||
| import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'; | ||
| import { NgForm } from '@angular/forms'; | ||
| import { AceEditorBoxComponent } from '../../../../shared/ace-editor/ace-editor-box/ace-editor-box.component'; | ||
| import { App } from '../../../../shared/model/v1/app'; | ||
| import { DeploymentService } from '../../../../shared/client/v1/deployment.service'; | ||
| import { AppService } from '../../../../shared/client/v1/app.service'; | ||
| import { AceEditorService } from '../../../../shared/ace-editor/ace-editor.service'; | ||
| import { MessageHandlerService } from '../../../../shared/message-handler/message-handler.service'; | ||
| import { AceEditorMsg } from '../../../../shared/ace-editor/ace-editor'; | ||
| import { isUndefined } from 'util'; | ||
| import { KubeDeployment } from '../../../../shared/model/v1/kubernetes/deployment'; | ||
| import { defaultDeployment } from '../../../../shared/default-models/deployment.const'; | ||
| import { AuthService } from '../../../../shared/auth/auth.service'; | ||
| import { Deployment, DeploymentMetaData } from '../../../../shared/model/v1/deployment'; | ||
| import { DeploymentTplService } from '../../../../shared/client/v1/deploymenttpl.service'; | ||
| import { DeploymentTpl } from '../../../../shared/model/v1/deploymenttpl'; | ||
|
|
||
| @Component({ | ||
| selector: 'kube-migration-deployment', | ||
| templateUrl: 'kube-migration-deployment.component.html' | ||
| }) | ||
| export class KubeMigrationDeploymentComponent implements OnInit { | ||
|
|
||
| @Output() create = new EventEmitter<boolean>(); | ||
| modalOpened: boolean; | ||
|
|
||
| @ViewChild('ngForm') | ||
| currentForm: NgForm; | ||
|
|
||
| @ViewChild(AceEditorBoxComponent) | ||
| aceBox: any; | ||
|
|
||
| deployment: KubeDeployment; | ||
| isSubmitOnGoing = false; | ||
|
|
||
| warningMsg: string; | ||
| cluster: string; | ||
|
|
||
| apps: App[]; | ||
| selectedApp: App; | ||
|
|
||
| constructor(private deploymentService: DeploymentService, | ||
| private deploymentTplService: DeploymentTplService, | ||
| private appService: AppService, | ||
| public authService: AuthService, | ||
| private aceEditorService: AceEditorService, | ||
| private messageHandlerService: MessageHandlerService) { | ||
|
|
||
| } | ||
|
|
||
| ngOnInit(): void { | ||
| this.appService | ||
| .getNames() | ||
| .subscribe( | ||
| response => { | ||
| this.apps = response.data; | ||
| }, | ||
| error => this.messageHandlerService.handleError(error) | ||
| ); | ||
|
|
||
| } | ||
|
|
||
| openModal(cluster: string, deployment: KubeDeployment) { | ||
| this.modalOpened = true; | ||
| this.isSubmitOnGoing = false; | ||
| this.warningMsg = ''; | ||
| this.cluster = cluster; | ||
|
|
||
|
wilhelmguo marked this conversation as resolved.
|
||
| this.deployment = JSON.parse(defaultDeployment); | ||
| this.deployment.metadata.name = deployment.metadata.name; | ||
| this.deployment.metadata.labels = deployment.metadata.labels; | ||
| this.deployment.metadata.annotations = deployment.metadata.annotations; | ||
| this.deployment.spec = deployment.spec; | ||
| this.validLabel(deployment); | ||
| this.initJsonEditor(); | ||
| } | ||
|
|
||
| initJsonEditor(): void { | ||
| this.aceEditorService.announceMessage(AceEditorMsg.Instance(this.deployment)); | ||
| } | ||
|
|
||
| validLabel(deployment: KubeDeployment) { | ||
| const app = deployment.spec.selector.matchLabels['app']; | ||
| if (!app) { | ||
| this.warningMsg = '.spec.selector.matchLabels 没有app标签,直接发布可能会导致游离的rs!'; | ||
| } | ||
| if (app !== deployment.metadata.name) { | ||
| this.warningMsg = '.spec.selector.matchLabels app标签和部署名称不一致,直接发布可能会导致游离的rs!'; | ||
| } | ||
| } | ||
|
|
||
| onCancel() { | ||
| this.modalOpened = false; | ||
| this.currentForm.reset(); | ||
| } | ||
|
|
||
| onSubmit() { | ||
|
|
||
|
wilhelmguo marked this conversation as resolved.
Outdated
|
||
| if (this.isSubmitOnGoing) { | ||
| return; | ||
| } | ||
| this.isSubmitOnGoing = true; | ||
| const deployment = new Deployment(); | ||
| deployment.name = this.deployment.metadata.name; | ||
| deployment.appId = this.selectedApp.id; | ||
| const metaData = new DeploymentMetaData(); | ||
| metaData.replicas = {[this.cluster]: this.deployment.spec.replicas}; | ||
| deployment.metaData = JSON.stringify(metaData); | ||
| this.deploymentService.create(deployment).subscribe( | ||
| resp => { | ||
| const data = resp.data; | ||
| const deploymentTpl = new DeploymentTpl(); | ||
| deploymentTpl.name = this.deployment.metadata.name; | ||
| deploymentTpl.deploymentId = data.id; | ||
| deploymentTpl.template = JSON.stringify(this.deployment); | ||
| deploymentTpl.description = 'migration from kubernetes. '; | ||
| this.deploymentTplService.create(deploymentTpl, this.selectedApp.id).subscribe( | ||
| () => { | ||
| this.messageHandlerService.showSuccess('创建部署和部署模版成功!请前往前台手动发布部署到相应机房!'); | ||
| }, | ||
| error => { | ||
| this.messageHandlerService.handleError(error); | ||
| }); | ||
| }, | ||
| error => { | ||
| this.messageHandlerService.handleError(error); | ||
| } | ||
| ); | ||
| this.modalOpened = false; | ||
| } | ||
|
|
||
| public get isValid(): boolean { | ||
| return this.currentForm && | ||
| this.currentForm.valid && | ||
| !this.isSubmitOnGoing && | ||
| !isUndefined(this.selectedApp); | ||
| } | ||
|
|
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.