Skip to content

Conversation

@kyrbrbik
Copy link
Contributor

@kyrbrbik kyrbrbik commented Dec 10, 2024

Pull Request Template for Helm Chart

Description

This change adds the option to run side containers in the postiz-app pod.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Tested by installing the helm chart with an oauth-proxy additional container and an additional port for the container in the service

  • Tested locally

Test Configuration: Bare-metal kubernetes cluster

  • Kubernetes version: 1.30.4
  • Helm version: 3.16.3
  • Minikube/kind version (if applicable):

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Additional Information

  • Does this change introduce any new Kubernetes resource types? No

  • Does this change modify any existing Kubernetes resource types? Yes
    Adds optional side container in the posti-app deployment and optional additional port in the posti-app service

  • Are there any changes to the values.yaml file? Yes
    Adds options for additional containers and service ports

  • Does this change require any specific Kubernetes permissions or RBAC changes? No

  • Are there any changes to chart dependencies? No

  • Have you updated the CHANGELOG.md file? No
    Theres no changelog file :)

Additional context

Add any other context or screenshots about the pull request here.

Summary by CodeRabbit

  • New Features

    • Added support for specifying additional containers and volumes in the deployment configuration.
    • Introduced a new field for additional service ports in the configuration.
  • Updates

    • Incremented application version from 1.0.4 to 1.0.5.

@coderabbitai
Copy link

coderabbitai bot commented Dec 10, 2024

Walkthrough

The changes in this pull request involve updates to the Helm chart for the postiz-app. The Chart.yaml file's version is incremented from 1.0.4 to 1.0.5. Enhancements are made to the deployment configuration in postiz-deployment.yaml by introducing conditional logic for additional containers and volumes. The postiz-service.yaml file is updated to include a conditional block for additionalPorts. Lastly, the values.yaml file is modified to add new fields for additionalPorts and extraContainers, expanding the configuration options without altering existing functionality.

Changes

File Change Summary
charts/postiz/Chart.yaml Version updated from 1.0.4 to 1.0.5.
charts/postiz/templates/postiz-deployment.yaml Added conditional logic for extraContainers and extraVolumes.
charts/postiz/templates/postiz-service.yaml Introduced conditional block for additionalPorts.
charts/postiz/values.yaml Added new fields: additionalPorts: [] and extraContainers: [].

Poem

In the fields where rabbits play,
New changes hop in bright array.
With ports and containers, oh what fun,
Flexibility for everyone!
A version bump, a joyful cheer,
Postiz-app's enhancements are here! 🐰✨


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. (Experiment)
  • @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

@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 (3)
charts/postiz/values.yaml (2)

26-26: Add documentation and examples for the new configuration options.

The new fields service.additionalPorts and extraContainers would benefit from:

  1. Documentation comments explaining their purpose and format
  2. Example configurations, especially for the oauth-proxy use case mentioned in the PR description

Example documentation:

service:
  additionalPorts: []
  # additionalPorts -- Additional ports to expose in the service
  # @example:
  # additionalPorts:
  # - port: 8080
  #   targetPort: oauth-proxy
  #   protocol: TCP
  #   name: oauth-proxy

extraContainers: []
# extraContainers -- Additional containers to run in the pod
# @example:
# extraContainers:
# - name: oauth-proxy
#   image: quay.io/oauth2-proxy/oauth2-proxy:v7.4.0
#   ports:
#   - containerPort: 8080
#     name: oauth-proxy

Also applies to: 48-48


26-26: Consider adding schema validation for the new fields.

To prevent configuration errors, consider adding schema validation using a JSON schema in values.schema.json.

Would you like me to help create a schema that validates:

  • additionalPorts: Array of valid Kubernetes service port objects
  • extraContainers: Array of valid Kubernetes container specs

Also applies to: 48-48

charts/postiz/templates/postiz-deployment.yaml (1)

Line range hint 71-75: Fix the volumes logic to preserve uploads-volume when using extraVolumes.

The current implementation makes uploads-volume and extraVolumes mutually exclusive. This could break functionality if the main container still needs the uploads volume while using extra volumes.

Replace the either/or logic with an additive approach:

      volumes:
-       {{- if .Values.extraVolumes }}
-       {{- toYaml .Values.extraVolumes | nindent 8 }}
-       {{- else }}
        - name: uploads-volume
          emptyDir: {}
-       {{- end }}
+       {{- with .Values.extraVolumes }}
+       {{- toYaml . | nindent 8 }}
+       {{- end }}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f09e2ff and 24fcde5.

📒 Files selected for processing (4)
  • charts/postiz/Chart.yaml (1 hunks)
  • charts/postiz/templates/postiz-deployment.yaml (2 hunks)
  • charts/postiz/templates/postiz-service.yaml (1 hunks)
  • charts/postiz/values.yaml (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • charts/postiz/Chart.yaml

Comment on lines +14 to +16
{{- if .Values.service.additionalPorts }}
{{- toYaml .Values.service.additionalPorts | nindent 4 }}
{{- end }}
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Port name validation is needed for service configuration

The review comment is valid. After examining the codebase:

  1. The service template defines a default http port name
  2. additionalPorts is included without any validation
  3. No validation exists in _helpers.yaml or schema
  4. The default values.yaml shows additionalPorts as an empty array without example structure or documentation

Since Kubernetes requires unique port names within a service, and there's no validation mechanism in place, this could lead to runtime issues if users define additional ports with duplicate names.

  • Add validation in _helpers.yaml to check for unique port names
  • Document the additionalPorts structure in values.yaml with an example
  • Consider adding a values schema file (values.schema.json) with JSON Schema validation
🔗 Analysis chain

Consider adding validation for port names.

While the implementation is correct, there's no validation to ensure that port names in additionalPorts don't conflict with the default http port name. Duplicate port names could cause issues in service discovery.

Let's check if the chart has any validation for this:

Consider adding a helper template to validate port names or include validation in the schema file.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for port name validation in the chart

# Look for any validation templates or helpers
fd -e yaml -e tpl "^_.*" charts/postiz/templates/

# Check if there's a schema file
fd "values.schema.json" charts/postiz/

Length of output: 128


Script:

#!/bin/bash
# Check the content of _helpers.yaml for any port validation
cat charts/postiz/templates/_helpers.yaml

# Check values.schema.json content for port validation
cat charts/postiz/values.schema.json

Length of output: 1918


Script:

#!/bin/bash
# Check the default values file to understand the service port structure
cat charts/postiz/values.yaml

# Check the complete service template to understand port configuration
cat charts/postiz/templates/postiz-service.yaml

Length of output: 2622

@jamesread
Copy link
Contributor

jamesread commented Jan 2, 2025

Hey @kyrbrbik , thanks for the PR, the way you've implemented looks generally OK.

I'm confused by this pattern though, why would people want to add "extraContainers" to this Helm chart, and why not use a separate chart for those containers? Is this a common recommended helm chart best practice that is documented somewhere? Thanks.

I'm just seeking to understand why this change is useful.

Also, sorry for the long delay in getting back to you - I've had to take December off of maintaining open source code as I've been busy with other life stuff - but I'll be more available now :-)

@kyrbrbik
Copy link
Contributor Author

kyrbrbik commented Jan 2, 2025

Hi @jamesread, it's a pretty well used pattern that you can add more containers into the application pod that enhance the functionality of it.
It would certainly be possible to install it with a different helm chart in most cases but that would add maintenance complexity. Here's a blog post explaining it better

@jamesread
Copy link
Contributor

Hey @kyrbrbik , thanks for taking the time to reply. I've seen that k8s doc before, and it reminded me that adding containers into the same pod (like sidecar containers) would be necessarily trickier via another helm chart - but would be made easier with the approach in this PR.

When I was reviewing it, I thought the extraContainers would be used for deploying containers outside of the same pod - like postgres, or something different - so I hadn't thought of that!

I just approved the lint check which ran fine, so I am merging this PR now. Thanks very much for your clean contribution and comments!

@jamesread jamesread merged commit 5d6a9de into gitroomhq:main Jan 2, 2025
3 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