diff --git a/README.md b/README.md
index c99d521e5..b1912736e 100644
--- a/README.md
+++ b/README.md
@@ -113,6 +113,10 @@ Following are the key capabilities of this action:
force (Optional) |
Deploy when a previous deployment already exists. If true then '--force' argument is added to the apply command. Using '--force' argument is not recommended in production. |
+
+ server-side (Optional) |
+ The apply command runs in the server instead of the client. If true then '--server-side' argument is added to the apply command. |
+
annotate-resources(Optional) |
Acceptable values: true/falseDefault value: trueSwitch whether to annotate the resources or not. If set to false all annotations are skipped completely. |
diff --git a/action.yml b/action.yml
index e391809c8..ac04ab893 100644
--- a/action.yml
+++ b/action.yml
@@ -55,6 +55,10 @@ inputs:
description: 'Deploy when a previous deployment already exists. If true then --force argument is added to the apply command'
required: false
default: false
+ server-side:
+ description: 'The apply command runs in the server instead of the client. If true then --server-side argument is added to the apply command.'
+ required: false
+ default: false
token:
description: 'Github token'
default: ${{ github.token }}
diff --git a/src/strategyHelpers/canary/podCanaryHelper.ts b/src/strategyHelpers/canary/podCanaryHelper.ts
index 1dc94ab35..50f6df0a7 100644
--- a/src/strategyHelpers/canary/podCanaryHelper.ts
+++ b/src/strategyHelpers/canary/podCanaryHelper.ts
@@ -71,8 +71,9 @@ export async function deployPodCanary(
core.debug('New objects list: ' + JSON.stringify(newObjectsList))
const manifestFiles = fileHelper.writeObjectsToFile(newObjectsList)
const forceDeployment = core.getInput('force').toLowerCase() === 'true'
+ const serverSideDeployment = core.getInput('server-side').toLowerCase() === 'true'
- const execResult = await kubectl.apply(manifestFiles, forceDeployment)
+ const execResult = await kubectl.apply(manifestFiles, forceDeployment, serverSideDeployment)
return {execResult, manifestFiles}
}
diff --git a/src/strategyHelpers/canary/smiCanaryHelper.ts b/src/strategyHelpers/canary/smiCanaryHelper.ts
index 0daca1d21..2f451f93e 100644
--- a/src/strategyHelpers/canary/smiCanaryHelper.ts
+++ b/src/strategyHelpers/canary/smiCanaryHelper.ts
@@ -97,7 +97,8 @@ export async function deploySMICanary(
)
const newFilePaths = fileHelper.writeObjectsToFile(newObjectsList)
const forceDeployment = core.getInput('force').toLowerCase() === 'true'
- const result = await kubectl.apply(newFilePaths, forceDeployment)
+ const serverSideDeployment = core.getInput('server-side').toLowerCase() === 'true'
+ const result = await kubectl.apply(newFilePaths, forceDeployment, serverSideDeployment)
const svcDeploymentFiles = await createCanaryService(kubectl, filePaths)
newFilePaths.push(...svcDeploymentFiles)
return {execResult: result, manifestFiles: newFilePaths}
@@ -192,8 +193,9 @@ async function createCanaryService(
const manifestFiles = fileHelper.writeObjectsToFile(newObjectsList)
manifestFiles.push(...trafficObjectsList)
const forceDeployment = core.getInput('force').toLowerCase() === 'true'
+ const serverSideDeployment = core.getInput('server-side').toLowerCase() === 'true'
- const result = await kubectl.apply(manifestFiles, forceDeployment)
+ const result = await kubectl.apply(manifestFiles, forceDeployment, server-side)
checkForErrors([result])
return manifestFiles
}
@@ -249,7 +251,8 @@ async function adjustTraffic(
}
const forceDeployment = core.getInput('force').toLowerCase() === 'true'
- const result = await kubectl.apply(trafficSplitManifests, forceDeployment)
+ const serverSideDeployment = core.getInput('server-side').toLowerCase() === 'true'
+ const result = await kubectl.apply(trafficSplitManifests, forceDeployment, serverSideDeployment)
checkForErrors([result])
return trafficSplitManifests
}
diff --git a/src/strategyHelpers/deploymentHelper.ts b/src/strategyHelpers/deploymentHelper.ts
index 3a3d5e3a0..c8ab6fc80 100644
--- a/src/strategyHelpers/deploymentHelper.ts
+++ b/src/strategyHelpers/deploymentHelper.ts
@@ -89,16 +89,18 @@ export async function deployManifests(
)
const forceDeployment = core.getInput('force').toLowerCase() === 'true'
+ const serverSideDeployment = core.getInput('server-side').toLowerCase() === 'true'
if (trafficSplitMethod === TrafficSplitMethod.SMI) {
const updatedManifests = appendStableVersionLabelToResource(files)
const result = await kubectl.apply(
updatedManifests,
- forceDeployment
+ forceDeployment,
+ serverSideDeployment
)
checkForErrors([result])
} else {
- const result = await kubectl.apply(files, forceDeployment)
+ const result = await kubectl.apply(files, forceDeployment, serverSideDeployment)
checkForErrors([result])
}
diff --git a/src/types/kubectl.test.ts b/src/types/kubectl.test.ts
index 352a36cbf..3ff0e49cf 100644
--- a/src/types/kubectl.test.ts
+++ b/src/types/kubectl.test.ts
@@ -90,7 +90,7 @@ describe('Kubectl class', () => {
it('applies a configuration with force when specified', async () => {
const configPaths = ['configPath1', 'configPath2', 'configPath3']
- const result = await kubectl.apply(configPaths, true)
+ const result = await kubectl.apply(configPaths, true, false)
expect(result).toBe(execReturn)
expect(exec.getExecOutput).toBeCalledWith(
kubectlPath,
@@ -106,6 +106,24 @@ describe('Kubectl class', () => {
)
})
+ it('applies a configuration with server-side when specified', async () => {
+ const configPaths = ['configPath1', 'configPath2', 'configPath3']
+ const result = await kubectl.apply(configPaths, false, true)
+ expect(result).toBe(execReturn)
+ expect(exec.getExecOutput).toBeCalledWith(
+ kubectlPath,
+ [
+ 'apply',
+ '-f',
+ configPaths[0] + ',' + configPaths[1] + ',' + configPaths[2],
+ '--server-side',
+ '--namespace',
+ testNamespace
+ ],
+ {silent: false}
+ )
+ })
+
it('describes a resource', async () => {
const resourceType = 'type'
const resourceName = 'name'
diff --git a/src/types/kubectl.ts b/src/types/kubectl.ts
index c096c77e1..fba29a3a0 100644
--- a/src/types/kubectl.ts
+++ b/src/types/kubectl.ts
@@ -34,7 +34,8 @@ export class Kubectl {
public async apply(
configurationPaths: string | string[],
- force: boolean = false
+ force: boolean = false,
+ serverSide: boolean = false,
): Promise {
try {
if (!configurationPaths || configurationPaths?.length === 0)
@@ -46,6 +47,7 @@ export class Kubectl {
createInlineArray(configurationPaths)
]
if (force) applyArgs.push('--force')
+ if (serverSide) applyArgs.push('--server-side')
return await this.execute(applyArgs.concat(this.getFlags()))
} catch (err) {