Erxes on Kubernetes

This is Erxes as a Kubernetes Application. It is essentially the Kubernetes-equivalent of the docker-compose.yml described in the Erxes docs.

Usage

You'll need kubectl.

From anywhere with internet access:

kubectl kustomize github.com/gobengo/erxes-k8s

This will print a stream of YAML to stdout. Apply it to your kubernetes cluster like

kubectl kustomize github.com/gobengo/erxes-k8s | kubectl apply -f -

If you have this repo locally, you can similarly build the YAML like kubectl kustomize ..

Don't have a Kubernetes Cluster?

If you have docker, you can probably use kind.

Install kind (requires golang):

GO111MODULE="on" go get sigs.k8s.io/kind@v0.4.0

Create a local kubernetes cluster running in docker using kind:

kind create cluster # then wait a bit
export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
kubectl create ns erxes
kubectl config set-context --current --namespace=erxes
kubectl kustomize github.com/gobengo/erxes-k8s | kubectl apply -f -

# Keep an eye on the pods as they come up. It'll take a bit because erxes docker containers are all being fetched in parallel.
watch kubectl get pods

# Once they're running, access things through the erxes-router service
kubectl port-forward svc/erxes-router 32402:80 & # Note this '32402' is tightly coupled with the default values in erxes-common ConfigMap
open http://localhost:32402 # This may open a web browser, e.g. on a mac, or it may not. If it doesn't work, use your web browser manually.

Kustomizing

You can (and probably should) use this as a base to build on top of, kustomizing to meet your needs.

  • You definitely will need to provide the right hostname at which you plan to access your Erxes deployment. You do this by using kustomize configMapGenerator to override the ERXES_HOST var in the ConfigMap named parameters. There is an example of how to do this in ./lib/test-override-host
    • I filed this issue with erxes to discuss allowing some of these values to support relative URLs so that deployments using this recipe work a little bit better without this parameters. However, this configuration will always be required for things like erxes email notifications to be able to link back to the running web app.
  • The included redis and mongodb definitions are pretty basic. You may want to configure those or bring your own.