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

Pod Mutating Webhook & Secret Annotation Injector #242

Merged
merged 8 commits into from
Mar 22, 2021
Merged

Conversation

EngHabu
Copy link
Contributor

@EngHabu EngHabu commented Mar 19, 2021

Signed-off-by: Haytham Abuelfutuh [email protected]

TL;DR

Add a Pod Mutating WebHook cmd for flytepropeller. The current setup only implements a secrets injector that can either inject secrets available to FlytePropeller or k8s secrets.

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

  • flytepropeller webhook init-certs command issues a CA/Cert/PrivateKey and store them into a secret given a secret name
  • flytepropeller webhook creates a MutatingWebhookConfigration object in etcd., a webhook server and registers it with API Server. From there:
    1. It starts listening to Pods labeled with inject-flyte-secrets: true.
    2. Parses out annotations on the pod to know which secrets to inject
    3. Lookups the env (envVars and mounted files) for the secret, if found it'll inject it directly into the pod
    4. Adds k8s EnvFrom or VolumeMountSource to mount the right secret into the Pod
  • Plugin Manager change to automatically add inject-flyte-secrets: true to CRDs if the task has secrets in its TaskTemplate.

Tracking Issue

flyteorg/flyte#800

@EngHabu EngHabu requested a review from kumare3 as a code owner March 19, 2021 18:12
@EngHabu EngHabu marked this pull request as draft March 19, 2021 18:13
pkg/webhook/k8s_secrets.go Outdated Show resolved Hide resolved
pkg/webhook/k8s_secrets.go Outdated Show resolved Hide resolved
pkg/webhook/pod.go Outdated Show resolved Hide resolved
@kumare3
Copy link
Contributor

kumare3 commented Mar 19, 2021

few comments

EngHabu added 4 commits March 19, 2021 14:51
Signed-off-by: Haytham Abuelfutuh <[email protected]>
Signed-off-by: Haytham Abuelfutuh <[email protected]>
Signed-off-by: Haytham Abuelfutuh <[email protected]>
Signed-off-by: Haytham Abuelfutuh <[email protected]>
@codecov
Copy link

codecov bot commented Mar 22, 2021

Codecov Report

Merging #242 (1ea6a05) into master (0d1eeab) will increase coverage by 0.77%.
The diff coverage is 73.65%.

@EngHabu EngHabu marked this pull request as ready for review March 22, 2021 22:02
mgr, err := manager.New(kubecfg, manager.Options{
Port: cfg.ListenPort,
CertDir: cfg.CertDir,
Namespace: limitNamespace,
Copy link
Contributor

Choose a reason for hiding this comment

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

if we add multiple namespaces - how does this work?

Co-authored-by: Ketan Umare <[email protected]>
Signed-off-by: Haytham Abuelfutuh <[email protected]>
@kumare3 kumare3 self-requested a review March 22, 2021 23:28
kumare3
kumare3 previously approved these changes Mar 22, 2021
Copy link
Contributor

@kumare3 kumare3 left a comment

Choose a reason for hiding this comment

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

lgtm, can you update the readme for flytepropeller to add that it contains this too?

Signed-off-by: Haytham Abuelfutuh <[email protected]>
@EngHabu EngHabu merged commit 979fabe into master Mar 22, 2021
kumare3 added a commit that referenced this pull request May 25, 2021
* Pod Mutating Webhook & Secret Annotation Injector

Signed-off-by: Haytham Abuelfutuh <[email protected]>

* Marshal the entire secret object instead

Signed-off-by: Haytham Abuelfutuh <[email protected]>

* docs

Signed-off-by: Haytham Abuelfutuh <[email protected]>

* cmd docs

Signed-off-by: Haytham Abuelfutuh <[email protected]>

* refactor

Signed-off-by: Haytham Abuelfutuh <[email protected]>

* Unit tests

Signed-off-by: Haytham Abuelfutuh <[email protected]>

* Update pkg/utils/secrets/marshaler.go

Co-authored-by: Ketan Umare <[email protected]>
Signed-off-by: Haytham Abuelfutuh <[email protected]>

* introduce webhook in README

Signed-off-by: Haytham Abuelfutuh <[email protected]>

Co-authored-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
eapolinario pushed a commit to eapolinario/flytepropeller that referenced this pull request Aug 9, 2023
* Pod Mutating Webhook & Secret Annotation Injector

Signed-off-by: Haytham Abuelfutuh <[email protected]>

* Marshal the entire secret object instead

Signed-off-by: Haytham Abuelfutuh <[email protected]>

* docs

Signed-off-by: Haytham Abuelfutuh <[email protected]>

* cmd docs

Signed-off-by: Haytham Abuelfutuh <[email protected]>

* refactor

Signed-off-by: Haytham Abuelfutuh <[email protected]>

* Unit tests

Signed-off-by: Haytham Abuelfutuh <[email protected]>

* Update pkg/utils/secrets/marshaler.go

Co-authored-by: Ketan Umare <[email protected]>
Signed-off-by: Haytham Abuelfutuh <[email protected]>

* introduce webhook in README

Signed-off-by: Haytham Abuelfutuh <[email protected]>

Co-authored-by: Ketan Umare <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants