bank-vaults / bank-vaults

A Vault swiss-army knife: A CLI tool to init, unseal and configure Vault (auth methods, secret engines).
https://bank-vaults.dev
Apache License 2.0
2.06k stars 469 forks source link

[vault-secrets-webhook] pod mutation with multiple imagePullSecrets if first secret not found #1269

Open alexey-ban opened 3 years ago

alexey-ban commented 3 years ago

Describe the bug: K8s is able to pull images using the provided pull secrets, even if one of them doesn't exist

vault-secrets-webhook picks the first listed imagePullSecret and broke if it not found

Expected behaviour: vault-secrets-webhook should attempt all listed imagePullSecrets to find the one that works.

Steps to reproduce the bug:

  1. Create deployment with 2 imagePullSecrets:
    imagePullSecrets:
    - name: registry1
    - name: registry2
  2. Create only second (registry2) with valid credentials

Additional context: Add any other context about the problem here.

Environment details:

/kind bug

bonifaido commented 3 years ago

Hi @alexey-ban, which version of the webhook do you use?

alexey-ban commented 3 years ago

Hi @bonifaido helm chart: 1.11.3, image: ghcr.io/banzaicloud/vault-secrets-webhook:1.11.2

bonifaido commented 3 years ago

Hi, I just found that we have an upstream issue here in the go-containerregistry library that checks the container registries: https://github.com/google/go-containerregistry/issues/723

dkulchinsky commented 3 years ago

Hey folks, We're struggling with a similar issue that was originally reported in https://github.com/banzaicloud/bank-vaults/issues/1232

In our case, we have multiple imagePullSecrets defined that indeed exist and are correct (the reason is because same Pod has containers coming from different internal repos that have different secrets).

How in this scenario, VSW is only able to pull images for the registry whose secret is the first in the imagePullSecrets list, if the image is in the registry whose secret is 2nd - it fails to pull the image and mutation is not performed.

dkulchinsky commented 3 years ago

Hey @bonifaido 👋🏼

I realize this is an upstream issue and looks like not something that can be easily fixed (although the PR that introduced the "bug" is really strange).

We are impacted by this due to our internal container registry having different secrets for different projects (namespace) in the registry.

Do you think there's anything that can be done in VSW to address this?

csatib02 commented 1 month ago

Hey,

Can someone verify that this issue still present as of today? It seems like there has been some fixes around this one.