New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds a sidecar Dockerfile and startup script. #22
Conversation
|
||
COPY --from=build /ubbagent-src/bin/ubbagent /usr/local/bin/ubbagent | ||
COPY docker/ubbagent-start /usr/local/bin/ubbagent-start | ||
CMD ["/usr/local/bin/ubbagent-start"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is ubbagent-start
sufficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this form (CMD ["..."]), no shell is required to execute the command. So the full path is needed.
Could change to CMD ubbagent-start
, but I'm not sure that there's any benefit in doing so.
Dockerfile
Outdated
@@ -0,0 +1,32 @@ | |||
# Copyright 2018 Google Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Google LLC
now :) No need to update existing files I think, but for new files, we should use LLC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Thanks for the heads up.
|
||
set -e | ||
|
||
if [ -z "$AGENT_CONFIG_FILE" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional: you can do [ -v AGENT_CONFIG_FILE ]
file instead. This works with -u
enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the tip. I think I'll leave it as -z to catch cases in which the variable is set but is actually an empty string.
docker/ubbagent-start
Outdated
fi | ||
|
||
cat "$AGENT_CONFIG_FILE" | envsubst > /tmp/ubbagent-envsubst.yaml | ||
exec ubbagent --config /tmp/ubbagent-envsubst.yaml $STATE $HTTP --logtostderr --v=2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"$STATE" "$HTTP"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this works since $STATE and $HTTP can expand into multiple parameters?
Example: sh -c 'x="-n foo"; echo $x'
outputs "foo" with no newline, whereas sh -c 'x="-n foo"; echo "$x"'
actually outputs "-n foo".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use '=' between the parameter and argument, so that the entire arg is a single string. They're now quoted in the final command line.
I also wonder if we can add a README file somewhere to capture the env variables. |
Added text to README.md as well. |
6f06dd3
to
a12e8af
Compare
a12e8af
to
0ff4a20
Compare
When run as a sidecar container, the following env vars are used: AGENT_CONFIG_FILE - Required. The path to a file containing the agent's configuration. AGENT_STATE_DIR - Optional. The path under which the agent stores state. If this parameter is not specified, no state will be stored. AGENT_LOCAL_PORT - Optional. The pod-local port on which the agent's HTTP API will listen for reports and provide status. If this parameter is not specified, the agent will not start its HTTP server. The configuration file is run through envsubst, so it can contain any additional parameters as well. For example, a service account key and a servicecontrol consumerId may be stored in a Kubernetes secret and passed in as environment variables.
When run as a sidecar container, the following env vars are used:
AGENT_CONFIG_FILE - Required. The path to a file containing the agent's
configuration.
AGENT_STATE_DIR - Optional. The path under which the agent stores state.
If this parameter is not specified, no state will be stored.
AGENT_LOCAL_PORT - Optional. The pod-local port on which the agent's
HTTP API will listen for reports and provide status. If this parameter
is not specified, the agent will not start its HTTP server.
The configuration file is run through envsubst, so it can contain
any additional parameters as well. For example, a service account
key and a servicecontrol consumerId may be stored in a Kubernetes
secret and passed in as environment variables.