mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-27 16:17:34 +00:00
Fix: change seldon service from istio to ambassador
Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>
This commit is contained in:
@@ -27,7 +27,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
istio "istio.io/client-go/pkg/apis/networking/v1beta1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
networkv1beta1 "k8s.io/api/networking/v1beta1"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
@@ -257,51 +256,30 @@ func (h *provider) GeneratorServiceEndpoints(wfctx wfContext.Context, v *value.V
|
||||
serviceEndpoints = append(serviceEndpoints, generatorFromIngress(ing, cluster)...)
|
||||
}
|
||||
case "SeldonDeployment":
|
||||
var vs istio.VirtualService
|
||||
if err := findResource(&vs, resource.Name, resource.Namespace, resource.Cluster); err != nil {
|
||||
klog.Error(err, fmt.Sprintf("find v1alpha3 VirtualService %s/%s from cluster %s failure", resource.Name, resource.Namespace, resource.Cluster))
|
||||
// seldon use ambassador to expose service
|
||||
var service corev1.Service
|
||||
if err := findResource(&service, "ambassador", "vela-system", resource.Cluster); err != nil {
|
||||
klog.Error(err, fmt.Sprintf("find v1 Service ambassador/vela-system from cluster %s failure", resource.Cluster))
|
||||
continue
|
||||
}
|
||||
if vs.Spec.Http == nil || vs.Spec.Http[0].Match == nil {
|
||||
klog.Error(fmt.Sprintf("find VirtualService %s/%s from cluster %s empty prefix", resource.Name, resource.Namespace, resource.Cluster))
|
||||
continue
|
||||
}
|
||||
// get istio service from label here since the seldon's gateway is predefined
|
||||
var istioService corev1.ServiceList
|
||||
labels := &v1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"istio": "ingressgateway",
|
||||
},
|
||||
}
|
||||
selector, err := v1.LabelSelectorAsSelector(labels)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := h.cli.List(ctx, &istioService, &client.ListOptions{
|
||||
LabelSelector: selector,
|
||||
}); err != nil || len(istioService.Items) == 0 {
|
||||
klog.Error(err, fmt.Sprintf("find istio service from cluster %s failure", resource.Cluster))
|
||||
continue
|
||||
}
|
||||
service := istioService.Items[0]
|
||||
if service.Status.LoadBalancer.Ingress == nil {
|
||||
klog.Error(fmt.Sprintf("find istio service from cluster %s empty ingress", resource.Cluster))
|
||||
klog.Error("ambassador service not ready", "service", service.Name, "namespace", service.Namespace, "cluster", resource.Cluster)
|
||||
continue
|
||||
}
|
||||
serviceEndpoints = append(serviceEndpoints, querytypes.ServiceEndpoint{
|
||||
Endpoint: querytypes.Endpoint{
|
||||
Host: service.Status.LoadBalancer.Ingress[0].IP,
|
||||
Port: 80,
|
||||
Path: vs.Spec.Http[0].Match[0].Uri.GetPrefix(),
|
||||
Path: fmt.Sprintf("/seldon/%s/%s", resource.Namespace, resource.Name),
|
||||
Protocol: corev1.ProtocolTCP,
|
||||
},
|
||||
Ref: corev1.ObjectReference{
|
||||
Kind: "VirtualService",
|
||||
Namespace: vs.ObjectMeta.Namespace,
|
||||
Name: vs.ObjectMeta.Name,
|
||||
UID: vs.UID,
|
||||
APIVersion: vs.APIVersion,
|
||||
ResourceVersion: vs.ResourceVersion,
|
||||
Kind: "Service",
|
||||
Namespace: service.Namespace,
|
||||
Name: service.Name,
|
||||
UID: service.UID,
|
||||
APIVersion: service.APIVersion,
|
||||
ResourceVersion: service.ResourceVersion,
|
||||
},
|
||||
Cluster: cluster,
|
||||
})
|
||||
|
||||
@@ -24,8 +24,6 @@ import (
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
istiov1beta1 "istio.io/api/networking/v1beta1"
|
||||
istio "istio.io/client-go/pkg/apis/networking/v1beta1"
|
||||
v1 "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
networkv1beta1 "k8s.io/api/networking/v1beta1"
|
||||
@@ -518,14 +516,12 @@ options: {
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "istio-service",
|
||||
"name": "ambassador",
|
||||
"namespace": "vela-system",
|
||||
"ports": []corev1.ServicePort{
|
||||
{Port: 80, TargetPort: intstr.FromInt(80), Name: "80port"},
|
||||
},
|
||||
"type": corev1.ServiceTypeLoadBalancer,
|
||||
"labels": map[string]string{
|
||||
"istio": "ingressgateway",
|
||||
},
|
||||
"status": corev1.ServiceStatus{
|
||||
LoadBalancer: corev1.LoadBalancerStatus{
|
||||
Ingress: []corev1.LoadBalancerIngress{
|
||||
@@ -537,11 +533,21 @@ options: {
|
||||
},
|
||||
},
|
||||
}
|
||||
err = k8sClient.Create(context.TODO(), &corev1.Namespace{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "vela-system",
|
||||
},
|
||||
})
|
||||
Expect(err).Should(BeNil())
|
||||
for _, s := range testServicelist {
|
||||
ns := "default"
|
||||
if s["namespace"] != nil {
|
||||
ns = s["namespace"].(string)
|
||||
}
|
||||
service := &corev1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: s["name"].(string),
|
||||
Namespace: "default",
|
||||
Namespace: ns,
|
||||
},
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: s["ports"].([]corev1.ServicePort),
|
||||
@@ -702,26 +708,6 @@ options: {
|
||||
Expect(err).Should(BeNil())
|
||||
}
|
||||
|
||||
err = k8sClient.Create(context.TODO(), &istio.VirtualService{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "sdep",
|
||||
Namespace: "default",
|
||||
},
|
||||
Spec: istiov1beta1.VirtualService{
|
||||
Http: []*istiov1beta1.HTTPRoute{
|
||||
{
|
||||
Match: []*istiov1beta1.HTTPMatchRequest{
|
||||
{
|
||||
Uri: &istiov1beta1.StringMatch{
|
||||
MatchType: &istiov1beta1.StringMatch_Prefix{Prefix: "/seldon/test"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
Expect(err).Should(BeNil())
|
||||
opt := `app: {
|
||||
name: "endpoints-app"
|
||||
namespace: "default"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user