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

Support kyverno-style mutation in globalization and localization #551

Open
abstractmj opened this issue Dec 7, 2022 · 2 comments · May be fixed by #564
Open

Support kyverno-style mutation in globalization and localization #551

abstractmj opened this issue Dec 7, 2022 · 2 comments · May be fixed by #564
Assignees
Labels
kind/feature New feature or request

Comments

@abstractmj
Copy link
Contributor

abstractmj commented Dec 7, 2022

What would you like to be added:

Support kyverno-style mutation in globalization and localization

Why is this needed:

The current globalization and localization strategies are not flexible enough to modify objects based on specific conditions

story1:
on tencent cloud, use qgpu for gpu virtualization, value 100 for a gpu card:
tke.cloud.tencent.com/qgpu-core: 100

on other cloud, use vgpu for gpu virtualization, value 50 for a gpu card:
example.com/vgpu: 50

for user-friendliness, resource type conversion and value conversion are required

story2:
on different clouds, there are different node label value for the same label key;
for example:
kubernetes.io/region: sg
kubernetes.io/region: singapore

for user-friendliness, resource type conversion and value conversion are required

kyverno is the most popular open-source project to do validation and mutation, it can meet the above needs , but it is hard to use kyverno to hook all manifests and description

the simple draft I came up with:

add extra mutation logic

point 1: add extra field

const (
	// HelmType applies Helm values for all matched HelmCharts.
	// Note: HelmType only works with HelmChart(s).
	HelmType OverrideType = "Helm"

	// JSONPatchType applies a json patch for all matched objects.
	// Note: JSONPatchType does not work with HelmChart(s).
	JSONPatchType OverrideType = "JSONPatch"

	// MergePatchType applies a json merge patch for all matched objects.
	// Note: MergePatchType does not work with HelmChart(s).
	MergePatchType OverrideType = "MergePatch"

	// StrategicMergePatchType won't be supported, since `patchStrategy`
	// and `patchMergeKey` can not be retrieved.

        .....
        KyvernoPathType = "Kyverno"
)
// OverrideConfig holds information that describes a override config.
type OverrideConfig struct {
	// Name indicate the OverrideConfig name.
	//
	// +optional
	Name string `json:"name,omitempty"`

	// Value represents override value.
	//
	// +required
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Type=string
	Value string `json:"value"`

	// Type specifies the override type for override value.
	//
	// +required
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Type=string
	// +kubebuilder:validation:Enum=Helm;JSONPatch;MergePatch
	Type OverrideType `json:"type"`

         // Mutation kyverno style mutation configuration
        // refer to https://github.com/kyverno/kyverno/blob/main/api/kyverno/v1/common_types.go
         Mutation kyvernoapi. Mutation
}

point 2: add mutating logic in Localizer

point 3: currently the globalization only select specified Feed, for select more than one feed, the resource selector should be added to GlobalizationSpec

@abstractmj abstractmj added the kind/feature New feature or request label Dec 7, 2022
@abstractmj abstractmj changed the title Support kyverno-style and mutation in globalization and localization Support kyverno-style mutation in globalization and localization Dec 7, 2022
@dixudx
Copy link
Member

dixudx commented Dec 7, 2022

@abstractmj This is a lovely feature. Would you like to help implement this in Clusternet?

@abstractmj
Copy link
Contributor Author

@abstractmj This is a lovely feature. Would you like to help implement this in Clusternet?
yes, gladly

@dixudx dixudx linked a pull request Jan 9, 2023 that will close this issue
@dixudx dixudx added this to the v0.14.0 milestone Jan 31, 2023
@dixudx dixudx modified the milestones: v0.14.0, v0.15.0 Feb 13, 2023
@dixudx dixudx modified the milestones: v0.15.0, v0.16.0 Feb 27, 2023
@dixudx dixudx modified the milestones: v0.16.0, v0.17.0 Jun 21, 2023
@dixudx dixudx removed this from the v0.17.0 milestone Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants