Skip to content

Commit

Permalink
feat(svc): Add predictorSpec annotations to service
Browse files Browse the repository at this point in the history
Capture predictorSpec annotations and apply them to the created
services.

Contributes to SeldonIO#2590

Signed-off-by: Nick Groszewski <groszewn@gmail.com>
  • Loading branch information
groszewn committed Nov 16, 2020
1 parent b5e64ad commit f0494f0
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions operator/controllers/seldondeployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ func createPredictorService(pSvcName string, seldonId string, p *machinelearning
machinelearningv1.Label_seldon_id: seldonId,
machinelearningv1.Label_managed_by: machinelearningv1.Label_value_seldon,
},
Annotations: map[string]string{},
},
Spec: corev1.ServiceSpec{
Selector: map[string]string{machinelearningv1.Label_seldon_app: pSvcName},
Expand All @@ -677,7 +678,6 @@ func createPredictorService(pSvcName string, seldonId string, p *machinelearning
}

if utils.GetEnv("AMBASSADOR_ENABLED", "false") == "true" {
psvc.Annotations = make(map[string]string)
//Create top level Service
ambassadorConfig, err := getAmbassadorConfigs(mlDep, p, pSvcName, engine_http_port, engine_grpc_port, isExplainer)
if err != nil {
Expand All @@ -689,6 +689,10 @@ func createPredictorService(pSvcName string, seldonId string, p *machinelearning
log.Info("Creating Headless SVC")
psvc.Spec.ClusterIP = "None"
}
// Add annotations from predictorspec
for k, v := range p.Annotations {
psvc.Annotations[k] = v
}
return psvc, err
}

Expand Down Expand Up @@ -716,9 +720,10 @@ func createContainerService(deploy *appsv1.Deployment,

svc := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: containerServiceValue,
Namespace: namespace,
Labels: map[string]string{containerServiceKey: containerServiceValue, machinelearningv1.Label_seldon_id: seldonId},
Name: containerServiceValue,
Namespace: namespace,
Labels: map[string]string{containerServiceKey: containerServiceValue, machinelearningv1.Label_seldon_id: seldonId},
Annotations: map[string]string{},
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
Expand Down Expand Up @@ -753,6 +758,11 @@ func createContainerService(deploy *appsv1.Deployment,
con.Ports = append(con.Ports, corev1.ContainerPort{Name: "grpc", ContainerPort: pu.Endpoint.GrpcPort, Protocol: corev1.ProtocolTCP})
}

// Add annotations from predictorspec
for k, v := range p.Annotations {
svc.Annotations[k] = v
}

// Backwards compatible additions. From 1.5.0 onwards could always call httpPort as both should be available but for
// previously wrapped components need to look at transport.
// TODO: deprecate and just call httpPort
Expand Down

0 comments on commit f0494f0

Please sign in to comment.