Skip to content

Commit fee2e07

Browse files
committed
chore: fix OpenShift 3 tests by using previously removed Pod generator
Previous change f6cd596 removed the Pod generator from tests. However, generators in kubectl 1.11 (the OpenShift version) default to applying Deployments instead of Pods. Restore the Pod generator only for OpenShift 3 tests.
1 parent aa2ab5c commit fee2e07

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/helpers/kubectl.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,17 @@ export async function applyK8sYaml(pathToYamlDeployment: string, namespace?: str
8989

9090
export async function createPodFromImage(name: string, image: string, namespace: string) {
9191
console.log(`Letting Kubernetes decide how to manage image ${image} with name ${name}`);
92-
await exec(`./kubectl run ${name} --image=${image} -n ${namespace} -- sleep 999999999`);
92+
/**
93+
* HACK! The newest version of kubectl does not support generators. However, "OpenShift 3" tests run on K8s 1.11 which supports generators.
94+
* The default behaviour there is to create a Deployment, whereas new versions of kubectl create Pods.
95+
* We can't use the default behaviour for both OpenShift 3 and other tests, because we would get different results.
96+
* Hence we need to specifically select the Pod generator on OS3 but it would default to Pod on anything else.
97+
*/
98+
const generator =
99+
process.env['TEST_PLATFORM'] === 'openshift3'
100+
? '--generator=run-pod/v1'
101+
: '';
102+
await exec(`./kubectl run ${name} ${generator} --image=${image} -n ${namespace} -- sleep 999999999`);
93103
console.log(`Done Letting Kubernetes decide how to manage image ${image} with name ${name}`);
94104
}
95105

0 commit comments

Comments
 (0)