node.jskuberneteslighthouselighthouse-ci

How can I make an environment variable accessible to a nodejs process hosted in Kubernetes?


I am trying to host my own instance of Lighthouse-CI and the Lighthouse report viewer. By default, Lighthouse-CI automatically opens the report viewer on Google's GitHub, but for security reasons I am hosting my own.

Lighthouse-CI checks for the node environment variable VIEWER_ORIGIN, but I'm unsure how to set it when it's being hosted in k8s. Here's the relevant line in Lighthouse-CI's server code.

I've tried adding VIEWER_ORIGIN to my k8s deployment for my server, and it's showing correctly when I describe the pod, but it's not reflecting at all in the actual application. Here's my current config:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: lhci-deployment
  labels:
    app: server
spec: 
  replicas: 1
  selector: 
    matchLabels:
      app: server
  template: 
    metadata: 
      labels: 
        app: server
    spec: 
      containers:
      - name: lhci
        image: patrickhulce/lhci-server:0.13.0
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9001
        env: 
        - name: VIEWER_ORIGIN
          value: 'example.com'

Solution

  • Turns out that yes, the problem ended up being Lighthouse specific - the env variable that I wanted to set is only evaluated at build time, not run time. This was actually changed in a very recent MR, which you can see here.