# Running Stardog in local Kubernetes cluster

**URL:** <https://community.stardog.com/t/running-stardog-in-local-kubernetes-cluster/3419>\
**Category:** Support\
**Created:** [December 17, 2021, 3:00pm UTC](https://community.stardog.com/t/running-stardog-in-local-kubernetes-cluster/3419 "2021-12-17T15:00:41Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnniemorrow](https://avatars.discourse-cdn.com/v4/letter/j/ee7513/32.png) [@johnniemorrow](https://community.stardog.com/u/johnniemorrow)\
**Post date:** [December 17, 2021, 3:00pm UTC](https://community.stardog.com/t/running-stardog-in-local-kubernetes-cluster/3419/1 "2021-12-17T15:00:41Z")

</div>

Hi Stardog Community,

I wanted to try out Stardog in Kubernetes by running it in a local cluster.

I signed up to get a licence key, created a [k3d](https://k3d.io) cluster, and installed it using [the helm charts](https://github.com/stardog-union/helm-charts) like this:

#!/bin/bash -eu

k3d cluster create --servers 3 --image rancher/k3s:v1.21.8-rc1-k3s1

kubectl create namespace stardog  
kubectl -n stardog create secret generic stardog-license --from-file stardog-license-key.bin=./stardog-license-key.bin  
helm repo add stardog [Stardog Helm Chart | helm-charts](https://stardog-union.github.io/helm-charts/)  
helm install stardog --namespace stardog stardog/stardog   
--set persistence.storageClass=local-path   
--set persistence.size=200Mi   
--set zookeeper.persistence.storageClass=local-path   
--set zookeeper.persistence.size=200Mi

The install takes a few minutes and then all stardog & zookeeper pods are running, and I can see the stardog loadbalancer service running:  
$ kubectl -n stardog get svc  
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE  
stardog-stardog LoadBalancer 10.43.114.130 172.19.0.2,172.19.0.3,172.19.0.4 5820:31499/TCP 14m  
stardog-zookeeper ClusterIP 10.43.90.151 2181/TCP,2888/TCP,3888/TCP 14m  
stardog-zookeeper-headless ClusterIP None 2181/TCP,2888/TCP,3888/TCP 14m

If I go to that LoadBalancer, 172.19.0.2:5820 it asks me to log in and I can login as admin. But after that it redirects me to [https://apps.stardog.com/](https://apps.stardog.com/) which looks like a hosted version. Is there a step I'm missing, or has anyone else tried it out on k3d/kind/minikube?

Thanks!  
John

---

<div class="post-metadata">

**Author:** ![pdmars](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pdmars/32/17_2.png) [@pdmars](https://community.stardog.com/u/pdmars)\
**Post date:** [December 17, 2021, 3:09pm UTC](https://community.stardog.com/t/running-stardog-in-local-kubernetes-cluster/3419/2 "2021-12-17T15:09:27Z")

</div>

Hi John,

That sounds like everything is working as expected in your local k8s cluster. You can use Stardog directly via that IP:port with the cli, or if you login through the browser [apps.stardog.com](http://apps.stardog.com) provides you with our suite of FE tools you can also use to interact with your local Stardog. For example, you can use studio through the browser and have it connect to Stardog.

Let us know if you have any questions about that.

Paul

---

<div class="post-metadata">

**Author:** ![johnniemorrow](https://avatars.discourse-cdn.com/v4/letter/j/ee7513/32.png) [@johnniemorrow](https://community.stardog.com/u/johnniemorrow)\
**Post date:** [December 17, 2021, 5:09pm UTC](https://community.stardog.com/t/running-stardog-in-local-kubernetes-cluster/3419/3 "2021-12-17T17:09:27Z")

</div>

Thanks Paul.

I was thinking that if I'm connect to [apps.stardog.com](http://apps.stardog.com) that it wouldn't be able to connect to a Stardog instance running in my local kubernetes cluster as the loadbalancer service is a local 172 ip address. So I ran:

docker run --name=stardog-studio -p 8888:8080 -d stardog/stardog-studio:3.2.0

...and I can go to localhost:8888 in my browser, point it to 172.19.0.2:5820 and login there, so that's good.

From there, I tried to create a test database in the UI but it pops up a 405 Not Allowed. I did an apt install stardog to get the stardog & stardog-admin CLIs and tried to create a db using the stardog-admin cli but that gives the the following error:

~/stardog $ cat stardog.sdpass  
_:_:\*:admin:admin  
~/stardog $ STARDOG\_HOME=/home/stardog /opt/stardog/bin/stardog-admin db create -n test --server 172.19.0.2:5820  
Unable to connect to server at [http://localhost:5820](http://localhost:5820) Connection refused (Connection refused).

Should I be able to create a db through the UI logged in as admin? I'm wondering if that's an issue with my kubernetes install or something else.

Thanks,  
John.

---

<div class="post-metadata">

**Author:** ![pdmars](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pdmars/32/17_2.png) [@pdmars](https://community.stardog.com/u/pdmars)\
**Post date:** [December 17, 2021, 5:41pm UTC](https://community.stardog.com/t/running-stardog-in-local-kubernetes-cluster/3419/4 "2021-12-17T17:41:51Z")

</div>

A few things.

1. You can use the studio delivered to your browser to connect to a local install of Stardog. Simply give it the same ip:port that the service exposes. You don't need to run studio in docker locally to connect to a local install of Stardog.

2. Try running just the stardog-admin command to create the db: `/opt/stardog/bin/stardog-admin --server http://172.19.0.2:5820 db create -n test`

Paul

---

<div class="post-metadata">

**Author:** ![pdmars](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pdmars/32/17_2.png) [@pdmars](https://community.stardog.com/u/pdmars)\
**Post date:** [December 17, 2021, 6:00pm UTC](https://community.stardog.com/t/running-stardog-in-local-kubernetes-cluster/3419/5 "2021-12-17T18:00:40Z")

</div>

Also, it wouldn't hurt to check the stardog logs on the pods to make sure everything started fine and without errors. Assuming the pods went to `running` in k8s, that should be the case, but it's easy to check just in case something else went wrong. Both the stdout of the pods may have info as well as the full log in `/var/opt/stardog/stardog.log` inside the stardog pods.

---

<div class="post-metadata">

**Author:** ![johnniemorrow](https://avatars.discourse-cdn.com/v4/letter/j/ee7513/32.png) [@johnniemorrow](https://community.stardog.com/u/johnniemorrow)\
**Post date:** [December 17, 2021, 7:46pm UTC](https://community.stardog.com/t/running-stardog-in-local-kubernetes-cluster/3419/6 "2021-12-17T19:46:56Z")

</div>

Thanks for the stardog-admin example Paul - I realized I was passing in the --server in the wrong place, instead of an arg to stardog-admin I had put it at the end after db create -n john and it wasn't picking it up. I noticed that some of the other commands do complain about that e.g. stardog-admin db list --server [http://etc](http://etc) gives an error about an unexpected --server param, but not on the db create.

I created a few databases from the command line, and tried listing them - but I seem to be getting changing results like below:

~/stardog$ /opt/stardog/bin/stardog-admin --server [http://172.19.0.2:5820](http://172.19.0.2:5820) db list  
+-----------+  
| Databases |  
+-----------+  
| test2 |  
+-----------+  
~/stardog$ /opt/stardog/bin/stardog-admin --server [http://172.19.0.2:5820](http://172.19.0.2:5820) db list  
+-----------+  
| Databases |  
+-----------+  
| test2 |  
| test4 |  
| test5 |  
+-----------+  
~/stardog$ /opt/stardog/bin/stardog-admin --server [http://172.19.0.2:5820](http://172.19.0.2:5820) db list  
+-----------+  
| Databases |  
+-----------+  
| test |  
| test2 |  
| test3 |  
| test4 |  
+-----------+  
~/stardog$ /opt/stardog/bin/stardog-admin --server [http://172.19.0.2:5820](http://172.19.0.2:5820) db list  
+-----------+  
| Databases |  
+-----------+  
| test2 |  
| test4 |  
| test5 |  
+-----------+  
~/stardog$ /opt/stardog/bin/stardog-admin --server [http://172.19.0.2:5820](http://172.19.0.2:5820) db list  
+-----------+  
| Databases |  
+-----------+  
| test2 |  
| test4 |  
| test5 |  
+-----------+  
~/work/stardog$ /opt/stardog/bin/stardog-admin --server [http://172.19.0.2:5820](http://172.19.0.2:5820) db list  
+-----------+  
| Databases |  
+-----------+  
| test2 |  
+-----------+

---

<div class="post-metadata">

**Author:** ![pdmars](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pdmars/32/17_2.png) [@pdmars](https://community.stardog.com/u/pdmars)\
**Post date:** [December 17, 2021, 7:52pm UTC](https://community.stardog.com/t/running-stardog-in-local-kubernetes-cluster/3419/7 "2021-12-17T19:52:42Z")

</div>

Are you using a Stardog free license? I suspect what happened is you have 3 single node Stardogs that are running instead of a single stardog cluster with 3 nodes. Then when you make requests to the k8s service is selects one of the standalone Stardogs to handle the request. We can verify this by checking the output of Stardog when it starts in `/var/opt/stardog/stardog.log` inside the containers.

For Stardog free you'll need to set `cluster.enabled=false` and `replicaCount=1` when you deploy Stardog with helm or you'll need to get a license that supports the cluster.

---

<div class="post-metadata">

**Author:** ![johnniemorrow](https://avatars.discourse-cdn.com/v4/letter/j/ee7513/32.png) [@johnniemorrow](https://community.stardog.com/u/johnniemorrow)\
**Post date:** [December 17, 2021, 8:31pm UTC](https://community.stardog.com/t/running-stardog-in-local-kubernetes-cluster/3419/8 "2021-12-17T20:31:53Z")

</div>

Yes, I believe it's a free license - I just signed up yesterday. The only settings of the helm chart I overwrote were the persistence storageClass & size ones (at the top of this thread). I don't see any mention of cluster in /var/opt/stardog/stardog.log so it could be three separate instances. I'll do a reinstall and set the cluster.enabled=false and replicaCount=1.

---

<div class="post-metadata">

**Author:** ![pdmars](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pdmars/32/17_2.png) [@pdmars](https://community.stardog.com/u/pdmars)\
**Post date:** [December 17, 2021, 8:34pm UTC](https://community.stardog.com/t/running-stardog-in-local-kubernetes-cluster/3419/9 "2021-12-17T20:34:16Z")

</div>

Sounds good. Let us know if you have any trouble.

If the Stardogs were forming a cluster you would see messages about the nodes joining (and who else is a member) at startup.

---

<div class="post-metadata">

**Author:** ![johnniemorrow](https://avatars.discourse-cdn.com/v4/letter/j/ee7513/32.png) [@johnniemorrow](https://community.stardog.com/u/johnniemorrow)\
**Post date:** [December 17, 2021, 8:58pm UTC](https://community.stardog.com/t/running-stardog-in-local-kubernetes-cluster/3419/10 "2021-12-17T20:58:47Z")

</div>

Thanks Paul - that did the trick! I get consistent results from the stardog-admin db list command now - I can also select one of those databases I've created from the dropdown when I run stardog-studio via docker.

---

<div class="post-metadata">

**Author:** ![pdmars](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pdmars/32/17_2.png) [@pdmars](https://community.stardog.com/u/pdmars)\
**Post date:** [December 17, 2021, 9:00pm UTC](https://community.stardog.com/t/running-stardog-in-local-kubernetes-cluster/3419/11 "2021-12-17T21:00:25Z")

</div>

That's great to hear!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [December 31, 2021, 9:00pm UTC](https://community.stardog.com/t/running-stardog-in-local-kubernetes-cluster/3419/12 "2021-12-31T21:00:33Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
