database-mesh/pisanix

how to run with a netcore api program

nontracey opened this issue · 17 comments

how to run with a netcore api program ,I have used the Deployment of K8S, other steps are according to the document, the startup of the sidecar reported an error, can I only start through helm?

error full info:
thread 'main' panicked at 'called Result::unwrap() on an Err value: reqwest::Error { kind: Decode, source: Error("missing field admin", line: 1, column: 301) }', app/config/src/config.rs:132:46 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Thanks for your feedback. You could add some annotations to VirtualDatabase, then restart the aplication Pod. Examples:

apiVersion: core.database-mesh.io/v1alpha1
kind: VirtualDatabase
metadata:
  annotations:
    database-mesh.io/metrics-port: "9090" # add this annotation
  name: catalogue
spec:
  services:
  - databaseMySQL:
      db: socksdb
      host: 127.0.0.1
      password: fake_password
      poolSize: 3
      port: 3306
      user: root
    name: my_mysql
    trafficStrategy: catalogue

This issue will be fixed in release v0.1.1 next week.

Another possible cause could be misconfigurated pisa-proxy and pisa-controller communication. This error means pisa-proxy doesn't get a correct configuration.

Any updates on this ? @lengyjc

Thanks for your feedback. You could add some annotations to VirtualDatabase, then restart the aplication Pod. Examples:

apiVersion: core.database-mesh.io/v1alpha1
kind: VirtualDatabase
metadata:
  annotations:
    database-mesh.io/metrics-port: "9090" # add this annotation
  name: catalogue
spec:
  services:
  - databaseMySQL:
      db: socksdb
      host: 127.0.0.1
      password: fake_password
      poolSize: 3
      port: 3306
      user: root
    name: my_mysql
    trafficStrategy: catalogue

I've tried adding annotation nodes, but it doesn't solve the problem.
here is my folder struction:
image
Three CustomResourceDefinitions except for database connection in other configurations are based on the contents of the document, redismanager is my business program, it is a netcore webapi program.
image
Start the program by using ' kubectl apply-f '
Is I misconfigurated pisa-proxy and pisa-controller communication?

The error message you pasted means pisa-proxy didn't receive the correct configuration from pisa-controller. For these kind of issues, you can try to get the configuration response from pisa-controller directly throught a kubectl port-forward command. Following the steps:

kubectl port-forward pod/${PISA_CONTROLLER_NAME} -n ${PISA_CONTROLLER_NAMESPACE} 8080:8080
curl -iv http://localhost:8080/apis/configs.database-mesh.io/v1alpha1/namespaces/${PISA_PROXY_NAMESPACE}/proxyconfigs/${INJECT_APPLICATION_NAME}

INJECT_APPLICATION_NAME refers to the redismanager.

Then attach the respone to this thread, we will figure it out.

Thanks !

by this command
kubectl port-forward pod/pisa-controller-645c597694-4z2bb -n test 8080:8080 curl -iv http://localhost:8080/apis/configs.database-mesh.io/v1alpha1/namespaces/test/proxyconfigs/mediinfo-redismanager-78499bb466-6tnmt
i got this result :
`* About to connect() to localhost port 8080 (#0)

  • Trying ::1...
  • Connected to localhost (::1) port 8080 (#0)

GET /apis/configs.database-mesh.io/v1alpha1/namespaces/test/proxyconfigs/mediinfo-redismanager-78499bb466-6tnmt HTTP/1.1
User-Agent: curl/7.29.0
Host: localhost:8080
Accept: /

< HTTP/1.1 400 Bad Request
HTTP/1.1 400 Bad Request
< Content-Type: application/json; charset=utf-8
Content-Type: application/json; charset=utf-8
< Date: Thu, 23 Jun 2022 06:34:33 GMT
Date: Thu, 23 Jun 2022 06:34:33 GMT
< Content-Length: 335
Content-Length: 335

<

  • Connection #0 to host localhost left intact
    {"ErrStatus":{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"virtualdatabases.core.database-mesh.io "mediinfo-redismanager-78499bb466-6tnmt" not found","reason":"NotFound","details":{"name":"mediinfo-redismanager-78499bb466-6tnmt","group":"core.database-mesh.io","kind":"virtualdatabases"},"code":404}}`

image
image

Our WebAPI program does not have a home page, but only restful interface. Can it only be connected to the front-end project?

The url should be like this:

curl -iv http://localhost:8080/apis/configs.database-mesh.io/v1alpha1/namespaces/test/proxyconfigs/mediinfo-redismanager

Our WebAPI program does not have a home page, but only restful interface. Can it only be connected to the front-end project?

It's no matter with your application. Pisa-Proxy handles handle database traffic only.

curl -iv http://localhost:8080/apis/configs.database-mesh.io/v1alpha1/namespaces/test/proxyconfigs/mediinfo-redismanager

  • About to connect() to localhost port 8080 (#0)
  • Trying ::1...
  • Connected to localhost (::1) port 8080 (#0)

GET /apis/configs.database-mesh.io/v1alpha1/namespaces/test/proxyconfigs/mediinfo-redismanager HTTP/1.1
User-Agent: curl/7.29.0
Host: localhost:8080
Accept: /

< HTTP/1.1 400 Bad Request
HTTP/1.1 400 Bad Request
< Content-Type: application/json; charset=utf-8
Content-Type: application/json; charset=utf-8
< Date: Thu, 23 Jun 2022 07:20:53 GMT
Date: Thu, 23 Jun 2022 07:20:53 GMT
< Content-Length: 301
Content-Length: 301

<

  • Connection #0 to host localhost left intact
    {"ErrStatus":{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"virtualdatabases.core.database-mesh.io "mediinfo-redismanager" not found","reason":"NotFound","details":{"name":"mediinfo-redismanager","group":"core.database-mesh.io","kind":"virtualdatabases"},"code":404}}

This means you should create a VirtualDatabase CRD with name of your application name ‘mediinfo-redismanager’.

It’s led by the ambiguous documentation. I’ll fix it soon.

This means you should create a VirtualDatabase CRD with name of your application name ‘mediinfo-redismanager’.

this fixed my problem

Sounds good. Did you join our wechat group ? You can add this broker account pisanix and join the community ! @lengyjc