-1

I have a running mongodb using sharding. I have made all the services i need, and i have mongodb uri to connect to mongos router. Now i want to use restheart container for http requests. I tried this:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: restheart
  labels:
    app: restheart
spec:
  replicas: 1
  selector:
    matchLabels:
      app: restheart
  template:
    metadata:
      labels:
        app: restheart
    spec:
      containers:
      - name: restheart-demo
        image: softinstigate/restheart
        #command:
                #- "--envFile /opt/restheart/etc/default.properties"
        ports:
        - containerPort: 8080
          protocol: TCP
        env:
        - name: MONGO_URI
          value: "mongodb://(uri here)"

then i used:

kubectl expose deploy restheart  --port 8080 --type NodePort

but get Requests return 401 code. I have to mention here that at my mongo uri i also included username:password, so that restheart not need to authenticate. how can i change the default settings of restheart at my yaml so that i can use it properly. There no documentation at all for restheart running at kubernetes My problem is that i dont know how to configure restheart when building my deploy with yaml file

  • HTT 401 is Unauthorized. Did you pass the credentials on your requests? Check https://restheart.org/docs/security/how-clients-authenticate/ – Andrea Di Cesare Sep 10 '20 at 12:31

1 Answers1

1

If you will check this URL.

You can see default value for mongo-uri = mongodb://127.0.0.1 You cant override this with environment variable. Instead, use volume mounts to replace that specific file with a configmap containing this file with changes and things should work.

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37
Saurabh Nigam
  • 795
  • 6
  • 12
  • thanks for your answer , i will check this out. As i am very new to kubernetes, can you please provide an example with volume mount? i would be gratefull. If not, thanks in advance. But let me comment this:You cant override this with environment variable my enviroment variable worked. But you are right, for further configuration i must do volume mount – Engineer_auth1234 Sep 08 '20 at 17:55
  • check this link https://kubernetes.io/docs/concepts/configuration/configmap/ – Saurabh Nigam Sep 08 '20 at 18:01
  • as i read restheart don't use insert command with post, instead it uses find and modify. That's a problem with sharding mongo: Write request for sharded collection must specify the shardkey. Use the 'shardkey' query parameter" – Engineer_auth1234 Sep 09 '20 at 16:56
  • If you don't know much K8s then another option is to edit the properties file (https://github.com/SoftInstigate/restheart/tree/master/core/etc/default.properties) and re-build the docker image with "docker build -t softinstigate/restheart ." Look at the Dockerfile https://github.com/SoftInstigate/restheart/blob/master/core/Dockerfile – mturatti Sep 09 '20 at 17:14