Running a database on Kubernetes is still considered a bit of a novelty, but ArangoDB has been doing exactly that as part of their managed service, and has released the Kube-ArangoDB operator they built to do it, so we can do it too.
I found there was a bit of a learning curve with Kube-ArangoDB, so the idea here is to try to flatten it a bit for others. To do that I’ve created a repo showing a sane single instance setup using Kustomize and Minikube.
Kustomizing Kube-ArangoDB
The key file in that repo is the kustomization.yaml
file. Kube-ArangoDB installs into the default namespace, so we’re using kustomize’s namespace
option to ensure that everything ends up in the db
namespace.
The main event is the resources
: we’re pulling Kube-ArangoDB directly from GitHub and adding two files of our own.
The in the replicas
section we’re just saying to run only a single instance of the various operators (since we’re running a single instance of the database).
And finally, we’re saying a secret called arangodb
from a .env
file.
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: db
resources:
- db-namespace.yaml
- arangodeployment.yaml
- https://raw.githubusercontent.com/arangodb/kube-arangodb/1.1.3/manifests/arango-crd.yaml
- https://raw.githubusercontent.com/arangodb/kube-arangodb/1.1.3/manifests/arango-deployment.yaml
- https://raw.githubusercontent.com/arangodb/kube-arangodb/1.1.3/manifests/arango-storage.yaml
- https://raw.githubusercontent.com/arangodb/kube-arangodb/1.1.3/manifests/arango-deployment-replication.yaml
replicas:
- name: arango-deployment-replication-operator
count: 1
- name: arango-deployment-operator
count: 1
- name: arango-storage-operator
count: 1
secretGenerator:
- envs:
- arangodb.env
name: arangodb
namespace: db
generatorOptions:
disableNameSuffixHash: true
In the secretGenerator
section, we told Kustomize to expect a .env
file in the directory, so we should create that next. The values in that file will be used as the credentials for the root user.
cat < arangodb.env
username=root
password=test
EOF
Running it
The the setup complete, we’ll start minikube, and build and apply the config.
minikube start
kustomize build . | kubectl apply -f -
You can watch the creation of the pods and pvc, and when it looks like this, you’ll know it’s ready.
$ kubectl get po,pvc -n db
NAME READY STATUS RESTARTS AGE
pod/arango-deployment-operator-7c54bb947-67qdn 1/1 Running 0 3m49s
pod/arango-deployment-replication-operator-558b49f785-k99hf 1/1 Running 0 3m49s
pod/arango-storage-operator-68fb5f6949-zzf4c 1/1 Running 0 3m49s
pod/arangodb-sngl-miotcqdv-435cf0 2/2 Running 0 3m9s
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
persistentvolumeclaim/arangodb-single-miotcqdv Bound pvc-71fee7f0-2387-4985-a551-a79ab8671a34 10Gi RWO standard 3m9s
With that running, you can connect to the admin interface by forwarding the ports to your local machine. The name of the pod will be different for you.
kubectl port-forward -n db svc/arangodb 8529:8529
Forwarding from 127.0.0.1:8529 -> 8529
Forwarding from [::1]:8529 -> 8529
With that you should be able to connect to localhost:8529, with the credentials you gave above.
That was easy
I didn’t find Kube-ArangoDB super approachable at first. After piecing a few things together and a few reps, I’m really impressed with the how easy it is to get my favourite database up and running in Kubernetes.