Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Implement ability to specify additional/override annotations when using Vault Secret Manager #556

Merged
merged 8 commits into from
Apr 19, 2023

Conversation

pradithya
Copy link
Member

@pradithya pradithya commented Apr 17, 2023

TL;DR

Add annotations configuration to the Vault Secret Manager to provide better flexibility when integrating with Vault.

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

When the Vault secret manager is enabled, flyte-pod-webhook is responsible for adding vault-specific annotation to the task pod that requests secret variables. These annotations are used to configure the Vault Agent behavior when retrieving and populating the secret from Vault. As of now, the annotation provided by flyte-pod-webhook is limited to the one implemented in vault_secret_manager.go.

This PR allows Flyte administrator to add additional or override default annotations providing better flexibility to customize Vault agent behavior. For example, the following configuration will set the Vault agent authentication type to use GCP and to immediately exit if the authentication failed.

      vaultSecretManager:
        kvVersion: "2"
        role: flyte
        annotations:
          vault.hashicorp.com/auth-config-type : "gce"
          vault.hashicorp.com/auth-type : "gcp"
          vault.hashicorp.com/agent-auto-auth-exit-on-err : "true"

Tracking Issue

NA

Follow-up issue

NA

@codecov
Copy link

codecov bot commented Apr 17, 2023

Codecov Report

Merging #556 (60927aa) into master (e4ca252) will increase coverage by 0.42%.
The diff coverage is 100.00%.

❗ Current head 60927aa differs from pull request most recent head dcf3113. Consider uploading reports for the commit dcf3113 to get more accurate results

@kumare3
Copy link
Contributor

kumare3 commented Apr 17, 2023

Cc @EngHabu / @hamersaw

KVVersion KVVersion `json:"kvVersion" pflag:"-,The KV Engine Version. Defaults to 2. Use 1 for unversioned secrets. Refer to - https://www.vaultproject.io/docs/secrets/kv#kv-secrets-engine."`
Role string `json:"role" pflag:",Specifies the vault role to use"`
KVVersion KVVersion `json:"kvVersion" pflag:"-,The KV Engine Version. Defaults to 2. Use 1 for unversioned secrets. Refer to - https://www.vaultproject.io/docs/secrets/kv#kv-secrets-engine."`
ExtraAnnotations map[string]string `json:"extraAnnotations" pflag:"-,Additional annotation to be added to the pod. Useful to further customize Vault integration (https://developer.hashicorp.com/vault/docs/platform/k8s/injector/annotations)"`
Copy link
Contributor

@hamersaw hamersaw Apr 17, 2023

Choose a reason for hiding this comment

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

Is the term extraAnnotations more descriptive than annotations? I think as long as we are explicit in the docs about which annotations Flyte automatically injects we can simplify this terminology.

Copy link
Member Author

Choose a reason for hiding this comment

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

Make sense, I think annotations is the better term since it not only allows Flyte administrator to add extra annotations but also overrides the default annotation created by Flyte.

{
name: "KVv3 Secret - with extra annotations",
args: args{
cfg: config.VaultSecretManagerConfig{Role: "flyte", KVVersion: config.KVVersion2, ExtraAnnotations: map[string]string{
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add some more examples here to cover the various override scenarios?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added cases where users provide their annotation via pod template annotations and system override annotation.

Copy link
Contributor

@hamersaw hamersaw left a comment

Choose a reason for hiding this comment

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

This is great! I think the only point of contention is ensuring users understand the default vault-specific annotations that Flyte sets so they don't assume this extraAnnotations argument needs to contain something already being set. Does it make sense to update these docs as part of this change as well?

Pradithya Aria and others added 6 commits April 18, 2023 10:14
…secret manager

Signed-off-by: Pradithya Aria <pradithya.pura@go-jek.com>
Signed-off-by: Jeev B <jeevb@users.noreply.github.com>
Signed-off-by: Pradithya Aria <pradithya.pura@go-jek.com>
…rg#554)

Signed-off-by: Jeev B <jeevb@users.noreply.github.com>
Signed-off-by: Pradithya Aria <pradithya.pura@go-jek.com>
* removed barrier logic

Signed-off-by: Daniel Rammer <daniel@union.ai>

* deprecated TransitionTypeBarrier

Signed-off-by: Daniel Rammer <daniel@union.ai>

* removed barrier tests

Signed-off-by: Daniel Rammer <daniel@union.ai>

* bumping flyteplugins

Signed-off-by: Daniel Rammer <daniel@union.ai>

---------

Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Pradithya Aria <pradithya.pura@go-jek.com>
…org#553)

* Check for TerminateExecution error and eat Precondition status

Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>

* lint

Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>

---------

Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Pradithya Aria <pradithya.pura@go-jek.com>
Signed-off-by: Pradithya Aria <pradithya.pura@go-jek.com>
@pradithya
Copy link
Member Author

Does it make sense to update these docs as part of this change as well?

Yes, will add a follow-up PR to update the Vault-related user guide once the PR is merged.

@pradithya pradithya changed the title Implement ability to specify additional annotations when using Vault Secret Manager Implement ability to specify additional/override annotations when using Vault Secret Manager Apr 18, 2023
@pradithya pradithya self-assigned this Apr 18, 2023
hamersaw
hamersaw previously approved these changes Apr 18, 2023
Copy link
Contributor

@hamersaw hamersaw left a comment

Choose a reason for hiding this comment

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

Minor nit, otherwise looks great.

pkg/webhook/vault_secret_manager.go Outdated Show resolved Hide resolved
Signed-off-by: Pradithya Aria <pradithya.pura@go-jek.com>
@bimtauer
Copy link
Contributor

Discovered this now when making some updates to my original contribution. I love this feature and its great to know that someone out there is also using flyte with vault :) One thing: I will rename the tests - you introduced a bunch of new ones named KVv3, KVv4 and so on. This was meant to represent the vault kv secret backend version to be tested. To my knowledge there are only 2.

@kumare3
Copy link
Contributor

kumare3 commented May 10, 2023

Tbh @bimtauer i atleast know 3/4 companies that use vault

eapolinario pushed a commit to eapolinario/flytepropeller that referenced this pull request Aug 9, 2023
…ng Vault Secret Manager (flyteorg#556)

* Implement ability to specify additional annotations when using Vault secret manager

Signed-off-by: Pradithya Aria <pradithya.pura@go-jek.com>

* Infer GOOS and GOARCH from environment (flyteorg#552)

Signed-off-by: Jeev B <jeevb@users.noreply.github.com>
Signed-off-by: Pradithya Aria <pradithya.pura@go-jek.com>

* fix makefile to read variables from environment and overrides (flyteorg#554)

Signed-off-by: Jeev B <jeevb@users.noreply.github.com>
Signed-off-by: Pradithya Aria <pradithya.pura@go-jek.com>

* Remove BarrierTick (flyteorg#545)

* removed barrier logic

Signed-off-by: Daniel Rammer <daniel@union.ai>

* deprecated TransitionTypeBarrier

Signed-off-by: Daniel Rammer <daniel@union.ai>

* removed barrier tests

Signed-off-by: Daniel Rammer <daniel@union.ai>

* bumping flyteplugins

Signed-off-by: Daniel Rammer <daniel@union.ai>

---------

Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Pradithya Aria <pradithya.pura@go-jek.com>

* Check for TerminateExecution error and eat Precondition status (flyteorg#553)

* Check for TerminateExecution error and eat Precondition status

Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>

* lint

Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>

---------

Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Pradithya Aria <pradithya.pura@go-jek.com>

* Rename to annotation

Signed-off-by: Pradithya Aria <pradithya.pura@go-jek.com>

* Inline merging annotations

Signed-off-by: Pradithya Aria <pradithya.pura@go-jek.com>

---------

Signed-off-by: Pradithya Aria <pradithya.pura@go-jek.com>
Signed-off-by: Jeev B <jeevb@users.noreply.github.com>
Signed-off-by: Daniel Rammer <daniel@union.ai>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Co-authored-by: Jeev B <jeevb@users.noreply.github.com>
Co-authored-by: Dan Rammer <daniel@union.ai>
Co-authored-by: Haytham Abuelfutuh <haytham@afutuh.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
6 participants