This demo illustrates some of the available service configuration options
kubectl apply -f service.yaml
After deployment, the config
application will expose the following endpoints:
/
Landing page with links to this endpoints/kn
Knative-specific data as defined in the Runtime Contract/req
Request context with environment variables and headers/res
Serving node info (Hostname, OS, Boot-time) and Pod available Memory/CPU resources/log
Content of specific log or log list in dir (e.g. /log?logpath=/var/log/app.log)
https://config.demo.knative.tech/
The JSON outputting endpoints (/kn
, /req
, /res
) include request metadata object. This provides context for each response and is useful when persisting returned data for evaluation/texting.
{
"meta": {
"id": "215bb44e-0513-44a5-a640-fc1546daf294",
"ts": "2019-01-04T20:09:12.52097224Z",
"uri": "/req",
"host": "config.demo.knative.tech",
"method": "GET"
},
...
The /req
endpoint provides an easy way to eval expected environment variables or headers for your requests. For example to get a release version of the config
app you would execute:
curl -s https://config.demo.knative.tech/req | jq '.envs.RELEASE'
Or to get your user-agent
as seen by the Knative service
curl -s https://config.demo.knative.tech/req | jq '.head."user-agent"'
The /node
endpoint provides information about the node which is serving your request. For example to see the boot time of that node and its hostname
curl -s https://config.demo.knative.tech/res | jq '.node.bootTs,.meta.host'
The /kn
endpoint is what you would use to evaluate Knative-specific data. In addition to the Knative environment variables (PORT
and ones prefixed by K_
like K_CONFIGURATION
, K_REVISION
, and K_SERVICE
), the /kn
endpoint also exposes information about the recommended file system mounts (e.g. /tmp
, /var/log
, or /dev/log
).
To test for example if the /etc/hosts
has the required R/W
permissions you can run this query. It searches for comment
in the returned document where access
group name == "DNS"
and and the item within that group has the path == /etc/hosts
curl -s https://config.demo.knative.tech/kn \
| jq -r --arg group "DNS" \
'.access[] | if .group == $group then . else empty end' \
| jq -r --arg path "/etc/hosts" \
'.list[] | if .path == $path then .comment else empty end'
The /log
endpoint returns the log file specified by the logpath
parameter in query string. ((e.g. /log?logpath=/var/log/config.log)). If the logpath
parameter is a directly the /log
will return a list of content in that directory.
Note,
config
by default writes logs tostdout
unless theLOG_TO_FILE
environment variable is set (anything other than "" will do). If that variable is set,ktest
will output its own logs to/var/log/config.log
Note, currently the
/log
endpoint will not return any logs larger than1MB
.
To search log you can pipe the /log
output through greb
. For example to find out the port
on which the server started
curl -s https://config.demo.knative.tech/log?logpath=/var/log/config.log \
| grep 'Server starting on port'