Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run dat inside kubernetes #1158

Open
dwiel opened this issue Oct 24, 2019 · 14 comments
Open

How to run dat inside kubernetes #1158

dwiel opened this issue Oct 24, 2019 · 14 comments

Comments

@dwiel
Copy link

dwiel commented Oct 24, 2019

Is anyone successfully running dat from inside kubernetes? The following Deployment is currently working for me, but it would be nice to avoid requiring hostNetwork: true. Also wondering how to best specify the .dat keys. I am currently sharing them from the host which works all right in this scenario, but isn't a very general solution. Also, the node this container is running on essentially has a public ip which might be making this easier. I haven't yet tested it from inside kubernetes on a node without a public ip.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: dat-server
  labels:
    app: dat-server
spec:
  replicas: 1
  selector:
    matchLabels:
      app: dat-server
  template:
    metadata:
      labels:
        app: dat-server
    spec:
      volumes:
        - name: nfs
          hostPath:
            path: /mnt/nfs
            type: Directory
        - name: dat-key
          hostPath:
            path: /root/.dat
            type: Directory
        # kubernetes secrets can't have subdirectories so this doesn't work
        # - name: dat-key
        #   secret:
        #     secretName: dat-key
      containers:
      - name: dat-server
        image: registry/dat:latest
        command:
          - "dat"
          - "share"
          - "/mnt/nfs/"
          # - "sleep"
          # - "300"
        volumeMounts:
          - name: nfs
            mountPath: /mnt/nfs
          - name: dat-key
            mountPath: /root/.dat
      # this gets dat network access, otherwise i get symmetric nat errors from dat doctor
      hostNetwork: true
      # sort of a hack, run this only on the node running the nfs server
      nodeSelector:
        nfs: server
# ---
# # I was still unable to access dat with this service
# kind: Service
# apiVersion: v1
# metadata:
#   name: dat-server
# spec:
#   type: NodePort
#   selector:
#     app: dat-server
#   ports:
#   - name: dat-tcp
#     protocol: TCP
#     nodePort: 30282
#     port: 30282
#     targetPort: 30282
#   - name: dat-udp
#     protocol: UDP
#     nodePort: 30282
#     port: 30282
#     targetPort: 30282
@RangerMauve
Copy link
Contributor

I think @ninabreznik and @Jam10o were messing around with getting it to work in docker. I'd assume that it'll be hard to get incoming connections to work (or the DHT?), but I don't have hands on experience with it myself.

@dwiel
Copy link
Author

dwiel commented Oct 30, 2019

Thanks, btw I've tested the above solution on nodes that dont have public ips with success. Would still like avoid hostNetwork: true, but it is running. I've also had it working in docker with udp and TCP ports opened as well.

@ninabreznik
Copy link
Member

@dwiel that's great. Can you share your dockerfile to see your configuration and hopefully make it run too?

Thanks @RangerMauve for a ping!

@dwiel
Copy link
Author

dwiel commented Oct 30, 2019

The dockerfile is very simple:

FROM node:11

# https://stackoverflow.com/a/45505787/2093984
RUN npm -g config set user root

RUN npm cache clean --force

RUN npm install -g dat

@dwiel
Copy link
Author

dwiel commented Oct 30, 2019

From another thread here i got the flags for running inside of docker (not kubernetes): -p 3282:3282/udp -p 3282:3282/tcp

@ninabreznik
Copy link
Member

Thanks, @dwie. I actually tried this but it somehow doesn't work. Maybe I am missing something else here, but if you want to check my repo that I containerize and run on Digital Ocean, please check it out and if you have any comment/suggestion, please let me know https://github.com/ninabreznik/ethplay

@dwiel
Copy link
Author

dwiel commented Oct 30, 2019

It looks like you are missing udp port 3282. You have to open udp ports independently from tcp ports.

@ninabreznik
Copy link
Member

It looks like you are missing udp port 3282. You have to open udp ports independently from tcp ports.

Like this? https://github.com/ninabreznik/ethplay/blob/master/Dockerfile

I tried this and then ran it on Digital Ocean with a command -p 3282:3282/tcp -p 3282:3282/udp
but sadly still nothing :/

@dwiel
Copy link
Author

dwiel commented Oct 31, 2019

Hmm, that looks right. Have you tried running dat doctor from inside the container? That helped me debug my setup.

@ninabreznik
Copy link
Member

ninabreznik commented Oct 31, 2019 via email

@dpaez
Copy link

dpaez commented Oct 31, 2019

This is interesting. @ninabreznik you can try add DEBUG=discovery-swarm-web-server to your npm discovery script, so it would be something like this:

"scripts": {
  "start": "node app.js",
  "discovery": "DEBUG=discovery-swarm-web-server discovery-swarm-web"
}

If everything is starting OK, the debug should output any connection error. Maybe that could help to debug.

@ninabreznik
Copy link
Member

@dpaez That's cool, thanks. Now, I see that there is another problem. And that's the fact that discovery-swarm-web doesn't support hypertrie... Any idea how to fix this? Or how to use hyperswarm in the browser?

@dpaez
Copy link

dpaez commented Nov 1, 2019

@ninabreznik I haven't used hypertrie directly nor in the browser yet. But I give it a look to the discovery-swarm-web dependencies and seems like hyperdiscovery needs an update to be compatible with the latest hypercore-protocol used by hypertrie. Withouth that discovery-swarm-web wont work with hypertries directly. That's my guess.

@ninabreznik
Copy link
Member

Thanks @dpaez, looks like something @RangerMauve mentioned too. He'll try to help out and we'll see what needs to be done and how to fix it :)

Thanks a lot for helping out. Will share my findings once I make it work 👯‍♀️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants