Search in sources :

Example 1 with OwnerReference

use of io.kubernetes.client.proto.Meta.OwnerReference in project seldon-core by SeldonIO.

the class SeldonDeploymentOperatorImpl method createResources.

@Override
public DeploymentResources createResources(SeldonDeployment mlDep) throws SeldonDeploymentException {
    OwnerReference ownerRef = getOwnerReference(mlDep);
    List<Deployment> deployments = new ArrayList<>();
    // for each predictor Create/replace deployment
    String serviceLabel = mlDep.getSpec().getName();
    for (PredictorSpec p : mlDep.getSpec().getPredictorsList()) {
        String depName = getKubernetesDeploymentName(mlDep.getSpec().getName(), p.getName());
        PodTemplateSpec.Builder podSpecBuilder = PodTemplateSpec.newBuilder(p.getComponentSpec());
        podSpecBuilder.getSpecBuilder().addContainers(createEngineContainer(mlDep, p)).setTerminationGracePeriodSeconds(20);
        podSpecBuilder.getMetadataBuilder().putAnnotations("prometheus.io/path", "/prometheus").putAnnotations("prometheus.io/port", "" + clusterManagerProperites.getEngineContainerPort()).putAnnotations("prometheus.io/scrape", "true");
        Deployment deployment = V1beta1Extensions.Deployment.newBuilder().setMetadata(ObjectMeta.newBuilder().setName(depName).putLabels(SeldonDeploymentOperatorImpl.LABEL_SELDON_APP, serviceLabel).putLabels(Constants.LABEL_SELDON_ID, mlDep.getSpec().getName()).putLabels("app", depName).putLabels("version", // FIXME
        "v1").putLabels(SeldonDeploymentOperatorImpl.LABEL_SELDON_TYPE_KEY, SeldonDeploymentOperatorImpl.LABEL_SELDON_TYPE_VAL).addOwnerReferences(ownerRef)).setSpec(DeploymentSpec.newBuilder().setTemplate(podSpecBuilder.build()).setStrategy(DeploymentStrategy.newBuilder().setRollingUpdate(RollingUpdateDeployment.newBuilder().setMaxUnavailable(IntOrString.newBuilder().setType(1).setStrVal("10%")))).setReplicas(p.getReplicas())).build();
        deployments.add(deployment);
    }
    final String serviceName = mlDep.getSpec().getName();
    Service s = Service.newBuilder().setMetadata(ObjectMeta.newBuilder().setName(serviceName).putLabels(SeldonDeploymentOperatorImpl.LABEL_SELDON_APP, serviceLabel).putLabels("seldon-deployment-id", mlDep.getSpec().getName()).addOwnerReferences(ownerRef).putAnnotations("getambassador.io/config", getAmbassadorAnnotation(mlDep, serviceName))).setSpec(ServiceSpec.newBuilder().addPorts(ServicePort.newBuilder().setProtocol("TCP").setPort(clusterManagerProperites.getEngineContainerPort()).setTargetPort(IntOrString.newBuilder().setIntVal(clusterManagerProperites.getEngineContainerPort())).setName("http")).addPorts(ServicePort.newBuilder().setProtocol("TCP").setPort(clusterManagerProperites.getEngineGrpcContainerPort()).setTargetPort(IntOrString.newBuilder().setIntVal(clusterManagerProperites.getEngineGrpcContainerPort())).setName("grpc")).setType("ClusterIP").putSelector(SeldonDeploymentOperatorImpl.LABEL_SELDON_APP, serviceLabel)).build();
    // Create service for deployment
    return new DeploymentResources(deployments, s);
}
Also used : V1OwnerReference(io.kubernetes.client.models.V1OwnerReference) OwnerReference(io.kubernetes.client.proto.Meta.OwnerReference) PodTemplateSpec(io.kubernetes.client.proto.V1.PodTemplateSpec) ArrayList(java.util.ArrayList) SeldonDeployment(io.seldon.protos.DeploymentProtos.SeldonDeployment) Deployment(io.kubernetes.client.proto.V1beta1Extensions.Deployment) RollingUpdateDeployment(io.kubernetes.client.proto.V1beta1Extensions.RollingUpdateDeployment) Service(io.kubernetes.client.proto.V1.Service) IntOrString(io.kubernetes.client.proto.IntStr.IntOrString) PredictorSpec(io.seldon.protos.DeploymentProtos.PredictorSpec)

Aggregations

V1OwnerReference (io.kubernetes.client.models.V1OwnerReference)1 IntOrString (io.kubernetes.client.proto.IntStr.IntOrString)1 OwnerReference (io.kubernetes.client.proto.Meta.OwnerReference)1 PodTemplateSpec (io.kubernetes.client.proto.V1.PodTemplateSpec)1 Service (io.kubernetes.client.proto.V1.Service)1 Deployment (io.kubernetes.client.proto.V1beta1Extensions.Deployment)1 RollingUpdateDeployment (io.kubernetes.client.proto.V1beta1Extensions.RollingUpdateDeployment)1 PredictorSpec (io.seldon.protos.DeploymentProtos.PredictorSpec)1 SeldonDeployment (io.seldon.protos.DeploymentProtos.SeldonDeployment)1 ArrayList (java.util.ArrayList)1