Traffic split annotations - canary deployment

This commit is contained in:
Vidya Reddy 2022-07-18 16:20:06 +05:30
parent 9f25026d56
commit 0e57c19ffe
5 changed files with 13 additions and 8 deletions

View File

@ -74,7 +74,7 @@ export async function rejectBlueGreenSMI(
// get all kubernetes objects defined in manifest files // get all kubernetes objects defined in manifest files
const manifestObjects: BlueGreenManifests = getManifestObjects(filePaths) const manifestObjects: BlueGreenManifests = getManifestObjects(filePaths)
// route trafficsplit to stable deploymetns // route trafficsplit to stable deployments
await routeBlueGreenSMI( await routeBlueGreenSMI(
kubectl, kubectl,
NONE_LABEL_VALUE, NONE_LABEL_VALUE,

View File

@ -77,9 +77,10 @@ export function getNewCanaryResource(
export async function fetchResource( export async function fetchResource(
kubectl: Kubectl, kubectl: Kubectl,
kind: string, kind: string,
name: string name: string,
annotations: {[key: string] : string} = {}
) { ) {
const result = await kubectl.getResource(kind, name) const result = await kubectl.getResource(kind, name, annotations)
if (!result || result?.stderr) { if (!result || result?.stderr) {
return null return null

View File

@ -25,12 +25,14 @@ export async function deploySMICanary(filePaths: string[], kubectl: Kubectl) {
yaml.safeLoadAll(fileContents, (inputObject) => { yaml.safeLoadAll(fileContents, (inputObject) => {
const name = inputObject.metadata.name const name = inputObject.metadata.name
const kind = inputObject.kind const kind = inputObject.kind
const annotations = inputObject.metadata.annotations
if (isDeploymentEntity(kind)) { if (isDeploymentEntity(kind)) {
const stableObject = canaryDeploymentHelper.fetchResource( const stableObject = canaryDeploymentHelper.fetchResource(
kubectl, kubectl,
kind, kind,
name name,
annotations
) )
if (!stableObject) { if (!stableObject) {

View File

@ -289,12 +289,13 @@ describe('Kubectl class', () => {
it('gets resource', async () => { it('gets resource', async () => {
const resourceType = 'type' const resourceType = 'type'
const name = 'name' const name = 'name'
expect(await kubectl.getResource(resourceType, name)).toBe(execReturn) const annotations: {[key: string] : string} = {}
expect(await kubectl.getResource(resourceType, name, annotations)).toBe(execReturn)
expect(exec.getExecOutput).toBeCalledWith( expect(exec.getExecOutput).toBeCalledWith(
kubectlPath, kubectlPath,
[ [
'get', 'get',
`${resourceType}/${name}`, `${resourceType}/${name}/${annotations}`,
'-o', '-o',
'json', 'json',
'--namespace', '--namespace',

View File

@ -135,11 +135,12 @@ export class Kubectl {
public async getResource( public async getResource(
resourceType: string, resourceType: string,
name: string name: string,
annotations: {[key: string] : string} = {}
): Promise<ExecOutput> { ): Promise<ExecOutput> {
return await this.execute([ return await this.execute([
'get', 'get',
`${resourceType}/${name}`, `${resourceType}/${name}/${annotations}`,
'-o', '-o',
'json' 'json'
]) ])