Skip to content
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

Improve TLS handling in etcd helm chart #620

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lllamnyp
Copy link
Member

@lllamnyp lllamnyp commented Feb 7, 2025

  1. Add a commonName to every certificate.
  2. Move 127.0.0.1 from DNS names to IP Addresses in the certificate spec.
  3. Make the entire subject field of the certificates templatable.
  4. Add client auth usage to the etcd-server certificate (yes, that's necessary), because etcd queries itself using its server cert as a client cert.
  5. Default all CA certificates' durations to 10 years and make this value templatable.

Summary by CodeRabbit

  • New Features

    • Enhanced certificate configurations for improved flexibility with dynamic duration, subject formatting, and common name identification, along with predefined IP addresses for better component recognition.
    • Introduced dynamic computation for backend storage quotas, enabling more adaptable cluster configuration.
    • Application version bumped to 2.6.0 with updated package version mappings.
  • Chores

    • Minor formatting adjustment in the JSON schema for cleaner file structure.

@lllamnyp lllamnyp requested a review from kvaps as a code owner February 7, 2025 06:39
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Feb 7, 2025
Copy link
Contributor

coderabbitai bot commented Feb 7, 2025

Walkthrough

This pull request updates the etcd chart template and related configuration files. In the etcd-cluster template, a new function is added to calculate quota backend bytes and certificate specifications have been updated for enhanced dynamic configuration. The changes include modifications to certificate fields and version updates in both the Chart.yaml and the versions map. Additionally, a minor formatting change is applied to the JSON schema file.

Changes

File(s) Change Summary
packages/extra/etcd/templates/etcd-cluster.yaml Added function calculateQuotaBackendBytes; updated certificate specifications for etcd-peer-ca, etcd-ca, etcd-server, etcd-peer, and etcd-client (adding commonName, subject, and ipAddresses fields, and replacing subject with duration in some cases).
packages/extra/etcd/values.schema.json Added a newline at the end of the file.
packages/extra/etcd/Chart.yaml
packages/extra/versions_map
Updated version from 2.5.0 to 2.6.0 in Chart.yaml; in versions_map, updated etcd 2.5.0 from HEAD to commit hash 861e6c46 and added a new entry etcd 2.6.0 HEAD.

Sequence Diagram(s)

sequenceDiagram
  participant U as User/Helm
  participant T as Template Engine (etcd-cluster.yaml)
  participant F as calculateQuotaBackendBytes Function
  U->>T: Provide .Values (subject, caDuration, etc.)
  T->>F: Invoke calculation of backend quota bytes
  F-->>T: Return computed value
  T->>T: Build certificate specs (commonName, subject, ipAddresses)
  T-->>U: Render and output configuration
Loading

Suggested labels

size:M, lgtm

Suggested reviewers

  • xy2
  • kvaps

Poem

I am a rabbit, hopping with cheer,
New changes bloom, fresh and clear.
Templates and versions now dance in tune,
A configuration fest under the moon.
Hop along with code, smooth as a rune!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between df97bf5 and 14d93d2.

📒 Files selected for processing (4)
  • packages/extra/etcd/Chart.yaml (1 hunks)
  • packages/extra/etcd/templates/etcd-cluster.yaml (7 hunks)
  • packages/extra/etcd/values.schema.json (1 hunks)
  • packages/extra/versions_map (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • packages/extra/etcd/values.schema.json
  • packages/extra/etcd/Chart.yaml
🔇 Additional comments (7)
packages/extra/versions_map (1)

9-10: LGTM! Version management changes align with the PR objectives.

The version updates appropriately reflect the significant changes to TLS handling:

  • Version 2.5.0 is correctly pinned to a specific commit
  • Version 2.6.0 is added as HEAD for the new changes
packages/extra/etcd/templates/etcd-cluster.yaml (6)

1-9: LGTM! Well-structured helper function for quota calculation.

The function correctly handles unit conversion and applies a 95% safety margin for quota calculation.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)


16-17: LGTM! Proper integration of quota calculation.

The quota-backend-bytes is now dynamically calculated using the helper function.


76-77: LGTM! CA certificate improvements.

The changes correctly implement:

  • Templatable CA certificate duration
  • Templatable subject field

Also applies to: 98-99


130-132: LGTM! Server certificate improvements.

The changes correctly implement:

  • Added commonName for identification
  • Added client auth usage for self-querying
  • Moved 127.0.0.1 to ipAddresses section
  • Added templatable subject field

Also applies to: 135-147


160-162: LGTM! Peer certificate improvements.

The changes correctly implement:

  • Added commonName for identification
  • Added templatable subject field
  • Moved 127.0.0.1 to ipAddresses section

Also applies to: 176-177


190-192: LGTM! Client certificate improvements.

The changes correctly implement:

  • Added commonName as "root"
  • Added templatable subject field

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dosubot dosubot bot added the enhancement New feature or request label Feb 7, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/extra/etcd/values.schema.json (1)

19-40: Accurate JSON Schema Enhancements for TLS Configurability
The schema now includes "caDuration" and a "subject" object with detailed sub-properties, which aligns well with the new templatable certificate configuration. As a potential refinement, consider specifying the array item types (e.g., adding "items": {"type": "string"} for properties like "organizations" and "countries") to enforce that only string values are provided. This refinement isn’t critical but could further improve schema validation.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1a88883 and df97bf5.

📒 Files selected for processing (3)
  • packages/extra/etcd/templates/etcd-cluster.yaml (7 hunks)
  • packages/extra/etcd/values.schema.json (1 hunks)
  • packages/extra/etcd/values.yaml (1 hunks)
🔇 Additional comments (7)
packages/extra/etcd/values.yaml (2)

10-30: Thorough Documentation for the New X509 Subject Parameters
The added block documents the new "subject" object very clearly with separate entries for organizations, organizational units, countries, localities, provinces, postal codes, street addresses, and serial number. The inline comments (and the use of commented-out fields) appropriately guide users on how they may customize these values if needed.


31-32: Clear CA Certificate Duration Setting
Defining "caDuration" as 87600h (representing a 10-year period) is consistent with the PR objectives. This provides a good default while still leaving room for user customization if necessary.

packages/extra/etcd/templates/etcd-cluster.yaml (5)

75-77: Dynamic Configuration in etcd-peer-ca Certificate
The changes for the etcd-peer-ca certificate now include a dynamic "duration" field (using .Values.caDuration) and a templated "subject" (via .Values.subject | toYaml | nindent 4). This meets the PR objectives by removing hardcoded values and enhancing flexibility.


97-99: Enhanced etcd-ca Certificate Settings
Similar to the etcd-peer-ca, the etcd-ca certificate now dynamically incorporates the "duration" and "subject" fields. This consistent approach simplifies configuration management for CA certificates.


130-147: Comprehensive Updates to the etcd-server Certificate
The etcd-server certificate now specifies a "commonName", a dynamic "subject", and moves the "127.0.0.1" into its own "ipAddresses" field. Additionally, including "client auth" in its usages directly addresses the self-querying behavior described in the PR objectives. Please verify the indentation produced by "toYaml | nindent 4" to ensure it renders correctly in the final manifest.


160-177: Consistent TLS Customization for the etcd-peer Certificate
The etcd-peer certificate now has a set "commonName", a dynamic "subject" field, and defines "ipAddresses" appropriately. This ensures that peer certificates leverage the new templating features and enhanced identification setup.


190-192: Updated etcd-client Certificate with Templated Subject
Adding the dynamic "subject" field to the etcd-client certificate extends the flexible TLS configuration to the client side. This change helps maintain consistency across all TLS certificates defined in this chart.

1. Add a `commonName` to every certificate.
2. Move 127.0.0.1 from DNS names to IP Addresses in the certificate
   spec.
3. Add **client** auth usage to the etcd-**server** certificate (yes,
   that's necessary), because etcd queries itself using its
   [server cert as a client cert](etcd-io/etcd#9785 (comment)).
4. Default all CA certificates' durations to 10 years.
@lllamnyp lllamnyp force-pushed the chore/improve-etcd-tls branch from df97bf5 to 14d93d2 Compare February 11, 2025 19:33
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant