Thanks and I am back
I converted you docker-compose.yaml file to K8s - and the problem beneath comes down to the same connection to “alpha” - see the command under the graphql I created.
And yes it is me who is doing something wrong with:
dgraph graphql --alpha dgraph-0.alpha.${POD_NAMESPACE}.svc.cluster.local:9080
Trying to connect to(kubectl logs dgraph-0 graphql):
dgraph-0.alpha.default.svc.cluster.local:9080
kubectl logs dgraph-0 graphql
+ dgraph graphql --alpha dgraph-0.alpha.default.svc.cluster.local:9080
[Decoder]: Using assembly version of decoder
I1126 22:20:01.875317 1 init.go:98]
Dgraph version : v1.1.0-236-g81b2d73d
Dgraph SHA-256 : 94daafc9de4163861fff4590042a476ba5ca5eaff51f7c8373e02c2fb51f4651
Commit SHA-1 : 81b2d73d
Commit timestamp : 2019-11-18 13:54:20 +1100
Branch : pawanrawal/graphql-standalone-image
Go version : go1.13.4
For Dgraph official documentation, visit https://docs.dgraph.io.
For discussions about Dgraph , visit http://discuss.hypermode.com.
To say hi to the community , visit https://dgraph.slack.com.
Licensed variously under the Apache Public License 2.0 and Dgraph Community License.
Copyright 2015-2018 Dgraph Labs, Inc.
I1126 22:20:01.876525 1 run.go:137] Starting GraphQL with Dgraph at: dgraph-0.alpha.default.svc.cluster.local:9080
I1126 22:20:01.877458 1 admin.go:276] Trying to connect to Dgraph at dgraph-0.alpha.default.svc.cluster.local:9080
I1126 22:20:01.879843 1 run.go:169] Bringing up GraphQL HTTP API at 0.0.0.0:9000/graphql
I1126 22:20:01.879862 1 run.go:170] Bringing up GraphiQL web interface for HTTP API at 0.0.0.0:9000/graphiql
I1126 22:20:01.879870 1 run.go:171] Bringing up GraphQL HTTP admin API at 0.0.0.0:9000/admin
I1126 22:20:01.879878 1 run.go:172] Bringing up GraphiQL web interface for HTTP admin API at 0.0.0.0:9000/admin/graphiql
I1126 22:20:21.877900 1 admin.go:276] Trying to connect to Dgraph at dgraph-0.alpha.default.svc.cluster.local:9080
...
The converted k8s.yaml file:
apiVersion: v1
kind: Service
metadata:
name: dgraph-public
labels:
app: dgraph
spec:
type: LoadBalancer
ports:
- port: 9000
targetPort: 9000
name: graphql-http
- port: 5080
targetPort: 5080
name: zero-grpc
- port: 6080
targetPort: 6080
name: zero-http
- port: 8080
targetPort: 8080
name: alpha-http
- port: 9080
targetPort: 9080
name: alpha-grpc
- port: 8000
targetPort: 8000
name: ratel-http
selector:
app: dgraph
---
# This StatefulSet runs 1 pod with one Zero, one Alpha & one Ratel containers.
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: dgraph
spec:
serviceName: "dgraph"
replicas: 1
selector:
matchLabels:
app: dgraph
template:
metadata:
labels:
app: dgraph
spec:
containers:
- name: graphql
image: dgraph/standalone:graphql
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9000
name: graphql-http
command:
- bash
- "-c"
- |
set -ex
dgraph graphql --alpha dgraph-0.alpha.${POD_NAMESPACE}.svc.cluster.local:9080
- name: ratel
image: dgraph/standalone:graphql
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8000
name: ratel-http
command:
- dgraph-ratel
- name: zero
image: dgraph/standalone:graphql
imagePullPolicy: IfNotPresent
ports:
- containerPort: 5080
name: zero-grpc
- containerPort: 6080
name: zero-http
volumeMounts:
- name: datadir
mountPath: /dgraph
command:
- bash
- "-c"
- |
set -ex
dgraph zero --my=$(hostname -f):5080
- name: alpha
image: dgraph/standalone:graphql
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
name: alpha-http
- containerPort: 9080
name: alpha-grpc
volumeMounts:
- name: datadir
mountPath: /dgraph
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
command:
- bash
- "-c"
- |
set -ex
dgraph alpha --my=$(hostname -f):7080 --lru_mb 2048 --zero dgraph-0.dgraph.${POD_NAMESPACE}.svc.cluster.local:5080
terminationGracePeriodSeconds: 60
volumes:
- name: datadir
persistentVolumeClaim:
claimName: datadir
updateStrategy:
type: RollingUpdate
volumeClaimTemplates:
- metadata:
name: datadir
annotations:
volume.alpha.kubernetes.io/storage-class: anything
spec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: 5Gi
All containers is running:
jq -n --arg schema "$(cat schema.graphql)" '{ query: "mutation addSchema($sch: String!) { addSchema(input: { schema: $sch }) { schema { schema } } }", variables: { sch: $schema }}' | curl -X POST -H "Content-Type: application/json" http://<**my-ipaddress-on-k8s**>:9000/admin -d @- | jq -r
Error:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 741 100 145 100 596 1198 4925 --:--:-- --:--:-- --:--:-- 6123
{
"errors": [
{
"message": "Unavailable: Server has not yet connected to Dgraph."
}
],
"extensions": {
"requestID": "34ad78ee-bd43-439a-875c-cfafef5baa74"
}
}