use of org.ballerinax.kubernetes.handlers.istio.IstioGatewayHandler in project kubernetes by ballerinax.
the class ArtifactManager method createArtifacts.
/**
* Generate kubernetes artifacts.
*
* @throws KubernetesPluginException if an error occurs while generating artifacts
*/
void createArtifacts() throws KubernetesPluginException {
// add default kubernetes instructions.
setDefaultKubernetesInstructions();
OUT.println("\nGenerating artifacts...");
if (kubernetesDataHolder.getJobModel() != null) {
new JobHandler().createArtifacts();
new DockerHandler().createArtifacts();
} else {
new ServiceHandler().createArtifacts();
new IngressHandler().createArtifacts();
new SecretHandler().createArtifacts();
new PersistentVolumeClaimHandler().createArtifacts();
new ResourceQuotaHandler().createArtifacts();
new ConfigMapHandler().createArtifacts();
new DeploymentHandler().createArtifacts();
new HPAHandler().createArtifacts();
new DockerHandler().createArtifacts();
new HelmChartHandler().createArtifacts();
new IstioGatewayHandler().createArtifacts();
new IstioVirtualServiceHandler().createArtifacts();
if (kubernetesDataHolder.getOpenShiftBuildExtensionModel() != null || kubernetesDataHolder.getOpenShiftRouteModels().size() > 0) {
// Clean all instructions
instructions.clear();
new OpenShiftBuildConfigHandler().createArtifacts();
new OpenShiftImageStreamHandler().createArtifacts();
new OpenShiftRouteHandler().createArtifacts();
}
}
printInstructions();
}
use of org.ballerinax.kubernetes.handlers.istio.IstioGatewayHandler in project kubernetes by ballerinax.
the class IstioGatewayGeneratorTests method testSimpleGateway.
@Test
public void testSimpleGateway() {
IstioGatewayModel istioGatewayModel = new IstioGatewayModel();
istioGatewayModel.setName("my-gateway");
Map<String, String> selectors = new LinkedHashMap<>();
selectors.put(KubernetesConstants.KUBERNETES_SELECTOR_KEY, "my-gatweway-controller");
istioGatewayModel.setSelector(selectors);
List<IstioServerModel> serverModels = new LinkedList<>();
// First server
IstioServerModel serverModel = new IstioServerModel();
IstioPortModel portModel = new IstioPortModel();
portModel.setNumber(80);
portModel.setProtocol("HTTP");
portModel.setName("http");
serverModel.setPort(portModel);
List<String> hostModels = new LinkedList<>();
hostModels.add("uk.bookinfo.com");
hostModels.add("eu.bookinfo.com");
serverModel.setHosts(hostModels);
IstioServerModel.TLSOptions tlsOptions = new IstioServerModel.TLSOptions();
tlsOptions.setHttpsRedirect(true);
serverModel.setTls(tlsOptions);
serverModels.add(serverModel);
istioGatewayModel.setServers(serverModels);
dataHolder.addIstioGatewayModel("sample-svc", istioGatewayModel);
try {
new IstioGatewayHandler().createArtifacts();
File gwYaml = dataHolder.getK8sArtifactOutputPath().resolve("hello" + ISTIO_GATEWAY_FILE_POSTFIX + YAML).toFile();
Gateway gateway = Utils.loadYaml(gwYaml);
// metadata
Assert.assertNotNull(gateway.getMetadata());
Assert.assertEquals(gateway.getMetadata().getName(), "my-gateway");
Assert.assertNotNull(gateway.getSpec());
Assert.assertEquals(gateway.getSpec().getSelector().get(KubernetesConstants.KUBERNETES_SELECTOR_KEY), "my-gatweway-controller");
Assert.assertEquals(gateway.getSpec().getServers().size(), 1);
Assert.assertEquals(gateway.getSpec().getServers().get(0).getPort().getNumber().intValue(), 80);
Assert.assertEquals(gateway.getSpec().getServers().get(0).getPort().getProtocol(), "HTTP");
Assert.assertEquals(gateway.getSpec().getServers().get(0).getPort().getName(), "http");
Assert.assertEquals(gateway.getSpec().getServers().get(0).getHosts().size(), 2);
Assert.assertEquals(gateway.getSpec().getServers().get(0).getHosts().get(0), "uk.bookinfo.com");
Assert.assertEquals(gateway.getSpec().getServers().get(0).getHosts().get(1), "eu.bookinfo.com");
Assert.assertNotNull(gateway.getSpec().getServers().get(0).getTls());
Assert.assertTrue(gateway.getSpec().getServers().get(0).getTls().getHttpsRedirect());
gwYaml.deleteOnExit();
} catch (IOException e) {
Assert.fail("Unable to write to file: " + e.getMessage());
} catch (KubernetesPluginException e) {
Assert.fail("Unable to generate yaml: " + e.getMessage());
}
}
Aggregations