use of org.ballerinax.kubernetes.models.EnvVarValueModel in project kubernetes by ballerinax.
the class KubernetesDeploymentGeneratorTests method testDeploymentGeneration.
@Test
public void testDeploymentGeneration() {
DeploymentModel deploymentModel = new DeploymentModel();
deploymentModel.setName(deploymentName);
Map<String, String> labels = new HashMap<>();
labels.put(KubernetesConstants.KUBERNETES_SELECTOR_KEY, selector);
deploymentModel.addPort(9090);
deploymentModel.addPort(9091);
deploymentModel.addPort(9092);
deploymentModel.setLabels(labels);
deploymentModel.setImage(imageName);
deploymentModel.setImagePullPolicy(imagePullPolicy);
ProbeModel probeModel = new ProbeModel();
probeModel.setPort(9090);
deploymentModel.setLivenessProbe(probeModel);
deploymentModel.setSingleYAML(false);
Map<String, EnvVarValueModel> env = new HashMap<>();
EnvVarValueModel testEnvVar = new EnvVarValueModel("ENV");
env.put("ENV_VAR", testEnvVar);
deploymentModel.setEnv(env);
deploymentModel.setReplicas(replicas);
dataHolder.setDeploymentModel(deploymentModel);
try {
new DeploymentHandler().createArtifacts();
File tempFile = dataHolder.getK8sArtifactOutputPath().resolve("hello_deployment.yaml").toFile();
Assert.assertTrue(tempFile.exists());
testGeneratedYAML(tempFile);
tempFile.deleteOnExit();
} catch (IOException e) {
Assert.fail("Unable to write to file");
} catch (KubernetesPluginException e) {
Assert.fail("Unable to generate yaml from service");
}
}
use of org.ballerinax.kubernetes.models.EnvVarValueModel in project kubernetes by ballerinax.
the class KubernetesJobGeneratorTests method testDeploymentGeneration.
@Test
public void testDeploymentGeneration() {
JobModel jobModel = new JobModel();
jobModel.setName(jobName);
Map<String, String> labels = new HashMap<>();
labels.put(KubernetesConstants.KUBERNETES_SELECTOR_KEY, selector);
jobModel.setLabels(labels);
jobModel.setImage(imageName);
jobModel.setImagePullPolicy(imagePullPolicy);
jobModel.setSingleYAML(false);
Map<String, EnvVarValueModel> env = new HashMap<>();
EnvVarValueModel testEnvVar = new EnvVarValueModel("ENV");
env.put("ENV_VAR", testEnvVar);
jobModel.setEnv(env);
dataHolder.setJobModel(jobModel);
try {
new JobHandler().createArtifacts();
File tempFile = dataHolder.getK8sArtifactOutputPath().resolve("hello_job.yaml").toFile();
Assert.assertTrue(tempFile.exists());
assertGeneratedYAML(tempFile);
tempFile.deleteOnExit();
} catch (IOException e) {
Assert.fail("Unable to write to file");
} catch (KubernetesPluginException e) {
Assert.fail("Unable to generate yaml from service");
}
}
Aggregations