I’ve struggled through getting a dgraph running on an on-premise K8S cluster (version 1.9.5) and there are number of tweaks. Most importantly, I needed the set the hostPort property on the StatefulSet for the dgraph server replicas. Have others run into this?
Essentially, it looks something like this:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: dgraph-server
spec:
serviceName: "dgraph-server"
replicas: 3
selector:
matchLabels:
app: dgraph-server
template:
metadata:
labels:
app: dgraph-server
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- dgraph-server
topologyKey: kubernetes.io/hostname
containers:
- name: server
image: dgraph/dgraph:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 7080
hostPort: 7080
name: server-grpc-int
- containerPort: 8080
name: server-http
- containerPort: 9080
name: server-grpc
volumeMounts:
- name: datadir
mountPath: /dgraph
command:
- bash
- "-c"
- |
set -ex
dgraph server --my=$(hostname -f):7080 --memory_mb=65535 --zero=dgraph-zero-0.dgraph-zero:5080
terminationGracePeriodSeconds: 60
volumes:
- name: datadir
persistentVolumeClaim:
claimName: datadir
updateStrategy:
type: RollingUpdate
volumeClaimTemplates:
- metadata:
name: datadir
annotations:
volume.beta.kubernetes.io/storage-class: dgraph-storage-server
spec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: 100Gi
Also, oddly, this service seems to be broken:
apiVersion: v1
kind: Service
metadata:
name: dgraph-server-0-http-public
labels:
app: dgraph-server
spec:
type: LoadBalancer
ports:
- port: 8080
targetPort: 8080
name: server-http
selector:
statefulset.kubernetes.io/pod-name: dgraph-server-0
I can port-forward the dgraph-server-0 http protocol and everything is fine. This might be an issue with our on-premise k8s deployment too.