-
Notifications
You must be signed in to change notification settings - Fork 9
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
Generalize the certificate generation configuration #220
Generalize the certificate generation configuration #220
Conversation
0e1817a
to
319e66f
Compare
First of all, the flag cleanup is impressive and functionally certgen is way more flexible after this patch, so thank you @giorio94 for tackling this 🙏
In any case, we're still on v0.1.x so the first version with this change should be v0.2.x. IMO there is so little maintenance on cergen that we shouldn't bother backporting, but no strong opinion here. If we do not backport, then we should consider branching a v0.1 branch in case we need to do patch releases for previous cilium versions, hence not approving the PR until this question has reached a conclusion (but patch LGTM). Finally, it's a tad scary to see such a huge change without any related test change, we definitely should consider adding at least a couple of functional tests (i.e. one for the initial cert /CA creation and one for renew), but of course not necessarily on this PR. |
319e66f
to
540d434
Compare
Rebased onto main to fix a conflict.
👍 I personally agree on starting using the new version on Cilium v1.16, and keep the previous one for all the other stable branches. And I also agree about branching a dedicated branch for dependency updates for the old version.
Agreed. To be fair certgen doesn't include any tests at the moment, hence adding tests requires definitely some extra effort (and likely push this to Cilium v1.17). In a certain sense, the new configuration is also arguably simpler compared to the previous one (~ 1/10 LoCs). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm vendor changes.
I personally agree on starting using the new version on Cilium v1.16, and keep the previous one for all the other stable branches. And I also agree about branching a dedicated branch for dependency updates for the old version.
+1
Converting back to draft while I'm putting together an E2E test workflow. |
540d434
to
f917bcd
Compare
Back reviewable, I've additionally dropped the now superfluous @kaworu PTAL 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the assert functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the addition of the e2e test! I left a couple suggestions below but nothing blocking. Great work, thanks, making certgen flexible is a really nice improvement! And it shaves many lines of code as an added benefit 🙂
Huh, looks like one of my review comment mysteriously disappeared. I was suggesting to replace references to "Cilium CA" by simply "CA" in the remaining flags, logs and error messages now that the tool is actually generic. |
Currently, certgen has detailed knowledge of the specific certificates used by Cilium, hence requiring any changes (e.g., introduction of a new certificate) to be manually applied to this tool as well. Moreover, it strongly relies on default values, making it difficult to predict the final output looking at the Cilium's configuration only. Let's instead introduce a generic configuration, which can be used to express the list of certificates to be generated, and their characteristics. The configuration shall be provided in yaml format through the dedicated flags (--config or --config-file), and an example is presented in the following: certs: - name: foo namespace: kube-system commonName: foo.cilium.io hosts: - foo.cilium.io - qux.cilium.io - 192.0.2.237 usage: - signing - key encipherment - server auth validity: 72h - name: bar ... Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
So that the tool returns an error to the user in case the usage is not correct, rather than ignoring it silently. Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Following the introduction of a dedicated configuration file to define the certificates to be generated, the only remaining usage of the cilium-namespace option is as an alias of ca-secret-namespace. Hence, let's remove it in favor of the more specific option. Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
In an effort towards generality, let's remove the extra hard-coded names (besides the user-configurable common name) from the autogenerated CA certificate. Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
f917bcd
to
e958ca1
Compare
Now that certgen is more generic and not specifically tied to Cilium, let's further drop the remaining references to the Cilium CA from flags, logs and comments. Suggested-by: Robin Hahling <robin.hahling@gw-computing.net> Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
e958ca1
to
328d1f3
Compare
I should have removed all the remaining references. PTAL and let me know if that's what you had in mind. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes exactly what I had in mind 🚀
Opened cilium/cilium#32998 to prevent renovate from upgrading the certgen version in stable Cilium branches. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work @giorio94 thanks for adding the test! 🙏
The test runs the certgen binary once and verifies that both the CA and the leaf certificates specified through the configuration are generated correctly. Then, it reruns the tool a second time, and it asserts that only the leaf certificates are regenerated, while the CA is not modified. Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
328d1f3
to
777d116
Compare
Currently, certgen has detailed knowledge of the specific certificates used by Cilium, hence requiring any changes (e.g., introduction of a new certificate) to be manually applied to this tool as well. Moreover, it strongly relies on default values, making it difficult to predict the final output looking at the Cilium's configuration only.
Let's instead introduce a generic configuration, which can be used to express the list of certificates to be generated, and their characteristics. The configuration shall be provided in yaml format through the dedicated flags (--config or --config-file), and an example is presented in the following:
WIP changes on the Cilium's side, as an example of how the proposed configuration could be used: giorio94/cilium@8583b14
Note: this obviously introduces backward incompatibility changes if merged, and we should decide whether to backport the Cilium's changes to stable versions, which is more risky, or keep using the old version there (hence needing to support two parallel versions for a while).