https://github.com/kilna/envhttpd
A dockerized HTTPD for serving environment variables
https://github.com/kilna/envhttpd
Last synced: 8 months ago
JSON representation
A dockerized HTTPD for serving environment variables
- Host: GitHub
- URL: https://github.com/kilna/envhttpd
- Owner: kilna
- License: mit
- Created: 2024-05-14T07:22:28.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-23T00:24:13.000Z (over 1 year ago)
- Last Synced: 2024-05-23T06:53:42.760Z (over 1 year ago)
- Language: Shell
- Size: 48.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.yml
- License: LICENSE
Awesome Lists containing this project
README
# envhttpd
**HTTP Server for Environment Variables**
[](https://hub.docker.com/r/kilna/envhttpd)
[](https://hub.docker.com/r/kilna/envhttpd)
[](https://hub.docker.com/r/kilna/envhttpd)
[](https://hub.docker.com/r/kilna/envhttpd)
[](https://hub.docker.com/r/kilna/envhttpd)[](https://github.com/kilna/envhttpd)
[](https://github.com/kilna/envhttpd/forks)
[](https://github.com/kilna/envhttpd/watchers)
[](https://github.com/kilna/envhttpd/stargazers)A web server that delivers environment variables as HTML, JSON, YAML, and
shell-evaluable script, and discrete curl-able endpoints. It allows filtering of
environment variables based on inclusion and exclusion patterns to control what
is exposed.With a docker image weighing in at less than 1mb, it is ideal to use as a
queryable pod metadata sidecar in Kubernetes, or any situation in which you need
to expose simple data without a lot of overhead.## Examples
All of the below use a docker container... when running locally just replace
`docker run ... kilna/envhttpd` with `envhttpd` and make sure the environment
variables are available (e.g. `export foo=bar`).### Running the container
Fire up a container...
```
$ docker run -e foo=bar -e yo=bro -p 8111:8111 -d kilna/envhttpd
Server is running at http://localhost:8111
```Now point your browser at http://localhost:8111 and you should see something
like this:
#### Providing command line options to the container
Everything after the image name `kilna/envhttpd` is passed as arguments to the
`envhttpd` binary (see [Command-Line Help](#command-line-help) for more details).```
$ docker run -e foo=bar -e yo=bro -p 8222:8222 -d kilna/envhttpd -p 8222 -i foo -x yo -H envhttpd.local
Server is running at http://envhttpd.local:8222
```### Text
Get a specific environment variable's value as plain UTF-8 text:
```
$ curl localhost:8111/var/foo
bar
```### JSON
Get all included environment variables as a JSON dictionary:
```
$ curl localhost:8111/json
{"foo":"bar","yo":"bro"}$ curl localhost:8111/json?pretty
{
"foo": "bar",
"yo": "bro"
}
```### YAML
Get all included environment variables as a YAML dictionary:
```
$ curl localhost:8111/yaml
---
foo: bar
yo: bro
```### Shell
Get all included environment variables as a shell-evaluable script:
```
$ curl localhost:8111/sh
foo="bar"
yo="bro"$ curl localhost:8111/sh?export
export foo="bar"
export yo="bro"
```### Kubernetes
See the [kubernetes example](./kubernetes/) for [pod](./kubernetes/pod/) and
[sidecar deployment](./kubernetes/sidecar/) under the `kubernetes/` folder.## Command-Line Help
```
$ envhttpd -h
Usage: envhttpd [OPTIONS]envhttpd is a lightweight HTTP server designed to expose env vars
in HTML, JSON, YAML, and evaluatable shell formats. It allows
filtering of environment variables based on inclusion and exclusion
patterns to control what is exposed.Options:
-p PORT Specify the port number the server listens on.
Default is 8111.
-i PATTERN Include env vars matching the specified PATTERN.
Supports glob patterns (e.g., APPNAME_*).
Default behavior is to include all env vars except
PATH and HOME since they're largely not relevant outside
of a container.
-x PATTERN Exclude env vars matching the specified PATTERN.
Supports glob patterns (e.g., DEBUG*, TEMP).
-d Run the server as a daemon in the background.
(Does not make sense in a docker container)
-D Enable debug mode logging and text/plain responses.
-H HOSTNAME Specify the hostname of the server.
-h Display this help message and exit.Endpoints:
/ Displays a web page listing all included env vars.
/json Gets env vars in JSON format.
/json?pretty Gets env vars in pretty-printed JSON format.
/yaml Gets env vars in YAML format.
/sh Gets env vars in shell evaluatable format.
/sh?export Gets env vars as shell with `export` prefix.
/var/VARNAME Gets the value of the specified env var.envhttpd, Copyright © 2024 Kilna, Anthony https://github.com/kilna/envhttpd
```## License
[MIT Link License](./LICENSE)
## Author
[Kilna, Anthony](http://github.com/kilna)
[kilna@kilna.com](mailto:kilna@kilna.com)