Search in sources :

Example 1 with ContainerBasedGatewayTemplateBuilder

use of org.wso2.carbon.apimgt.core.template.ContainerBasedGatewayTemplateBuilder in project carbon-apimgt by wso2.

the class KubernetesGatewayImpl method createContainerGateway.

/**
 * @see ContainerBasedGatewayGenerator#createContainerGateway(String, API)
 */
@Override
public void createContainerGateway(String label, API api) throws ContainerBasedGatewayException {
    Map<String, String> templateValues = new HashMap<>();
    String serviceName = label + ContainerBasedGatewayConstants.CMS_SERVICE_SUFFIX;
    String deploymentName = label + ContainerBasedGatewayConstants.CMS_DEPLOYMENT_SUFFIX;
    String ingressName = label + ContainerBasedGatewayConstants.CMS_INGRESS_SUFFIX;
    templateValues.put(ContainerBasedGatewayConstants.NAMESPACE, namespace);
    templateValues.put(ContainerBasedGatewayConstants.GATEWAY_LABEL, label);
    templateValues.put(ContainerBasedGatewayConstants.SERVICE_NAME, serviceName);
    templateValues.put(ContainerBasedGatewayConstants.DEPLOYMENT_NAME, deploymentName);
    templateValues.put(ContainerBasedGatewayConstants.INGRESS_NAME, ingressName);
    templateValues.put(ContainerBasedGatewayConstants.CONTAINER_NAME, label + ContainerBasedGatewayConstants.CMS_CONTAINER_SUFFIX);
    templateValues.put(ContainerBasedGatewayConstants.API_CORE_URL, apiCoreUrl);
    templateValues.put(ContainerBasedGatewayConstants.BROKER_HOST, brokerHost);
    templateValues.put(ContainerBasedGatewayConstants.GATEWAY_HOSTNAME, generateSubDomain(api) + "." + gatewayHostname);
    ContainerBasedGatewayTemplateBuilder builder = new ContainerBasedGatewayTemplateBuilder();
    // Create gateway service resource
    createServiceResource(builder.generateTemplate(templateValues, ContainerBasedGatewayConstants.GATEWAY_SERVICE_TEMPLATE), serviceName);
    // Create gateway deployment resource
    createDeploymentResource(builder.generateTemplate(templateValues, ContainerBasedGatewayConstants.GATEWAY_DEPLOYMENT_TEMPLATE), deploymentName);
    // Create gateway ingress resource
    createIngressResource(builder.generateTemplate(templateValues, ContainerBasedGatewayConstants.GATEWAY_INGRESS_TEMPLATE), ingressName);
}
Also used : HashMap(java.util.HashMap) ContainerBasedGatewayTemplateBuilder(org.wso2.carbon.apimgt.core.template.ContainerBasedGatewayTemplateBuilder)

Aggregations

HashMap (java.util.HashMap)1 ContainerBasedGatewayTemplateBuilder (org.wso2.carbon.apimgt.core.template.ContainerBasedGatewayTemplateBuilder)1