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

Feature: support multi hosts in vs #5430

Merged
merged 10 commits into from
Apr 25, 2024
1 change: 1 addition & 0 deletions operator/controllers/istio.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ const (
ANNOTATION_ISTIO_RETRIES = "seldon.io/istio-retries"
ANNOTATION_ISTIO_RETRIES_TIMEOUT = "seldon.io/istio-retries-timeout"
ANNOTATION_ISTIO_HOST = "seldon.io/istio-host"
ANNOTATION_ISTIO_HOST_SEPARATOR = ","
)
2 changes: 1 addition & 1 deletion operator/controllers/seldondeployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func createIstioResources(mlDep *machinelearningv1.SeldonDeployment,
Namespace: namespace,
},
Spec: istio_networking.VirtualService{
Hosts: []string{utils2.GetAnnotation(mlDep, ANNOTATION_ISTIO_HOST, "*")},
Hosts: utils2.GetAnnotations(mlDep, ANNOTATION_ISTIO_HOST, ANNOTATION_ISTIO_HOST_SEPARATOR, "*"),
Gateways: []string{utils2.GetAnnotation(mlDep, ANNOTATION_ISTIO_GATEWAY, istio_gateway)},
Http: []*istio_networking.HTTPRoute{
{
Expand Down
4 changes: 2 additions & 2 deletions operator/controllers/seldondeployment_explainers.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ func createExplainerIstioResources(pSvcName string, p *machinelearningv1.Predict
Namespace: namespace,
},
Spec: istio_networking.VirtualService{
Hosts: []string{utils2.GetAnnotation(mlDep, ANNOTATION_ISTIO_HOST, "*")},
Hosts: utils2.GetAnnotations(mlDep, ANNOTATION_ISTIO_HOST, ANNOTATION_ISTIO_HOST_SEPARATOR, "*"),
Gateways: []string{utils2.GetAnnotation(mlDep, ANNOTATION_ISTIO_GATEWAY, istio_gateway)},
Http: []*istio_networking.HTTPRoute{
{
Expand All @@ -349,7 +349,7 @@ func createExplainerIstioResources(pSvcName string, p *machinelearningv1.Predict
Namespace: namespace,
},
Spec: istio_networking.VirtualService{
Hosts: []string{utils2.GetAnnotation(mlDep, ANNOTATION_ISTIO_HOST, "*")},
Hosts: utils2.GetAnnotations(mlDep, ANNOTATION_ISTIO_HOST, ANNOTATION_ISTIO_HOST_SEPARATOR, "*"),
Gateways: []string{utils2.GetAnnotation(mlDep, ANNOTATION_ISTIO_GATEWAY, istio_gateway)},
Http: []*istio_networking.HTTPRoute{
{
Expand Down
19 changes: 19 additions & 0 deletions operator/controllers/utils/controller_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,25 @@ func GetAnnotation(mlDep *machinelearningv1.SeldonDeployment, annotationKey stri
}
}

// Get an annotation array from the Seldon Deployment given by annotationKey or return the array with fallback.
func GetAnnotations(mlDep *machinelearningv1.SeldonDeployment, annotationKey string, separator string, fallback string) []string {
RafalSkolasinski marked this conversation as resolved.
Show resolved Hide resolved
var annotation string
if anno, hasAnnotation := mlDep.Spec.Annotations[annotationKey]; hasAnnotation {
annotation = anno
} else {
if anno, hasAnnotation := mlDep.Annotations[annotationKey]; hasAnnotation {
annotation = anno
} else {
annotation = fallback
}
}
if strings.Contains(annotation, separator) {
return strings.Split(annotation, separator)
} else {
return []string{annotation}
}
}

// get annotations that start with seldon.io/engine
func GetEngineEnvAnnotations(mlDep *machinelearningv1.SeldonDeployment) []corev1.EnvVar {

Expand Down
Loading