autoTls: bound certificate lifetime by the CA that will actually sign it, not the configured caCertificateLifetime
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- kubernetes, rust
調査の方向性
NodePublishVolume がバックエンドを構築する際に呼び出される TlsGenerate::get_or_create_k8s_certificate から始め、Secret の CA 証明書を読み込む ca::Manager::load_or_create を調査します。CA のうち最も遅い有効期限を使用して有効期間の上限を実装し、現在時刻に再起動バッファを加えた時点をカバーする CA がない場合の既存のハードな失敗は維持します。既存の警告または条件の動作を確認し、関連するテストで証明書の有効期間と失敗のエッジケースを検証します。
索引モデルが issue の本文から書いたものです。
説明
get_or_create_k8s_certificate clamps maxCertificateLifetime to (caCertificateLifetime - caCertificateRetirementDuration) / 4.
That is good in general, bad when someone brings their own CA as secret operator never looks at the actual CA that is provided. It just looks at what is in the CR:
ca:
secret:
name: secret-provisioner-tls-ca
namespace: default
autoGenerate: false
caCertificateLifetime: 700d
caCertificateRetirementDuration: 1d
maxCertificateLifetime = (700 - 1) / 4 = 174 (or 175, not sure, doesn't matter here)
That clamps to 174d . But we have no idea what's really in the CA.
If it has 200 days left:
- above 174 days remaining: works
- 174 down to 139: flip-flops, because jitter puts each cert somewhere in 139-174d and only some of them still fit
- below 139: every mount fails
That is not great.
It only happens when autoGenerate is false, but still....
Scope
- Calculate the clamp by looking at the CA in the Secret that expires last
- Keep it a hard failure where no CA covers
now + restartBuffer - Warning Event and/or condition on the Pod when the cert had to be shortened because of the CA's remaining lifetime?
- Open question....do we do this elsewhere? Easy to do? I think it'd be good.
[!NOTE]
This next bit is complicated and I'm not 100% sure it is all correct. I think it makes sense but I have a nagging feeling that something is still off. It is 100% written by hand but I'm not sure if the new steps 3 & 4 are correct to be honest. So many edge cases.
When a pod mounts a TLS volume, NodePublishVolume builds the backend for that SecretClass.
For autoTls that is TlsGenerate::get_or_create_k8s_certificate, which does, in this order:
- safe_max_cert_lifetime = (caCertificateLifetime - caCertificateRetirementDuration) / 4, from the CR fields
- max_cert_lifetime = min(maxCertificateLifetime, safe_max_cert_lifetime). This is the clamp.
- ca::Manager::load_or_create, which reads the CA certificates from the Secret
We need to load the CAs (step 3) before computing the clamp (step 2), and additionally bound it (the max cert lifetime) by the remaining lifetime (not_after - now, minus caCertificateRetirementDuration) of the CA that expires last. This way we never create certificates that can outlive the last expiring CA.
- ca::Manager::load_or_create, reads the CA certificates from the Secret
- safe_max_cert_lifetime = (caCertificateLifetime - caCertificateRetirementDuration) / 4, from the CR, unchanged
- ca_bound = not_after(CA that expires last) - now - caCertificateRetirementDuration, from the loaded certificates. This is new.
- max_cert_lifetime = min(maxCertificateLifetime, safe_max_cert_lifetime, ca_bound)
[!NOTE]
Do we even still needsafe_max_cert_lifetime? I believe it makes sure that all Pods can still talk to each other even if some already have a new CA and others don't but 🤯
Open questions
- Check the existing warnings whether they are correctly calculated and/or whether we want something new
- Event or Pod condition or both? An Event per mount is noisy on a large StatefulSet, otoh we might want noisy in this case?
- I believe it'd be easy to fold #94 into this. If you agree and it adds less than a day you're welcome to do so. Otherwise skip.
- I understand that this is underspecified but at least a log line and maybe another condition woudl be good here?
Out of scope
- Validating the SecretClass on admission
Expected effort
1-2 days. If it takes longer, stop and flag it.
- 主要言語
- Rust
- スター
- 13
- フォーク
- 8
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 10
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
stackabletech/secret-operator のほかの issue
-
type/bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
stackabletech/secret-operator#754 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
stackabletech/secret-operator#720 · コメント 1 件 ·
-
customer-request type/bug
難易度 3/5 1〜2日 初心者へのやさしさ 38/100
stackabletech/secret-operator#666 · コメント 2 件 ·
-
customer-request type/feature-improvement
stackabletech/secret-operator#630 · コメント 7 件 · 担当者 1 名 ·
-
stackabletech/secret-operator#620 · コメント 2 件 · 担当者 1 名 ·
stackabletech/secret-operator の issue をすべて見る
似ている issue
-
bug CLI custom-model
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
rust-bitcoin/rust-bitcoin#6930 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
fulcrumgenomics/ferro-hgvs#2251 ·
-
A-allocators A-docs C-enhancement T-libs
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100