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

feat: Add initial support for Helm chart URLs #1265

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

chiragbhatia8
Copy link

@chiragbhatia8 chiragbhatia8 commented Jan 9, 2025

Preliminary Support for Deploying Helm Charts from .tgz URLs

This PR introduces preliminary support for deploying Helm charts directly from URLs pointing to .tgz files, addressing issue #775. While the core functionality is implemented, this PR is still a work in progress and is not ready for merge.

Current Status

Core Features Implemented

  • URL Field Addition: A new url field has been added to the HelmChartConfig structure to support .tgz Helm charts sourced from URLs.
  • Integration of URL-based Downloads: The Helm chart handling logic has been updated to integrate URL-based chart downloads, allowing users to specify a direct link to a .tgz file.
  • Extraction and Caching: Implemented proper extraction and caching mechanisms for .tgz charts to ensure efficient deployment.
  • Partial Integration: The new URL feature has been partially integrated with existing Helm deployment workflows, allowing for seamless usage alongside traditional chart sources.

Modified Files

  • pkg/helm/chart.go: Added logic to handle URL-based charts, including download and extraction functionality.
  • pkg/helm/helm_release.go: Updated release handling to accommodate charts sourced from URLs.
  • pkg/helm/pulled_chart.go: Enhanced support for pulling charts from URL sources, ensuring proper validation and error handling.
  • pkg/types/helm_chart.go: Introduced the url field and validation logic to ensure that only valid URLs are accepted.
  • pkg/utils/tar.go: Added utility functions to handle .tgz files, including extraction and validation.

Checklist

Type of Change

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

PR Status

  • Corresponding issue exists ([Feature] Ability to handle tgz helm targets #775)
  • Motivation and explanation of changes added
  • Contribution guidelines followed (needs review)
  • Code self-review performed
  • Added meaningful comments in code
  • Tests added (needs review)
  • All tests passing locally (needs review)
  • Documentation added (needs review)

Implementation Details

What’s Done

  • Support for URL-based .tgz Helm Charts: Users can now specify a URL to a .tgz file directly in their Helm chart configuration.
  • Validation Logic:
    • Ensures that only one source (repo, path, git, or url) is specified.
    • Validates that the URL points to a valid .tgz file.
    • Requires a ChartName to be provided when using a URL.
  • Core Logic:
    • Implemented download functionality in chart.go to fetch and cache the .tgz files.
    • Integrated .tgz extraction via utils/tar.go to handle the downloaded files properly.

Work in Progress

  • Tests: Basic tests have been implemented but are currently failing. Coverage is insufficient for edge cases, and further testing is needed.
  • Documentation: The URL feature needs detailed documentation, including configuration examples and usage guidelines.

TODO Before Merge

  1. Fix failing tests and ensure 100% coverage for the new functionality.
  2. Add examples and documentation for the URL feature.

Testing Summary for PR:

To ensure the functionality of the changes made in this PR, I conducted a comprehensive testing process that involved the following steps:

image

  1. Configuration Validation:

    • Verified the .kluctl.yaml configuration file, which is crucial for defining the deployment targets and their respective environments. The configuration is as follows:
      discriminator: kluctl-examples-simple-helm-{{ target.name }}
      
      targets:
      - name: simple-helm
        args:
          environment: simple-helm
        context: minikube
      
      args:
      - name: environment
    • In this configuration:
      • The discriminator is set to create unique identifiers for the Helm deployments based on the target name.
      • The targets section defines a target named simple-helm, which specifies the environment as simple-helm and uses minikube as the context for deployment.
  2. Deployment Configuration:

    • The main deployment configuration is defined in deployment.yml:
      deployments:
      - include: deployment
    • This file includes the deployment configurations from the deployment directory, allowing for modular organization of deployment files.
  3. Specific Deployment Details:

    • The deployment/deployment.yml file specifies the details of the NGINX deployment:
      deployments:
      - path: nginx
      
      overrideNamespace: "nginx"
    • Here, the deployment path is set to nginx, and the namespace is overridden to ensure that all resources are created within the nginx namespace.
  4. Helm Chart Configuration:

    • The nginx/helm-chart.yml file defines helm chart to be downloaded either from repo or url:
      helmChart:
       # repo: https://charts.bitnami.com/bitnami
       chartName: nginx
       chartVersion: 17.3.2
       skipUpdate: false
       skipPrePull: true
       releaseName: nginx-proxy
       namespace: nginx
       output: helm-rendered.yml #
    
       # This is what we're testing - direct URL support
       tarUrl: https://charts.bitnami.com/bitnami/nginx-15.1.1.tgz
    • This configuration ensures that the NGINX service is of type ClusterIP, and it sets resource limits to manage resource allocation effectively.
  5. Helm Values Configuration:

    • The nginx/helm-values.yml file defines resource limits and requests for the NGINX deployment:
      resources:
        limits:
          cpu: 100m
          memory: 128Mi
        requests:
          cpu: 100m
          memory: 128Mi
      
      service:
        type: ClusterIP
    • This configuration ensures that the NGINX service is of type ClusterIP, and it sets resource limits to manage resource allocation effectively.
  6. Kustomization Configuration:

    • The nginx/kustomization.yml file is responsible for managing the resources for the NGINX deployment:
      apiVersion: kustomize.config.k8s.io/v1beta1
      kind: Kustomization
      
      resources:
      - namespace.yml
      - helm-rendered.yml # this file is auto-generated at deploy time
    • This file includes the namespace.yml and a placeholder for helm-rendered.yml, which is generated during the deployment process.
  7. Namespace Definition:

    • The nginx/namespace.yml file defines the namespace for the NGINX deployment:
      apiVersion: v1
      kind: Namespace
      metadata:
        name: "nginx"
    • This ensures that all resources related to the NGINX deployment are created within the specified namespace.

Initial implementation for direct URL support in Helm charts.
Allows downloading charts directly from URLs without requiring
a repository.

Issue: kluctl#775

Signed-off-by: Chirag Bhatia <chiragbhatia8@gmail.com>
Initial implementation for direct URL support in Helm charts.
Allows downloading charts directly from URLs without requiring
a repository.

Issue: kluctl#775

Signed-off-by: Chirag Bhatia <chiragbhatia8@gmail.com>
@chiragbhatia8 chiragbhatia8 force-pushed the feature/775-helm-chart-url-support branch from 6d7b1a6 to e85a2c8 Compare January 9, 2025 16:51
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.

1 participant