Skip to content

Conversation

liad5h
Copy link

@liad5h liad5h commented Jul 9, 2023

No description provided.

@hashicorp-cla
Copy link

hashicorp-cla commented Jul 9, 2023

CLA assistant check
All committers have signed the CLA.

@heatherezell heatherezell added enhancement New feature or request agent Area: Vault Agent (auth, templating, rendering, etc.) labels Jul 10, 2023
Copy link
Collaborator

@thyton thyton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liad5h Thank you for taking this on and being patient! The PR is generally on a good path :). I have some change requests. I'm happy to sync up and help out with addressing them if you need.

Would you mind dropping a small description in the PR and something like below in CHANGELOG.md under Unreleased?

Improvements:
* Add support to configure sidecar type (proxy or agent) and proxy's auto auth token use through Pod Annotations [GH-496](https://github.com/hashicorp/vault-k8s/pull/496)

"vault.hashicorp.com/agent-telemetry-stackdriver_namespace": "foo",
"vault.hashicorp.com/agent-telemetry-stackdriver_debug_logs": "false",
"vault.hashicorp.com/agent-telemetry-prefix_filter": `["+vault.token", "-vault.expire", "+vault.expire.num_leases"]`,
"vault.hashicorp.com/agent-telemetry-prefix_filter": `["+vault.token", "-vault.expire", "+vault.expire.num_leases"]`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you revert the accidental space?

}

func (a *Agent) sidecarType() string {
if a.SidecarType != "" && !(a.SidecarType == "agent" || a.SidecarType == "proxy") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if a.SidecarType != "" && !(a.SidecarType == "agent" || a.SidecarType == "proxy") {
if a.SidecarType != "" && (a.SidecarType == "agent" || a.SidecarType == "proxy") {

I think you meant if a.SidecarType is not empty, and a.SidecarType is "agent" or "proxy", then return a.SidecarType?

Comment on lines +288 to +290
arg := fmt.Sprintf(DefaultContainerArg, agent.SidecarType)
if container.Args[0] != arg {
t.Errorf("arg value wrong, should have been %s, got %s", arg, container.Args[0])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we also add a similar assertion for agent.ProxyUseAutoAuthToken?


if container.Args[0] != DefaultContainerArg {
t.Errorf("arg value wrong, should have been %s, got %s", DefaultContainerArg, container.Args[0])
arg := fmt.Sprintf(DefaultContainerArg, agent.SidecarType)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add different test cases under TestContainerSidecar() to test varying annotation sets containing 2 new annotations?

// AnnotationAgentSidecarType is the key of the annotation that controls whether
// a Vault agent or Vault proxy is injected into the pod
// Should be set to one of "agent" / "proxy", defaults to "agent".
AnnotationAgentSidecarType = "vault.hashicorp.com/sidecar-type"
// AnnotationAgentProxyUseAutoAuthToken is the key of the annotation that controls whether
// the auto auth token should be used in the vault proxy.
// configures the "use_auto_auth_token" key in the "api_proxy" stanza.
AnnotationAgentProxyUseAutoAuthToken = "vault.hashicorp.com/sidecar-proxy-use-auto-auth-token"

func TestContainerSidecar(t *testing.T) {
annotations := map[string]string{
AnnotationVaultRole: "foobar",
}
pod := testPod(annotations)

@rathberm
Copy link

@thyton is this the official pr for this topic? Vault agent api proxy will be removed in 2026 Q2, I think this will break a lot of use-cases of this project.
I'd be willing to take this on if you are not working on it already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Area: Vault Agent (auth, templating, rendering, etc.) enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants