Connect to dgraph within a docker cluster

What I want to do

I’m having multiple microservices they’re communicated through gRPC just fine and I wanted to link dgraph to most of these services

What I did

I linked dgraph container in docker-composer.yaml to other services HTTP connection is working
bust gRPC client is not tho gRPC is working fine in other services

Error

{"code":14,
"details":"No connection established",
"metadata":{"internalRepr":{},"options":{}}}

docker-compose.yml

view
version: '3.7'

services:
  main:
    # gateway-service: 
    build:
      context: ./gateway-service
      target: development
    volumes:
      - ./gateway-service:/usr/src/app
      - /usr/src/app/node_modules
      # - node_modules:/usr/src/app/node_modules
    ports:
      - 3000:3000
      # - 9229:9229
    command: npm run start:dev
    env_file:
      - ./gateway-service/.env
    links:
      - gdb
      - user
    depends_on:
      - gdb
  
  user:
    # user-service: 
    build:
      context: ./user-service
      target: development
    volumes:
      - ./user-service:/usr/src/app
      - /usr/src/app/node_modules
      # - /usr/src/app/user/node_modules
    expose: ["5050"]
    #   # - 9229:9229
    command: npm run start:dev
    
    env_file:
      - ./user-service/.env
    links:
      - gdb
    depends_on:
      - gdb

  
  
  
  gdb:
    image: dgraph/standalone
    ports:
      - 8080:8080
      - 9080:9080
      - 5080:5080
      - 6080:6080
    expose: ["9080","5080","6080","8080","8000"]

Can you query for More about Dgraph Alpha - Deploy ? you can use insomnia.

What says http://locahos:6080/state ?

Is this syntax correct?

Try

expose:
  - "9080"
  - "..."

The standalone image doesn’t have the Ratel UI. You have to run it separately.

Can you use grpcurl to check if it can reach out the gRPC service from Dgraph?

it gives


{
	"counter": "12",
	"groups": {
		"1": {
			"members": {
				"1": {
					"id": "1",
					"groupId": 1,
					"addr": "localhost:7080",
					"leader": true,
					"amDead": false,
					"lastUpdate": "1625759055",
					"learner": false,
					"clusterInfoOnly": false,
					"forceGroupId": false
				}
			},
			"tablets": {
				"dgraph.drop.op": {
					"groupId": 1,
					"predicate": "dgraph.drop.op",
					"force": false,
					"onDiskBytes": "0",
					"remove": false,
					"readOnly": false,
					"moveTs": "0",
					"uncompressedBytes": "0"
				},
				"dgraph.graphql.p_query": {
					"groupId": 1,
					"predicate": "dgraph.graphql.p_query",
					"force": false,
					"onDiskBytes": "0",
					"remove": false,
					"readOnly": false,
					"moveTs": "0",
					"uncompressedBytes": "0"
				},
				"dgraph.graphql.schema": {
					"groupId": 1,
					"predicate": "dgraph.graphql.schema",
					"force": false,
					"onDiskBytes": "0",
					"remove": false,
					"readOnly": false,
					"moveTs": "0",
					"uncompressedBytes": "0"
				},
				"dgraph.graphql.xid": {
					"groupId": 1,
					"predicate": "dgraph.graphql.xid",
					"force": false,
					"onDiskBytes": "0",
					"remove": false,
					"readOnly": false,
					"moveTs": "0",
					"uncompressedBytes": "0"
				},
				"dgraph.type": {
					"groupId": 1,
					"predicate": "dgraph.type",
					"force": false,
					"onDiskBytes": "0",
					"remove": false,
					"readOnly": false,
					"moveTs": "0",
					"uncompressedBytes": "0"
				}
			},
			"snapshotTs": "0",
			"checksum": "12696972231616318625",
			"checkpointTs": "0"
		}
	},
	"zeros": {
		"1": {
			"id": "1",
			"groupId": 0,
			"addr": "localhost:5080",
			"leader": true,
			"amDead": false,
			"lastUpdate": "0",
			"learner": false,
			"clusterInfoOnly": false,
			"forceGroupId": false
		}
	},
	"maxUID": "0",
	"maxTxnTs": "10000",
	"maxNsID": "0",
	"maxRaftId": "1",
	"removed": [],
	"cid": "913692ba-d8f6-4362-ab15-ec1feb697f00",
	"license": {
		"user": "",
		"maxNodes": "18446744073709551615",
		"expiryTs": "1628351056",
		"enabled": true
	}
}

can you provide more information?

i did and still having it

What did you do? This is to access through a Browser. I don’t remember this type of error in the Browser.

Download Insomnia, use the query in the given example and hit it against the http://locahos:8080/admin - Just that. It is a GraphQL query.

BTW.

Check your firewall or similar. Check if your machine isn’t the issue, maybe it hasn’t the rights to access it.

Looks fine. Check the last things I mentioned above. About firewall and so on.

{
  "data": {
    "health": [
      {
        "instance": "zero",
        "address": "localhost:5080",
        "version": "v21.03.1",
        "status": "healthy",
        "lastEcho": 1625759497,
        "group": "0",
        "uptime": 443,
        "ongoing": [],
        "indexing": []
      },
      {
        "instance": "alpha",
        "address": "localhost:7080",
        "version": "v21.03.1",
        "status": "healthy",
        "lastEcho": 1625759497,
        "group": "1",
        "uptime": 446,
        "ongoing": [
          "opRollup"
        ],
        "indexing": []
      }
    ]
  },
  "extensions": {
    "tracing": {
      "version": 1,
      "startTime": "2021-07-08T15:51:37.552077507Z",
      "endTime": "2021-07-08T15:51:37.572938924Z",
      "duration": 20861750
    }
  }
}

firewall is not the issue cuz when i run the container individually it works fine on grpcCurl

Well if it works fine via grpcCurl, the issue is in your code somewhere.

It is not unhealthy, You can hit via HTTP and gRPC by other tools. All state checks are fine. Your firewall isn’t an issue. Exposing the port certainly isn’t the issue. So the only one left is your program.

no it’s not a problem with my program it’s working just fine outside of docker, I think the problem is with linking dgraph standalone with other services

I can’t reproduce it. If you help to create a reproducible scenario it would be great.

1 Like

i can upload code sample for you to test it

You can send me a gist via DM, but these days i will be away from the office, working via notebook. Don’t expect me to urgently check it. But I will.

For the dgraph configuration, is a white list configured to allow the source IP?

1 Like

Yeah, thats a good point. @omaralmgerbie check this configs and allow your network https://dgraph.io/docs/deploy/dgraph-administration/#whitelisting-admin-operations

1 Like