@@ -27,6 +27,7 @@ import (
27
27
"google.golang.org/protobuf/proto"
28
28
appsv1 "k8s.io/api/apps/v1"
29
29
v1 "k8s.io/api/core/v1"
30
+ "k8s.io/apimachinery/pkg/api/errors"
30
31
"k8s.io/apimachinery/pkg/api/resource"
31
32
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
32
33
"k8s.io/apimachinery/pkg/types"
@@ -696,6 +697,149 @@ var _ = Describe("Inference Graph controller test", func() {
696
697
return inferenceGraphSubmitted .Status .URL .Host
697
698
}, timeout , interval ).Should (Equal (osRoute .Status .Ingress [0 ].Host ))
698
699
})
700
+
701
+ It ("Should not create ingress when cluster-local visibility is configured" , func () {
702
+ By ("By creating a new InferenceGraph" )
703
+ var configMap = & v1.ConfigMap {
704
+ ObjectMeta : metav1.ObjectMeta {
705
+ Name : constants .InferenceServiceConfigMapName ,
706
+ Namespace : constants .KServeNamespace ,
707
+ },
708
+ Data : configs ,
709
+ }
710
+ Expect (k8sClient .Create (context .TODO (), configMap )).NotTo (HaveOccurred ())
711
+ defer func () { _ = k8sClient .Delete (context .TODO (), configMap ) }()
712
+ graphName := "igraw-private"
713
+ var expectedRequest = reconcile.Request {NamespacedName : types.NamespacedName {Name : graphName , Namespace : "default" }}
714
+ var serviceKey = expectedRequest .NamespacedName
715
+ ctx := context .Background ()
716
+ ig := & v1alpha1.InferenceGraph {
717
+ ObjectMeta : metav1.ObjectMeta {
718
+ Name : serviceKey .Name ,
719
+ Namespace : serviceKey .Namespace ,
720
+ Annotations : map [string ]string {
721
+ "serving.kserve.io/deploymentMode" : string (constants .RawDeployment ),
722
+ },
723
+ Labels : map [string ]string {
724
+ constants .NetworkVisibility : constants .ClusterLocalVisibility ,
725
+ },
726
+ },
727
+ Spec : v1alpha1.InferenceGraphSpec {
728
+ Nodes : map [string ]v1alpha1.InferenceRouter {
729
+ v1alpha1 .GraphRootNodeName : {
730
+ RouterType : v1alpha1 .Sequence ,
731
+ Steps : []v1alpha1.InferenceStep {
732
+ {
733
+ InferenceTarget : v1alpha1.InferenceTarget {
734
+ ServiceURL : "http://someservice.exmaple.com" ,
735
+ },
736
+ },
737
+ },
738
+ },
739
+ },
740
+ },
741
+ }
742
+ Expect (k8sClient .Create (ctx , ig )).Should (Succeed ())
743
+ defer func () { _ = k8sClient .Delete (ctx , ig ) }()
744
+
745
+ // The OpenShift route must not be created
746
+ actualK8sDeploymentCreated := & appsv1.Deployment {}
747
+ Eventually (func () error {
748
+ return k8sClient .Get (ctx , serviceKey , actualK8sDeploymentCreated )
749
+ }, timeout , interval ).Should (Succeed ())
750
+ actualK8sDeploymentCreated .Status .Conditions = []appsv1.DeploymentCondition {
751
+ {Type : appsv1 .DeploymentAvailable },
752
+ }
753
+ Expect (k8sClient .Status ().Update (ctx , actualK8sDeploymentCreated )).Should (Succeed ())
754
+ osRoute := osv1.Route {}
755
+ Consistently (func () error {
756
+ osRouteKey := types.NamespacedName {Name : ig .GetName () + "-route" , Namespace : ig .GetNamespace ()}
757
+ return k8sClient .Get (ctx , osRouteKey , & osRoute )
758
+ }, timeout , interval ).Should (WithTransform (errors .IsNotFound , BeTrue ()))
759
+
760
+ // The InferenceGraph should have a cluster-internal hostname
761
+ Eventually (func () string {
762
+ _ = k8sClient .Get (ctx , serviceKey , ig )
763
+ return ig .Status .URL .Host
764
+ }, timeout , interval ).Should (Equal (fmt .Sprintf ("%s.%s.svc.cluster.local" , graphName , "default" )))
765
+ })
766
+
767
+ It ("Should reconfigure InferenceGraph as private when cluster-local visibility is configured" , func () {
768
+ By ("By creating a new InferenceGraph" )
769
+ var configMap = & v1.ConfigMap {
770
+ ObjectMeta : metav1.ObjectMeta {
771
+ Name : constants .InferenceServiceConfigMapName ,
772
+ Namespace : constants .KServeNamespace ,
773
+ },
774
+ Data : configs ,
775
+ }
776
+ Expect (k8sClient .Create (context .TODO (), configMap )).NotTo (HaveOccurred ())
777
+ defer func () { _ = k8sClient .Delete (context .TODO (), configMap ) }()
778
+ graphName := "igraw-exposed-to-private"
779
+ var expectedRequest = reconcile.Request {NamespacedName : types.NamespacedName {Name : graphName , Namespace : "default" }}
780
+ var serviceKey = expectedRequest .NamespacedName
781
+ ctx := context .Background ()
782
+ ig := & v1alpha1.InferenceGraph {
783
+ ObjectMeta : metav1.ObjectMeta {
784
+ Name : serviceKey .Name ,
785
+ Namespace : serviceKey .Namespace ,
786
+ Annotations : map [string ]string {
787
+ "serving.kserve.io/deploymentMode" : string (constants .RawDeployment ),
788
+ },
789
+ },
790
+ Spec : v1alpha1.InferenceGraphSpec {
791
+ Nodes : map [string ]v1alpha1.InferenceRouter {
792
+ v1alpha1 .GraphRootNodeName : {
793
+ RouterType : v1alpha1 .Sequence ,
794
+ Steps : []v1alpha1.InferenceStep {
795
+ {
796
+ InferenceTarget : v1alpha1.InferenceTarget {
797
+ ServiceURL : "http://someservice.exmaple.com" ,
798
+ },
799
+ },
800
+ },
801
+ },
802
+ },
803
+ },
804
+ }
805
+ Expect (k8sClient .Create (ctx , ig )).Should (Succeed ())
806
+ defer func () { _ = k8sClient .Delete (ctx , ig ) }()
807
+
808
+ // Wait the OpenShift route to be created
809
+ actualK8sDeploymentCreated := & appsv1.Deployment {}
810
+ Eventually (func () error {
811
+ return k8sClient .Get (ctx , serviceKey , actualK8sDeploymentCreated )
812
+ }, timeout , interval ).Should (Succeed ())
813
+ actualK8sDeploymentCreated .Status .Conditions = []appsv1.DeploymentCondition {
814
+ {Type : appsv1 .DeploymentAvailable },
815
+ }
816
+ Expect (k8sClient .Status ().Update (ctx , actualK8sDeploymentCreated )).Should (Succeed ())
817
+ osRoute := osv1.Route {}
818
+ Eventually (func () error {
819
+ osRouteKey := types.NamespacedName {Name : ig .GetName () + "-route" , Namespace : ig .GetNamespace ()}
820
+ return k8sClient .Get (ctx , osRouteKey , & osRoute )
821
+ }, timeout , interval ).Should (Succeed ())
822
+
823
+ // Reconfigure as private
824
+ Expect (k8sClient .Get (ctx , serviceKey , ig )).Should (Succeed ())
825
+ if ig .Labels == nil {
826
+ ig .Labels = map [string ]string {}
827
+ }
828
+ ig .Labels [constants .NetworkVisibility ] = constants .ClusterLocalVisibility
829
+ Expect (k8sClient .Update (ctx , ig )).Should (Succeed ())
830
+
831
+ // The OpenShift route should be deleted
832
+ Eventually (func () error {
833
+ osRouteKey := types.NamespacedName {Name : ig .GetName () + "-route" , Namespace : ig .GetNamespace ()}
834
+ return k8sClient .Get (ctx , osRouteKey , & osRoute )
835
+ }).Should (WithTransform (errors .IsNotFound , BeTrue ()))
836
+
837
+ // The InferenceGraph should have a cluster-internal hostname
838
+ Eventually (func () string {
839
+ _ = k8sClient .Get (ctx , serviceKey , ig )
840
+ return ig .Status .URL .Host
841
+ }, timeout , interval ).Should (Equal (fmt .Sprintf ("%s.%s.svc.cluster.local" , graphName , "default" )))
842
+ })
699
843
})
700
844
701
845
Context ("When creating an InferenceGraph in Serverless mode" , func () {
0 commit comments