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

feature/fix-k8s-config-with-OIDC #594

Merged
merged 6 commits into from
Jan 20, 2025

Conversation

klinch0
Copy link
Contributor

@klinch0 klinch0 commented Jan 20, 2025

Summary by CodeRabbit

  • Chores
    • Updated tenant application version from 1.6.6 to 1.6.7
    • Updated version tracking in package management system
    • Minor configuration adjustments in kubeconfig template
    • Enhanced logic for determining API server endpoint based on kubeconfig presence

@klinch0 klinch0 requested a review from kvaps as a code owner January 20, 2025 12:18
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jan 20, 2025
Copy link
Contributor

coderabbitai bot commented Jan 20, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request involves version updates for the tenant application across multiple files. The changes primarily focus on incrementing the application version from 1.6.6 to 1.6.7. The Chart.yaml file is updated with the new version, and the versions_map is modified to reflect the version change and commit hash. Additionally, a modification is made to the kubeconfig.yaml template to handle the API server endpoint configuration more dynamically.

Changes

File Change Summary
packages/apps/tenant/Chart.yaml Version bumped from 1.6.6 to 1.6.7
packages/apps/tenant/templates/kubeconfig.yaml Added conditional logic for $managementKubeconfigEndpoint to dynamically set $apiServerEndpoint
packages/apps/versions_map Updated tenant version entries, replacing 1.6.6 HEAD with 1.6.6 d4634797 and adding 1.6.7 HEAD

Possibly related PRs

  • feature/fix-k8s-config-with-OIDC #594: The changes in this PR directly match the version increment from 1.6.6 to 1.6.7 in the Chart.yaml file, as well as updates to the versions_map, indicating a strong connection to the main PR.

Suggested labels

enhancement

Suggested reviewers

  • lllamnyp
  • kvaps

Poem

🐰 A Version Hop, A Rabbit's Delight
From 1.6.6 to 1.6.7 we take flight
Config files dance, versions align
With each small change, our code refines
Hopping forward, one commit at a time! 🚀


📜 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 b722250 and 1e5950c.

📒 Files selected for processing (1)
  • packages/apps/tenant/templates/kubeconfig.yaml (1 hunks)

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.

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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2a976af and 536bd3a.

📒 Files selected for processing (3)
  • packages/apps/tenant/Chart.yaml (1 hunks)
  • packages/apps/tenant/templates/kubeconfig.yaml (1 hunks)
  • packages/apps/versions_map (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/apps/tenant/Chart.yaml
🔇 Additional comments (3)
packages/apps/versions_map (1)

102-103: LGTM! Verify commit hash exists.

The version mapping changes look good. The version increment from 1.6.6 to 1.6.7 is properly sequenced, and pinning 1.6.6 to a specific commit hash follows good versioning practices.

Let's verify that the commit hash exists and is properly referenced:

✅ Verification successful

✓ Commit hash verified successfully

The commit d463479 exists and correctly corresponds to the tenant 1.6.6 release, which includes version bump from 1.6.5 to 1.6.6 as part of PR #556.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the commit hash exists in the repository
# and that it's properly referenced in the version mapping

# Check if the commit exists
git rev-parse --quiet --verify d4634797 || echo "Commit d4634797 not found"

# Show commit message to verify it's the correct 1.6.6 release commit
git log -n 1 --format=%B d4634797 2>/dev/null || echo "Cannot read commit message"

Length of output: 82


Script:

#!/bin/bash
# Get the commit message to verify it's related to tenant 1.6.6
git show --no-patch --format=%B d4634797f36460c4ba3bbe6c4e129a964b4803bf

Length of output: 1020

packages/apps/tenant/templates/kubeconfig.yaml (2)

Line range hint 37-46: Consider updating client authentication API version.

The configuration uses client.authentication.k8s.io/v1beta1 which is in beta. Consider checking if a stable version is available for your Kubernetes version.

Also, the skip-open-browser flag is correctly used for automated authentication, but ensure your OIDC provider is configured to handle this non-interactive flow.

Run this script to check the available API versions:


13-13: Verify CA certificate encoding to prevent double-encoding issues.

The CA certificate from kube-root-ca.crt ConfigMap is typically already in base64 format. Using b64enc on it again could lead to double-encoding and cause authentication failures.

Run this script to check the encoding:

If the CA cert is already encoded, apply this diff:

-{{- $k8sCa := index $rootSaConfigMap.data "ca.crt" | b64enc }}
+{{- $k8sCa := index $rootSaConfigMap.data "ca.crt" }}
✅ Verification successful

Current implementation is correct - base64 encoding is required for kubeconfig

The CA certificate from kube-root-ca.crt ConfigMap is stored in PEM format and needs to be base64 encoded when embedded in kubeconfig files. The b64enc pipe is necessary here as the kubeconfig specification requires the certificate-authority-data field to be base64 encoded.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if the CA certificate in the ConfigMap is already base64 encoded

# Get the CA certificate from the ConfigMap
kubectl get configmap kube-root-ca.crt -n kube-system -o jsonpath='{.data.ca\.crt}' | base64 -d 2>/dev/null

if [ $? -eq 0 ]; then
  echo "WARNING: CA cert is already base64 encoded. Remove the b64enc pipe."
else
  echo "OK: CA cert is not base64 encoded. Current implementation is correct."
fi

Length of output: 364


Script:

#!/bin/bash
# Search for patterns related to CA certificate handling
echo "=== Searching for ca.crt usage ==="
rg "ca.crt" -A 3 -B 3

echo -e "\n=== Searching for ConfigMap definitions ==="
rg "kind:\s+ConfigMap" -A 5 -B 5

echo -e "\n=== Looking for similar kubeconfig templates ==="
fd "kubeconfig.*yaml"

Length of output: 66677

Comment on lines 7 to 10
{{- $managedKubeconfigEndpoint := index $cozyConfig.data "managed-kubeconfig-endpoint" }}
{{- if and $managedKubeconfigEndpoint (ne $managedKubeconfigEndpoint "") }}
{{- $apiServerEndpoint = $managedKubeconfigEndpoint }}
{{- end }}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling and documentation for the managed endpoint configuration.

While the logic for overriding the API server endpoint is sound, there are a few improvements needed:

  1. Add error handling for the ConfigMap key lookup
  2. Document the expected format and validation requirements for the endpoint
  3. Consider adding validation for the endpoint URL format

Apply this diff to improve error handling:

-{{- $managedKubeconfigEndpoint := index $cozyConfig.data "managed-kubeconfig-endpoint" }}
+{{- $managedKubeconfigEndpoint := default "" (get $cozyConfig.data "managed-kubeconfig-endpoint") }}

Also, please add a comment block explaining:

  • The purpose of the managed endpoint override
  • Expected URL format and validation rules
  • Security implications of changing the API server endpoint
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{{- $managedKubeconfigEndpoint := index $cozyConfig.data "managed-kubeconfig-endpoint" }}
{{- if and $managedKubeconfigEndpoint (ne $managedKubeconfigEndpoint "") }}
{{- $apiServerEndpoint = $managedKubeconfigEndpoint }}
{{- end }}
{{- $managedKubeconfigEndpoint := default "" (get $cozyConfig.data "managed-kubeconfig-endpoint") }}
{{- if and $managedKubeconfigEndpoint (ne $managedKubeconfigEndpoint "") }}
{{- $apiServerEndpoint = $managedKubeconfigEndpoint }}
{{- end }}

Copy link
Member

@kvaps kvaps left a comment

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 20, 2025
@kvaps kvaps merged commit 06afcf2 into aenix-io:main Jan 20, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants