Skip to content

Commit

Permalink
Add disable ingress feature for raw deployment (kubeflow#2773)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrews Arokiam <[email protected]>
Signed-off-by: Dan Sun <[email protected]>
Co-authored-by: Dan Sun <[email protected]>
  • Loading branch information
andyi2it and yuzisun authored Apr 7, 2023
1 parent 7933c43 commit 5980cf6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 24 deletions.
7 changes: 7 additions & 0 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ var (
PredictorProtocolAnnotationKey = InferenceServiceInternalAnnotationsPrefix + "/predictor-protocol"
)

// kserve networking constants
const (
NetworkVisibility = "networking.kserve.io/visibility"
ClusterLocalVisibility = "cluster-local"
ClusterLocalDomain = "svc.cluster.local"
)

// StorageSpec Constants
var (
DefaultStorageSpecSecret = "storage-config"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func createIngress(isvc *v1beta1.InferenceService, useDefault bool, config *v1be
}
isInternal := false
//if service is labelled with cluster local or knative domain is configured as internal
if val, ok := isvc.Labels[constants.VisibilityLabel]; ok && val == "cluster-local" {
if val, ok := isvc.Labels[constants.VisibilityLabel]; ok && val == constants.ClusterLocalVisibility {
isInternal = true
}
serviceInternalHostName := network.GetServiceHostname(isvc.Name, isvc.Namespace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,34 +255,45 @@ func semanticIngressEquals(desired, existing *netv1.Ingress) bool {
}

func (r *RawIngressReconciler) Reconcile(isvc *v1beta1api.InferenceService) error {
ingress, err := createRawIngress(r.scheme, isvc, r.ingressConfig, r.client)
if ingress == nil {
return nil
var err error
isInternal := false
// disable ingress creation if service is labelled with cluster local or kserve domain is cluster local
if val, ok := isvc.Labels[constants.NetworkVisibility]; ok && val == constants.ClusterLocalVisibility {
isInternal = true
}
if err != nil {
return err
if r.ingressConfig.IngressDomain == constants.ClusterLocalDomain {
isInternal = true
}
//reconcile ingress
existingIngress := &netv1.Ingress{}
err = r.client.Get(context.TODO(), types.NamespacedName{
Namespace: isvc.Namespace,
Name: isvc.Name,
}, existingIngress)
if err != nil {
if apierr.IsNotFound(err) {
err = r.client.Create(context.TODO(), ingress)
log.Info("creating ingress", "ingressName", isvc.Name, "err", err)
} else {
if !isInternal {
ingress, err := createRawIngress(r.scheme, isvc, r.ingressConfig, r.client)
if ingress == nil {
return nil
}
if err != nil {
return err
}
} else {
if !semanticIngressEquals(ingress, existingIngress) {
err = r.client.Update(context.TODO(), ingress)
log.Info("updating ingress", "ingressName", isvc.Name, "err", err)
//reconcile ingress
existingIngress := &netv1.Ingress{}
err = r.client.Get(context.TODO(), types.NamespacedName{
Namespace: isvc.Namespace,
Name: isvc.Name,
}, existingIngress)
if err != nil {
if apierr.IsNotFound(err) {
err = r.client.Create(context.TODO(), ingress)
log.Info("creating ingress", "ingressName", isvc.Name, "err", err)
} else {
return err
}
} else {
if !semanticIngressEquals(ingress, existingIngress) {
err = r.client.Update(context.TODO(), ingress)
log.Info("updating ingress", "ingressName", isvc.Name, "err", err)
}
}
if err != nil {
return err
}
}
if err != nil {
return err
}
isvc.Status.URL, err = createRawURL(isvc, r.ingressConfig)
if err != nil {
Expand Down

0 comments on commit 5980cf6

Please sign in to comment.