Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(svc): Add predictorSpec annotations to service #2618

Merged
merged 1 commit into from
Feb 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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