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

Replace ArtifactHub package fetching with helm charts #1030

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

Conversation

jordojordo
Copy link
Member

@jordojordo jordojordo commented Jan 28, 2025

Fix #1027

Note:
For testing purposes you can use my fork of the Kubewarden helm charts.

This PR refactors the creation and editiong of policies by shifting from ArtifactHub based templates to a new Policy Chart model.

In addition, several UI components (tables, forms, and editors) have been updated and migrated many components (e.g. admission, Config, Create, PolicyReadmePanel, PolicyTable, Values) to use the <script setup lang="ts"> syntax.

Policy Chart Integration

  • Removed the ArtifactHub integration module and replaced it with a new policyChart module:
  • The new module provides functions to extract resource annotations and determine whether a policy targets global (non-namespaced) resources.
  • Updated components and methods (in Create.vue, Config.vue, and PolicyReadmePanel.vue) to fetch policy details from Policy Charts rather than ArtifactHub packages.
  • Introduced new types/interfaces (PolicyChart and PolicyDetail) to represent policy charts and their associated metadata.
  • A new set of annotations will now be added to a policy created from the UI to help with fetching the Chart questions when in edit mode:
    • kubewarden.io/chart-key
    • kubewarden.io/chart-name
    • kubewarden.io/chart-version
      • If any of these annotations are missing the UI will attempt to find a matching chart based on the module, if not found it will just show the yaml editor for settings.

Necessary Policy chart changes

In order to have the Policy Helm charts displayed correctly within the UI, we need to have a few annotations added to each policy:

  catalog.cattle.io/ui-component: kubewarden # This is added for custom UI deployment of a chart
  catalog.cattle.io/hidden: 'true' # Hide the chart from the catalog chart page
  # catalog.cattle.io/requires-gvr: "policyservers.policies.kubewarden.io/v1" # Declare that this chart provides a type, which other charts may use in `requires-gvr`. Only add to parent, not CRD chart.

  # We can use the `type` annotation to control where the chart is available, which we can define as a Kubewarden Policy
  catalog.cattle.io/type: kubewarden-policy

  # Annotations needed for the UI
  kubewarden/displayName: <policy-displayName>
  kubewarden/mutation: 'true|false'
  kubewarden/contextAwareResources: 'true|false'
  kubewarden/resources: <comma-separated-string>
  • The description and keywords of the chart should also match what we used in the artifacthub-pkg.yaml.

@jordojordo jordojordo self-assigned this Jan 28, 2025
@jordojordo jordojordo added kind/enhancement New feature or request area/policy labels Jan 28, 2025
@jordojordo jordojordo added this to the 3.1.0 milestone Jan 28, 2025
@jordojordo jordojordo marked this pull request as ready for review February 3, 2025 16:38
Copy link
Collaborator

@kravciak kravciak left a comment

Choose a reason for hiding this comment

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

  • I can't create policy server (create button is disabled)
  • currently we have a banner Please add a policy repository. How do users know what repository?
  • source changes from template to custom after upgrade (I guess this is feature..)

Screenshot from 2025-02-11 13-13-41

@jordojordo
Copy link
Member Author

@kravciak I've updated the PR a bit to account for the recent changes from the RFC: kubewarden/rfc#46

It currently will not work properly as the questions.yaml files for each chart is incorrect within the POC of the main charts repo: kubewarden/helm-charts@main...rancher-policies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/policy kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

POC: Use helm charts to populate policy creation table
2 participants