PROLOGUE: When i first attempted to deploy Olive.1 on Kubernetes using tutor 15.x I got blank screens for all enabled MFEs. Interestingly , the same MFEs worked fine when deploying to an AWS EC2 instance using tutor’s quick start instructions. Hence, the problem was clearly and directly related to Kubernetes configuration. Following were the two hard-fought battles that I went through to get MFEs working on Kubernetes.
For any enabled MFE url end point deployed to Kubernetes, i initally saw the following three errors in Chrome’s JS console window:
My configuration work with regards to MFEs was limited to the following two command lines:
pip install tutor-mfe
tutor plugins enable mfe
I verified the following:
- the Docker container deployed, hub.docker.com/r/overhangio/openedx-mfe, is the same for both k8s and local
- k8s ingress correctly reaches the static assets in the container. That is, the MFE endpoints return the same contents for both k8s and local.
- the bash environment variable values in the container are the same for both k8s and local
- the mfe container runs
caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
for both k8s and local
Problem 1: Proxy service setup
One difference that i found is in the proxy services. Tutor local uses Caddy to listen on ports 80 and 443 and to proxy upstream, whereas k8s (in my case) is using nginx. Tutor’s Caddy proxy includes a couple of entries that were not present in the nginx.conf of my nginx container on k8s. These included the following:
I duplicated the path and additional header in the nginx controller as follows:
Afterwards, the MFE container correctly orchestrated the generation of the mfe_config url end point:
Note however, that all of the urls in the dict above are “http” rather than “https”, leading to the other problem.
Problem 2: Mixed Content errors in the browser
the tutor-mfe plugin is designed for a single-server deployment in which the tutor setting ENABLE_HTTPS works well as a once-size-fits-all toggle for whether or not to use http or https. But in Kubernetes deployments this setting requires more finesse. I ultimately created this tutor patch to iron out the http protocol settings.
And now, everything works!