-
Notifications
You must be signed in to change notification settings - Fork 76
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
Do not throw error when matchLabels do not find any secret/configmap #426
Comments
Hi @erikgb thanks for your work on this subject.
My detail use case is this one: A central team create a bunch of Bundle that will provide inside "clients" namespace a set of configmap/secrets for them to use in different case ( a truststore for internal calls, a truststore for specific external services, custom cert from a specific project/team). Has our service grow, new certificat will be added. Our bundle will look for confimap and secret with a specific label to add those always evolving set of certificats. |
@Shawcs thanks for your prompt feedback! Since there is already a test asserting that an empty resulting bundle (containing no certificates) is invalid (an error), I think we should head for option one:
|
That would do it. The only thing to be careful with is: If I select configMap and Secret with a label and there is some configMap matching my filter but no secret I would expect the target to be created and containing the cert from the ConfigMap |
Makes a lot of sense! That is a test added to the PR - since that use case is currently broken. |
I also noticed something else that can be linked to this feature. The status do not reflect problem with bad/empty source. How to reproduce:
apiVersion: trust.cert-manager.io/v1alpha1
kind: Bundle
metadata:
name: my-bundle
spec:
sources:
- configMap:
key: ca.crt
selector:
matchLabels:
trust-bundle.my-bundle: include
target:
additionalFormats:
pkcs12:
key: ca.p12
password: changeit
namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: infra
secret:
key: ca.crt kind: ConfigMap
apiVersion: v1
metadata:
name: my-cert.crt
namespace: infra-cert-manager
labels:
trust-bundle.my-bundle: include
data:
ca.crt: |
-----BEGIN CERTIFICATE-----
MIIDojCCAYqgAwIBAgIQV5ocp05c1d2ULNLEDrdCpTANBgkqhkiG9w0BAQsFADBH
MQswCQYDVQQGEwJDSDEnMCUGA1UEChMeQmFucXVlIExvbWJhcmQgT2RpZXIgZXQg
Q2llIFNBMQ8wDQYDVQQDEwZMTyBEUEkwHhcNMjQwMzA3MDAwMDAwWhcNMjUwMzA3
MjM1OTU5WjAVMRMwEQYDVQQDEwpnaXRodWIuY29tMFkwEwYH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
message: 'Successfully synced Bundle to namespaces that match this label selector: kubernetes.io/metadata.name=infra'
observedGeneration: 1
reason: Synced
status: 'True'
type: Synced
kind: ConfigMap
apiVersion: v1
metadata:
name: my-cert.crt
namespace: infra-cert-manager
labels:
trust-bundle.my-bundle: include
data:
ca.crt: |
-----BEGIN CERTIFICATE-----
MIIDojCCAYqgAwIBAgIQV5ocp05c1d2ULNLEDrdCpTANBgkqhkiG9w0BAQsFADBH
MQswCQYDVQQGEwJDSDEnMCUGA1UEChMeQmFucXVlIExvbWJhcmQgT2RpZXIgZXQg
Q2llIFNBMQ8wDQYDVQQDEwZMTyBEUEkwHhcNMjQwMzA3MDAwMDAwWhcNMjUwMzA3
MjM1OTU5WjAVMRMwEQYDVQQDEwpnaXRodWIuY29tMFkwEwYHKoZIzj0CAQYIKoZI
PlhhSYK+Dvv1Op2/C
bd8LU10GmzZpZ/aR4SZDymggc32xvXEfPSrM36qgDcbg7Vb3mm+uZUgWKHmh1pnA
1DeiFM9PT9GGN8m5ioMsbYw2jt8Gbz0CWSQlJWAfo0LEbVnIH4TG10m6Ix
zqDgzL7QYe7XpGqY1LuwNidozLvRUaZkhDud7XlgHYYQwrP4z6/ekawett0LdvSL
JdSRFvE7pO4K2kXxFr8YzeET0jrZ+JeVX8WYbsfUlo0UdMVnViIFrgbTd8v6Mlev
kBG18BDEDA8hYS1JsSmpeiy/c/WsIzihgtNVJojqnF
16LisgMdnA/1gj801KmoTYUfQFNwl7ymulCRrVNOzqs/
G3VnreyXrukwRbMI/MR4ccXl5/n+Hw==
-----END CERTIFICATE-----
I suggest that when we have this kind of error the status in the bundle is updated with a relevant error. This also work for the case where source is empty |
I couldn't agree more! 👍 Do you mind opening up a new issue asking for this? It will slightly change the behavior of the trust-manager API, and we should track such changes well. It might break some user workflows, and we should communicate such changes well. |
Hi team,
when we specify a selector for configMap or Secret source like this:
If no configMap matches this label selector the operator throw this kind of error:
Proposition
if we don't find any ConfigMap or Secret matching the label we just ignore it ?
The text was updated successfully, but these errors were encountered: