added blue green strategy (#47)

* added blue green strategy

* Addressed review comments

* addressed pr comments

* updated names in test

* addressed final pr comments
This commit is contained in:
Sundar
2020-07-13 08:59:05 +05:30
committed by GitHub
parent c9b54fdae2
commit b4bc3003e8
26 changed files with 2893 additions and 175 deletions
+27 -5
View File
@@ -5,15 +5,26 @@ import * as SMICanaryDeploymentHelper from '../utilities/strategy-helpers/smi-ca
import { Kubectl } from '../kubectl-object-model';
import * as utils from '../utilities/manifest-utilities';
import * as TaskInputParameters from '../input-parameters';
import { rejectBlueGreenService } from '../utilities/strategy-helpers/service-blue-green-helper';
import { rejectBlueGreenIngress } from '../utilities/strategy-helpers/ingress-blue-green-helper';
import { rejectBlueGreenSMI } from '../utilities/strategy-helpers/smi-blue-green-helper'
import { isSMIRoute, isIngressRoute, isBlueGreenDeploymentStrategy } from '../utilities/strategy-helpers/blue-green-helper'
import { getManifestFiles } from '../utilities/strategy-helpers/deployment-helper'
export async function reject(ignoreSslErrors?: boolean) {
const kubectl = new Kubectl(await utils.getKubectl(), TaskInputParameters.namespace, ignoreSslErrors);
export async function reject() {
const kubectl = new Kubectl(await utils.getKubectl(), TaskInputParameters.namespace, true);
if (!canaryDeploymentHelper.isCanaryDeploymentStrategy()) {
core.debug('Strategy is not canary deployment. Invalid request.');
throw ('InvalidRejectActionDeploymentStrategy');
if (canaryDeploymentHelper.isCanaryDeploymentStrategy()) {
await rejectCanary(kubectl);
} else if (isBlueGreenDeploymentStrategy()) {
await rejectBlueGreen(kubectl);
} else {
core.debug('Strategy is not canary or blue-green deployment. Invalid request.');
throw ('InvalidDeletetActionDeploymentStrategy');
}
}
async function rejectCanary(kubectl: Kubectl) {
let includeServices = false;
if (canaryDeploymentHelper.isSMICanaryStrategy()) {
core.debug('Reject deployment with SMI canary strategy');
@@ -23,4 +34,15 @@ export async function reject(ignoreSslErrors?: boolean) {
core.debug('Deployment strategy selected is Canary. Deleting baseline and canary workloads.');
canaryDeploymentHelper.deleteCanaryDeployment(kubectl, TaskInputParameters.manifests, includeServices);
}
async function rejectBlueGreen(kubectl: Kubectl) {
let inputManifestFiles: string[] = getManifestFiles(TaskInputParameters.manifests);
if(isIngressRoute()) {
await rejectBlueGreenIngress(kubectl, inputManifestFiles);
} else if (isSMIRoute()) {
await rejectBlueGreenSMI(kubectl, inputManifestFiles);
} else {
await rejectBlueGreenService(kubectl, inputManifestFiles);
}
}