Skip to content

Commit

Permalink
Merge pull request #395 from BennieMeng/hotfix/deployment-strategy-ch…
Browse files Browse the repository at this point in the history
…ange-error

fix: deployment strategy changeto rollingupdate error
  • Loading branch information
wilhelmguo authored Apr 15, 2019
2 parents 0f6055a + 00c147b commit 0e5f858
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ <h3 class="header-title" id="创建模版">
<label class="clr-col-md-3 form-group-label-override required">{{'TEMPLATE.UPDATE_WAY' | translate}}</label>
<div class="radio-inline">
<input type="radio" name="statefulSetStrategyType" id="statefulSetStrategyType1" value="RollingUpdate"
[(ngModel)]="kubeResource.spec.strategy.type" checked>
[(ngModel)]="kubeResource.spec.strategy.type" checked (change)="strategyTypeChange()">
<label for="statefulSetStrategyType1">{{'TEMPLATE.SCROLL_UPDATE' | translate}}</label>
</div>
<div class="radio-inline">
<input type="radio" name="statefulSetStrategyType" id="statefulSetStrategyType2" value="Recreate"
[(ngModel)]="kubeResource.spec.strategy.type">
[(ngModel)]="kubeResource.spec.strategy.type" (change)="strategyTypeChange()">
<label for="statefulSetStrategyType2">{{'TEMPLATE.REBUILD' | translate}}</label>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ export class CreateEditDeploymentTplComponent extends ContainerTpl implements On
return cpuLimit;
}

strategyTypeChange() {
if (this.kubeResource.spec.strategy.type === 'RollingUpdate' && !this.kubeResource.spec.strategy.rollingUpdate) {
this.kubeResource.spec.strategy.rollingUpdate = new RollingUpdateDeployment();
this.kubeResource.spec.strategy.rollingUpdate.maxSurge = '20%';
this.kubeResource.spec.strategy.rollingUpdate.maxUnavailable = 1;
}
}

initDefault() {
this.kubeResource = JSON.parse(defaultDeployment);
this.kubeResource.spec.template.spec.containers.push(this.defaultContainer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ export class PodLoggingComponent implements OnInit, OnDestroy {
this.messageHandlerService.showInfo('缺少机房信息,请联系管理员');
}
const command = this.selectedPod ?
`kubetool log --source ${this.logSource === undefined ? '' : this.logSource} --${this.resourceType} ` +
`kubetool log --source ${this.logSource === undefined ? '' : this.logSource}` +
` --${this.resourceType === 'deployments' ? 'deployment' : this.resourceType} ` +
`${this.resourceName} --pod=${this.selectedPod.metadata.name} --container=${this.selectedContainer} --layout=log` : '';
this.copyService.copy(command);
this.switchCopyButton();
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/src/app/shared/list-pod/list-pod.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ export class ListPodComponent implements OnDestroy {
this.messageHandlerService.showInfo('缺少机房信息,请联系管理员');
}
const kubeToolCmd = `kubetool log --source ${this.logSource === undefined ? '' : this.logSource} ` +
` --${this.resourceType} ${this.resourceName} --pod=${pod.metadata.name} --layout=log`;
` --${this.resourceType === 'deployments' ? 'deployment' : this.resourceType} ${this.resourceName}` +
` --pod=${pod.metadata.name} --layout=log`;
this.copyService.copy(kubeToolCmd);
this.switchCopyButton();
}
Expand Down

0 comments on commit 0e5f858

Please sign in to comment.