Skip to content

Commit

Permalink
feat(kubernetes): support rolling restart operation for deployments (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
maggieneterval authored Oct 17, 2019
1 parent 7e8cb7e commit 17be6af
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/scripts/modules/core/src/manifest/ManifestWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ export class ManifestWriter {
});
}

public static rollingRestartManifest(command: any, application: Application): IPromise<ITask> {
const description = 'Rolling restart of manifest';
command.type = 'rollingRestartManifest';
return TaskExecutor.executeTask({
job: [command],
application,
description,
});
}

public static findArtifactsFromResource(command: any, application: Application): IPromise<ITask> {
const description = 'Find artifacts from a Kubernetes resource';
command.type = 'findArtifactsFromResource';
Expand Down
2 changes: 2 additions & 0 deletions app/scripts/modules/kubernetes/src/v2/kubernetes.v2.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { ManifestWizard } from 'kubernetes/v2/manifest/wizard/ManifestWizard';
import { KUBERNETES_ENABLE_MANIFEST_STAGE } from 'kubernetes/v2/pipelines/stages/traffic/enableManifest.stage';
import { KUBERNETES_DISABLE_MANIFEST_STAGE } from 'kubernetes/v2/pipelines/stages/traffic/disableManifest.stage';
import { KubernetesSecurityGroupReader } from 'kubernetes/shared/securityGroup/securityGroup.reader';
import { KUBERNETES_ROLLING_RESTART } from 'kubernetes/v2/manifest/rollout/RollingRestart';

import 'kubernetes/shared/validation/applicationName.validator';
import 'kubernetes/shared/help/kubernetes.help';
Expand Down Expand Up @@ -87,6 +88,7 @@ module(KUBERNETES_V2_MODULE, [
KUBERNETES_ENABLE_MANIFEST_STAGE,
KUBERNETES_DISABLE_MANIFEST_STAGE,
STAGE_ARTIFACT_SELECTOR_COMPONENT_REACT,
KUBERNETES_ROLLING_RESTART,
]).config(() => {
CloudProviderRegistry.registerProvider('kubernetes', {
name: 'Kubernetes',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { module } from 'angular';

import * as React from 'react';
import { react2angular } from 'react2angular';

import { Application, ManifestWriter, ReactInjector } from '@spinnaker/core';

import { IKubernetesServerGroupManager } from 'kubernetes/v2/serverGroupManager';

interface IRollingRestartProps {
application: Application;
serverGroupManager: IKubernetesServerGroupManager;
}

interface IRollingRestartParameters {
account: string;
cloudProvider: string;
location: string;
manifestName: string;
}

function RollingRestart({ application, serverGroupManager }: IRollingRestartProps) {
function rollingRestart() {
const rollingRestartParameters: IRollingRestartParameters = {
account: serverGroupManager.account,
cloudProvider: 'kubernetes',
location: serverGroupManager.namespace,
manifestName: serverGroupManager.name,
};
ReactInjector.confirmationModalService.confirm({
account: serverGroupManager.account,
askForReason: true,
header: `Initiate rolling restart of ${serverGroupManager.name}`,
provider: 'kubernetes',
submitMethod: () => {
return ManifestWriter.rollingRestartManifest(rollingRestartParameters, application);
},
taskMonitorConfig: {
application,
title: `Rolling restart of ${serverGroupManager.name}`,
},
});
}
return (
<li>
<a onClick={rollingRestart}>Rolling Restart</a>
</li>
);
}

export const KUBERNETES_ROLLING_RESTART = 'spinnaker.kubernetes.v2.rolling.restart';
module(KUBERNETES_ROLLING_RESTART, []).component(
'kubernetesRollingRestart',
react2angular(RollingRestart, ['application', 'serverGroupManager']),
);
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ <h3 class="horizontal middle space-between flex-1" select-on-dbl-click>
Pause Rollout
</a>
</li>
<kubernetes-rolling-restart
ng-if="!ctrl.manifest.status.paused.state"
application="ctrl.app"
server-group-manager="ctrl.serverGroupManager"
/>
<li role="presentation" class="divider"></li>
<li>
<a href ng-click="ctrl.editServerGroupManager()">
Expand Down

0 comments on commit 17be6af

Please sign in to comment.