diff --git a/README.md b/README.md index 604d5b97..c036a644 100644 --- a/README.md +++ b/README.md @@ -197,6 +197,7 @@ Environmental variables: | `log_call_id` | In HTTP mode, when printing a response code, content-length and timing, include the X-Call-Id header at the end of the line in brackets i.e. `[079d9ff9-d7b7-4e37-b195-5ad520e6f797]` or `[none]` when it's empty. Default: `false` | | `max_inflight` | Limit the maximum number of requests in flight, and return a HTTP status 429 when exceeded | | `mode` | The mode which of-watchdog operates in, Default `streaming` [see doc](#3-streaming-fork-modestreaming---default). Options are [http](#1-http-modehttp), [serialising fork](#2-serializing-fork-modeserializing), [streaming fork](#3-streaming-fork-modestreaming---default), [static](#4-static-modestatic) | +| `namespace_mount_path | Path used by the watchdog to lookup the namespace the function is deployed in. | `/var/run/secrets/kubernetes.io/serviceaccount/namespace` | | `port` | Specify an alternative TCP port for testing. Default: `8080` | | `prefix_logs` | When set to `true` the watchdog will add a prefix of "Date Time" + "stderr/stdout" to every line read from the function process. Default `true` | | `read_timeout` | HTTP timeout for reading the payload from the client caller (in seconds) | diff --git a/executor/jwt_authenticator.go b/executor/jwt_authenticator.go index 0c05e08d..39b92c9d 100644 --- a/executor/jwt_authenticator.go +++ b/executor/jwt_authenticator.go @@ -207,7 +207,12 @@ func getFnName() (string, error) { } func getFnNamespace() (string, error) { - nsVal, err := os.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace") + namespacePath := "/var/run/secrets/kubernetes.io/serviceaccount/namespace" + if v, ok := os.LookupEnv("namespace_mount_path"); ok && len(v) > 0 { + namespacePath = v + } + + nsVal, err := os.ReadFile(namespacePath) if err != nil { return "", err }