use of org.ballerinax.kubernetes.models.knative.ServiceModel 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);
}
}
use of org.ballerinax.kubernetes.models.knative.ServiceModel in project kubernetes by ballerinax.
the class KnativeServiceAnnotationProcessor method processAnnotation.
@Override
public void processAnnotation(SimpleVariableNode variableNode, AnnotationAttachmentNode attachmentNode) throws KubernetesPluginException {
ServiceModel serviceModel = processService(attachmentNode);
if (KnativeUtils.isBlank(serviceModel.getName())) {
serviceModel.setName(KnativeUtils.getValidName(variableNode.getName().getValue()) + KNATIVE_SVC_POSTFIX);
}
// If service annotation port is not empty, then listener port is used for the k8s svc target port while
// service annotation port is used for k8s port.
// If service annotation port is empty, then listener port is used for both port and target port of the k8s
// svc.
BLangTypeInit bListener = (BLangTypeInit) ((BLangSimpleVariable) variableNode).expr;
if (serviceModel.getPort() == 8080) {
serviceModel.addPort(extractPort(bListener));
}
}
Aggregations