Search in sources :

Example 1 with DockerGenException

use of org.ballerinax.docker.generator.exceptions.DockerGenException in project kubernetes by ballerinax.

the class DeploymentHandler method createArtifacts.

@Override
public void createArtifacts() throws KubernetesPluginException {
    try {
        DeploymentModel deploymentModel = dataHolder.getDeploymentModel();
        deploymentModel.setPodAutoscalerModel(dataHolder.getPodAutoscalerModel());
        deploymentModel.setSecretModels(dataHolder.getSecretModelSet());
        deploymentModel.setConfigMapModels(dataHolder.getConfigMapModelSet());
        deploymentModel.setVolumeClaimModels(dataHolder.getVolumeClaimModelSet());
        if (null != deploymentModel.getLivenessProbe() && deploymentModel.getLivenessProbe().getPort() == 0) {
            // set first port as liveness port
            if (deploymentModel.getPorts().size() == 0) {
                throw new KubernetesPluginException("unable to detect port for liveness probe." + "missing @kubernetes:Service annotation on listener.");
            }
            deploymentModel.getLivenessProbe().setPort(deploymentModel.getPorts().iterator().next());
        }
        if (null != deploymentModel.getReadinessProbe() && deploymentModel.getReadinessProbe().getPort() == 0) {
            // set first port as readiness port
            if (deploymentModel.getPorts().size() == 0) {
                throw new KubernetesPluginException("unable to detect port for readiness probe. " + "missing @kubernetes:Service annotation on listener.");
            }
            deploymentModel.getReadinessProbe().setPort(deploymentModel.getPorts().iterator().next());
        }
        generate(deploymentModel);
        OUT.println();
        OUT.print("\t@kubernetes:Deployment \t\t\t - complete 1/1");
        dataHolder.setDockerModel(getDockerModel(deploymentModel));
    } catch (DockerGenException e) {
        throw new KubernetesPluginException("error occurred creating docker image.", e);
    }
}
Also used : DockerGenException(org.ballerinax.docker.generator.exceptions.DockerGenException) DeploymentModel(org.ballerinax.kubernetes.models.DeploymentModel) KubernetesPluginException(org.ballerinax.kubernetes.exceptions.KubernetesPluginException)

Example 2 with DockerGenException

use of org.ballerinax.docker.generator.exceptions.DockerGenException in project kubernetes by ballerinax.

the class JobHandler method createArtifacts.

@Override
public void createArtifacts() throws KubernetesPluginException {
    try {
        String balxFileName = extractJarName(dataHolder.getUberJarPath());
        JobModel jobModel = dataHolder.getJobModel();
        if (isBlank(jobModel.getName())) {
            jobModel.setName(getValidName(balxFileName) + JOB_POSTFIX);
        }
        if (isBlank(jobModel.getImage())) {
            jobModel.setImage(balxFileName + DOCKER_LATEST_TAG);
        }
        jobModel.addLabel(KubernetesConstants.KUBERNETES_SELECTOR_KEY, balxFileName);
        generate(jobModel);
        // generate dockerfile and docker image
        dataHolder.setDockerModel(getDockerModel(jobModel));
        OUT.println();
        OUT.print("\t@kubernetes:Job \t\t\t - complete 1/1");
    } catch (DockerGenException e) {
        throw new KubernetesPluginException("error occurred creating docker image.", e);
    }
}
Also used : DockerGenException(org.ballerinax.docker.generator.exceptions.DockerGenException) JobModel(org.ballerinax.kubernetes.models.JobModel) KubernetesPluginException(org.ballerinax.kubernetes.exceptions.KubernetesPluginException)

Example 3 with DockerGenException

use of org.ballerinax.docker.generator.exceptions.DockerGenException in project kubernetes by ballerinax.

the class DockerHandler method createArtifacts.

@Override
public void createArtifacts() throws KubernetesPluginException {
    try {
        // Generate docker artifacts
        DockerArtifactHandler dockerArtifactHandler = new DockerArtifactHandler(dataHolder.getDockerModel());
        OUT.println();
        dockerArtifactHandler.createArtifacts(OUT, "\t@kubernetes:Docker \t\t\t", dataHolder.getUberJarPath(), dataHolder.getDockerArtifactOutputPath());
    } catch (DockerGenException e) {
        throw new KubernetesPluginException(e.getMessage(), e);
    }
}
Also used : DockerGenException(org.ballerinax.docker.generator.exceptions.DockerGenException) DockerArtifactHandler(org.ballerinax.docker.generator.DockerArtifactHandler) KubernetesPluginException(org.ballerinax.kubernetes.exceptions.KubernetesPluginException)

Example 4 with DockerGenException

use of org.ballerinax.docker.generator.exceptions.DockerGenException in project kubernetes by ballerinax.

the class KnativeDockerHandler method createArtifacts.

@Override
public void createArtifacts() throws KubernetesPluginException {
    try {
        // Generate docker artifacts
        DockerArtifactHandler dockerArtifactHandler = new DockerArtifactHandler(knativeDataHolder.getDockerModel());
        OUT.println();
        dockerArtifactHandler.createArtifacts(OUT, "\t@knative:Docker \t\t\t", knativeDataHolder.getUberJarPath(), knativeDataHolder.getDockerArtifactOutputPath());
    } catch (DockerGenException e) {
        throw new KubernetesPluginException(e.getMessage(), e);
    }
}
Also used : DockerGenException(org.ballerinax.docker.generator.exceptions.DockerGenException) DockerArtifactHandler(org.ballerinax.docker.generator.DockerArtifactHandler) KubernetesPluginException(org.ballerinax.kubernetes.exceptions.KubernetesPluginException)

Example 5 with DockerGenException

use of org.ballerinax.docker.generator.exceptions.DockerGenException in project kubernetes by ballerinax.

the class KnativeServiceHandler method createArtifacts.

@Override
public void createArtifacts() throws KubernetesPluginException {
    try {
        ServiceModel serviceModel = knativeDataHolder.getServiceModel();
        serviceModel.setPodAutoscalerModel(knativeDataHolder.getPodAutoscalerModel());
        serviceModel.setSecretModels(knativeDataHolder.getSecretModelSet());
        serviceModel.setConfigMapModels(knativeDataHolder.getConfigMapModelSet());
        if (null != serviceModel.getLivenessProbe() && serviceModel.getLivenessProbe().getPort() == 0) {
            // set first port as liveness port
            serviceModel.getLivenessProbe().setPort(serviceModel.getPorts().iterator().next());
        }
        if (null != serviceModel.getReadinessProbe() && serviceModel.getReadinessProbe().getPort() == 0) {
            // set first port as readiness port
            serviceModel.getReadinessProbe().setPort(serviceModel.getPorts().iterator().next());
        }
        generate(serviceModel);
        OUT.println();
        OUT.print("\t@knative:Service \t\t\t - complete 1/1");
        knativeDataHolder.setDockerModel(getDockerModel(serviceModel));
    } catch (DockerGenException e) {
        throw new KubernetesPluginException("error occurred creating docker image.", e);
    }
}
Also used : DockerGenException(org.ballerinax.docker.generator.exceptions.DockerGenException) ServiceModel(org.ballerinax.kubernetes.models.knative.ServiceModel) KubernetesPluginException(org.ballerinax.kubernetes.exceptions.KubernetesPluginException)

Aggregations

DockerGenException (org.ballerinax.docker.generator.exceptions.DockerGenException)5 KubernetesPluginException (org.ballerinax.kubernetes.exceptions.KubernetesPluginException)5 DockerArtifactHandler (org.ballerinax.docker.generator.DockerArtifactHandler)2 DeploymentModel (org.ballerinax.kubernetes.models.DeploymentModel)1 JobModel (org.ballerinax.kubernetes.models.JobModel)1 ServiceModel (org.ballerinax.kubernetes.models.knative.ServiceModel)1