use of me.snowdrop.istio.api.networking.v1alpha3.VirtualServiceBuilder in project kubernetes by ballerinax.
the class IstioVirtualServiceHandler method generate.
/**
* Generate artifact for istio virtual service model.
*
* @param serviceName The name of the service in which the virtual service routes to.
* @param vsModel The virtual service model.
* @throws KubernetesPluginException Error when writing artifact files.
*/
private void generate(String serviceName, IstioVirtualServiceModel vsModel) throws KubernetesPluginException {
try {
VirtualService virtualService = new VirtualServiceBuilder().withNewMetadata().withName(vsModel.getName()).withNamespace(dataHolder.getNamespace()).withLabels(vsModel.getLabels()).withAnnotations(vsModel.getAnnotations()).endMetadata().withNewSpec().withHosts(vsModel.getHosts()).withGateways(vsModel.getGateways()).withHttp(populateHttp(serviceName, vsModel.getHttp())).endSpec().build();
String gatewayContent = SerializationUtils.dumpWithoutRuntimeStateAsYaml(virtualService);
KubernetesUtils.writeToFile(gatewayContent, ISTIO_VIRTUAL_SERVICE_FILE_POSTFIX + YAML);
} catch (IOException e) {
String errorMessage = "error while generating yaml file for istio virtual service: " + vsModel.getName();
throw new KubernetesPluginException(errorMessage, e);
}
}
Aggregations