lgy1027 edited a comment on issue #646:
URL: 
https://github.com/apache/apisix-ingress-controller/issues/646#issuecomment-903665930


   > @lgy1027 Please use the latest version of ingress-controller,now it is 
1.2.0
   
   现在不报错了,直接build1.2镜像,但是我在使用client创建router时还是报错
   ````
   ApisixRoute.apisix.apache.org "httpbin-route" is invalid: [<nil>: Invalid 
value: "": "spec.http" must validate one and only one schema (oneOf). Found 2 
valid alternatives, spec.http.authentication.type: Unsupported value: "": 
supported values: "basicAuth", "keyAuth", spec.http.backend.serviceName: 
Invalid value: "": spec.http.backend.serviceName in body shouldbe at least 1 
chars long, spec.http.backend.servicePort: Invalid value: 0: 
spec.http.backend.servicePort in body should be greater than or equal to 1, 
spec.http.backend.weight: Invalid value: "null": spec.http.backend.weight in 
body mustbe of type integer: "null"]
   ````
   代码如下:
   ````
   import 
"github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/clientset/versioned"
   
   client,err = versioned.NewForConfig(config)
   
   func BuildRoute()  {
        w := int(100)
        v2b := &v2beta1.ApisixRoute{
                TypeMeta: metav1.TypeMeta{
                        Kind:"ApisixRoute",
                        APIVersion:"apisix.apache.org/v2beta1",
                },
                ObjectMeta:metav1.ObjectMeta{
                        Name: "httpbin-route",
                        Namespace: "lgy",
                },
                Spec: v2beta1.ApisixRouteSpec{
                        HTTP:[]v2beta1.ApisixRouteHTTP{
                                v2beta1.ApisixRouteHTTP{
                                        Name: "httpbin",
                                        Match: v2beta1.ApisixRouteHTTPMatch{
                                                Hosts: 
[]string{"local.httpbin.org"},
                                                Paths: []string{"/*"},
                                        },
                                        Backends: 
[]v2alpha1.ApisixRouteHTTPBackend{
                                                v2alpha1.ApisixRouteHTTPBackend{
                                                        ServiceName: "httpbin",
                                                        ServicePort: 
intstr.IntOrString{
                                                                Type: 
intstr.Int,
                                                                IntVal: 80,
                                                        },
                                                        Weight:&w,
                                                },
                                        },
                                },
                        },
                },
   
        }
        _, err := 
client.ApisixV2beta1().ApisixRoutes("lgy").Create(context.Background(),v2b,v1.CreateOptions{})
        fmt.Println(err)
   }
   ````
   apisix-ingress-controller引得依赖是1.2.0的版本
   ````
   require (
        bou.ke/monkey v1.0.2
        github.com/apache/apisix-ingress-controller v1.2.0
   ````
   使用kubectl apply -f yaml 没问题


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to