K8s service cannot work with JSON API

I started a JSON API service inside the pod and port-forward out is available but via service access reported 503 error. What do I need to configure?

Hi @532213748,

I suspect you kept the the listening address as the default, which is localhost. Add the --address 0.0.0.0 option to make the process bind to the other interfaces as well.

Kind Regards,
Mate

Hi @Mate_Varga Both Participant Node and JSON API configuration have ‘‘address=0.0.0.0’’, it also cannot work well.

Can you share your configuration files for both the participant node, the json api server and the kubernetes objects representing them and their network related config? If it is sensitive feel free to send them is a private message.

I am just testing now, you can see they are in two configmaps:
apiVersion: v1
data:
participant_config: |
canton {
participants {
participant {
storage.type = memory
admin-api.port = 5012
ledger-api.port = 5011
ledger-api.address = 0.0.0.0
}
}
// enable ledger_api commands for our getting started guide
features.enable-testing-commands = yes
features.enable-preview-commands = yes
}
kind: ConfigMap

apiVersion: v1
data:
json_api_config: |
{
server {
address = 0.0.0.0
port = 8080
}
ledger-api {
address = “localhost”
port = 5011
}
}
kind: ConfigMap

So how is your network setup, are you running the containers in the same pod?
What is the exact error message you are receiving?

I built my Daml network as following:
Step 1. Create Domain, I created a pod and a service. Domain configuration:

canton {
  domains {
    mydomain {
          storage.type = memory
          public-api.port = 10018
          public-api.address = 0.0.0.0
          admin-api.port = 10019
    }
  }
}

Step 2. Create Participant Node. In this step I create a pod and a service, there are two containers in the pod, one of which used for JSON API.
Participant Node configuration:

canton {
      participants {
        participant {
          storage.type = memory
          admin-api.port = 5012
          ledger-api.port = 5011
          ledger-api.address = 0.0.0.0
        }
      }
      // enable ledger_api commands for our getting started guide
      features.enable-testing-commands = yes
      features.enable-preview-commands = yes
    }

JSON API configuration:

 {
      server {
        address = 0.0.0.0
        port = 8080
      }
      ledger-api {
        address = "localhost"
        port = 5011
      }
    }

Step 3. Connect to Domain use following code:

    nodes.local.start()
    val domainUrl = sys.env.get("DOMAIN_URL").getOrElse("http://canton-domain-service:10018")
    val myself = participant
    myself.domains.connect("mydomain", domainUrl)
    myself.health.ping(myself)

Step 4. After that I call json api in one of the pods with curl command:

curl -H "Authorization:Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhbGljZSIsInNjb3BlIjoiZGFtbF9sZWRnZXJfYXBpIn0.fQi6KFWxgcQQ9eB2oX-dM9wv5u0D3BvUUsFdydtz3Bk" daml-json-api-778f887b6f-dvvvn:8080/v1/user

“daml-json-api-778f887b6f-dvvvn” is service name.
and return an error:

{"errors":["UNAVAILABLE: io exception"],"ledgerApiError":{"code":14,"details":[],"message":"io exception"},"status":503}