Skip to content

Add patchMergeKey to VMRule CRDs #657

@vaskozl

Description

@vaskozl

The CRDs do not define patchMergeKey and patchStrategy for both group names and rule alert fields.

https://github.com/VictoriaMetrics/operator/blob/master/api/v1beta1/vmrule_types.go

The lack of merge keys makes it hard to adjust the rules and alerts with both kubectl patch and kustomize. This is especially prudent when you deploy the default rules with the stack chart, which can be quite noisy.

For example if one uses the stack chart deployed with flux, but wants to adjust some rules after the fact, they may used a kustomize postrenderer (or otherwise directly with kubectl patch) to try and and change a given rule (e.g. increasing the required alert time to 15m -> 60m):

   kind: VMRule    
   apiVersion: operator.victoriametrics.com/v1beta1    
   metadata:    
     name: stack-kubernetes-apps    
     namespace: victoria-metrics    
   spec:    
     groups:    
       - name: kubernetes-apps    
         rules:    
           - alert: KubeDeploymentGenerationMismatch                                              
             for: 60m 

Without the merge key the entire list of groups is overwritten, replacing everything with the list in the patch. The only current solution is to redefine the entirety of the Rules in your patch or to otherwise use a JSON patch with the numeric index of the group/rule you want to patch (which may change as new version of the charts are pushed). While in theory the chart could allow for rule customization, I would expect the CRDs to specify merging on group name and alert rule field.

This currently affects v0.34.0 of the operator and apiVersion operator.victoriametrics.com/v1beta1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestwaiting for releaseThe change was merged to upstream, but wasn't released yet.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions