How to deploy Ember app to kubernetes

#kubernetes#emberjs#javascript#docker

As part of my unfinished project observerio, I was working on my first Ember dashboard. After completing the prototype, I decided to deploy it as a pod in a Kubernetes cluster on DigitalOcean. Why Kubernetes? It can save a lot of time if you're a solo developer without enough resources to support a non-profitable idea.

During my first deployment, I found it relatively easy to build a release version of the Ember app. However, when opening the dashboard in a browser, I discovered that my routing wasn't working properly. After searching for solutions online, someone suggested modifying the Nginx settings when serving the Ember app.

Here's the Docker.release file used by the pod:

FROM alpine:3.6

COPY dist/ /app

WORKDIR /app

CMD ["tail", "-f", "/dev/null"]

I needed to figure out how to change the Nginx settings. Since I wasn't familiar with the internal workings of Kubernetes, my next step was to explore the containers running in the Kubernetes cluster. In the ingress pod I found the Nginx template used for serving my Ember pod.

nginx.tmpl

To ensure I was working with the same template as the installed ingress container, I copied nginx.tmpl from the container and added the following configuration (at line 458):

{{ if and (eq $path "/") (eq $server.Hostname "observer.rubyforce.co") }}
            try_files $uri $uri/ /index.html?/$request_uri;
{{ end }}

Then changed ingress controller to use the new template via config map, example of Deployment

Probably it could be helpful for someone as well.

Thanks for reading!

← Back to all posts

© Copyright 2023 Bitscorp