Skip to content

Added multiple env variables to kubernetes-provider #1305

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

Merged
merged 11 commits into from
Sep 23, 2024

Conversation

iFlyinq
Copy link
Contributor

@iFlyinq iFlyinq commented Sep 16, 2024

Closes #

✅ Checklist

  • I have followed every step in the contributing guide
  • The PR title follows the convention.
  • I ran and tested the code works

Changelog

Added more flexibility for the kubernetes-provider by adding the COORDINATOR_HOST, COORDINATOR_PORT and KUBERNETES_NAMESPACE env variables. They all fall back to the defaults they used to have.


💯

Summary by CodeRabbit

  • New Features
    • Enhanced configuration for Kubernetes task operations, allowing for flexible deployment through environment variables.
    • Improved handling of COORDINATOR_HOST and COORDINATOR_PORT for better adaptability in various environments.
    • Introduced dynamic namespace assignment for PodCleaner and UptimeHeartbeat, promoting configurability.
  • Bug Fixes
    • Addressed hardcoded namespace issues in PodCleaner and UptimeHeartbeat initializations, promoting configurability.

Copy link

changeset-bot bot commented Sep 16, 2024

⚠️ No Changeset found

Latest commit: a13d118

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

pkg-pr-new bot commented Sep 16, 2024

pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/build@1305
pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev@1305
pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/core@1305
pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/sdk@1305

commit: a13d118

Copy link
Contributor

coderabbitai bot commented Sep 17, 2024

Walkthrough

The changes enhance the configuration of the KubernetesTaskOperations class in the Kubernetes provider by allowing the namespace parameter to default to the KUBERNETES_NAMESPACE environment variable. The handling of COORDINATOR_HOST and COORDINATOR_PORT environment variables is improved, enabling conditional assignment based on their presence. Additionally, instances of PodCleaner and UptimeHeartbeat are initialized with the KUBERNETES_NAMESPACE variable, promoting configurability. These modifications improve the flexibility and adaptability of the task operations in various deployment scenarios.

Changes

File Path Change Summary
apps/kubernetes-provider/src/index.ts - Constructor of KubernetesTaskOperations now accepts an options object for dynamic namespace assignment.
- PodCleaner initialization updated to use KUBERNETES_NAMESPACE instead of hardcoded "default".
- UptimeHeartbeat initialization updated to use KUBERNETES_NAMESPACE instead of hardcoded "default".
- Improved handling of COORDINATOR_HOST and COORDINATOR_PORT environment variables for conditional assignment.

Poem

In the land of Kubernetes, oh so bright,
A namespace now dances, a joyful sight.
Hosts and ports, they play their part,
Configurable magic, a work of art.
With every change, our tasks take flight,
Hopping through clouds, in pure delight! 🐇✨


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

Outside diff range and nitpick comments (1)
apps/kubernetes-provider/src/index.ts (1)

25-27: LGTM! Consider adding validation for KUBERNETES_NAMESPACE.

The introduction of COORDINATOR_HOST, COORDINATOR_PORT, and KUBERNETES_NAMESPACE environment variables aligns well with the PR objectives, enhancing the flexibility of the kubernetes-provider. The default value for KUBERNETES_NAMESPACE maintains backward compatibility.

Consider adding validation for the KUBERNETES_NAMESPACE value to ensure it's a valid Kubernetes namespace name. You could use a regular expression to check if it follows Kubernetes naming conventions.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d951f72 and a13d118.

Files selected for processing (1)
  • apps/kubernetes-provider/src/index.ts (8 hunks)
Additional context used
Biome
apps/kubernetes-provider/src/index.ts

[error] 425-432: This getter should return a value.

(lint/suspicious/useGetterReturn)

Additional comments not posted (6)
apps/kubernetes-provider/src/index.ts (6)

51-66: LGTM! Constructor change enhances flexibility.

The modification to the KubernetesTaskOperations constructor to accept an options object with an optional namespace property is a good improvement. It allows for more flexible initialization of the class while maintaining backward compatibility.


238-238: LGTM! Improved maintainability for coordinator environment variables.

The use of this.#coordinatorEnvVars instead of hardcoded values in the populate-taskinfo init container improves code maintainability. This change centralizes the coordinator environment variables, making it easier to update coordinator-related configuration in the future.


478-478: LGTM! Consistent use of centralized coordinator environment variables.

The inclusion of ...this.#coordinatorEnvVars in the #getSharedEnv method is consistent with the changes made elsewhere in the code. This improves maintainability and reduces the risk of inconsistencies when updating coordinator-related configuration.


651-653: LGTM! Consistent use of KUBERNETES_NAMESPACE.

The initialization of KubernetesTaskOperations with an options object containing the KUBERNETES_NAMESPACE is consistent with the updated constructor signature. This change correctly utilizes the newly introduced KUBERNETES_NAMESPACE environment variable, enhancing the flexibility of namespace configuration.


693-693: LGTM! Consistent use of KUBERNETES_NAMESPACE in PodCleaner and UptimeHeartbeat.

The use of KUBERNETES_NAMESPACE in the initialization of both PodCleaner and UptimeHeartbeat is consistent with the overall changes in this PR. This improves the flexibility of the system by allowing the namespace to be configured via an environment variable instead of using a hardcoded value.

Also applies to: 702-702


Line range hint 1-713: Overall, excellent implementation of the new environment variables and namespace flexibility.

This PR successfully introduces the new environment variables COORDINATOR_HOST, COORDINATOR_PORT, and KUBERNETES_NAMESPACE, enhancing the flexibility of the kubernetes-provider as intended. The changes are well-implemented, maintaining backward compatibility and improving code maintainability.

Key improvements:

  1. Flexible initialization of KubernetesTaskOperations with optional namespace configuration.
  2. Centralized management of coordinator environment variables.
  3. Consistent use of KUBERNETES_NAMESPACE throughout the file.

Minor suggestions for further improvement:

  1. Consider adding validation for the KUBERNETES_NAMESPACE value.
  2. Fix the #coordinatorPortEnvVar getter to explicitly return undefined when COORDINATOR_PORT is not set.

Great job on enhancing the configurability of the kubernetes-provider!

Tools
Biome

[error] 425-432: This getter should return a value.

(lint/suspicious/useGetterReturn)

Copy link
Collaborator

@nicktrn nicktrn left a comment

Choose a reason for hiding this comment

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

Thanks 🙏

@nicktrn nicktrn merged commit aba51ab into triggerdotdev:main Sep 23, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants