You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Working with the TemplateManagement Object will include a lot of enabling of templatechains in namespaces, which itself can be done with kubectl patch.
Assuming the provided TemplateManagement with a single Chain enabled in the target Namespace:
I would expect the hmc TemplateManagement object to look like this:
apiVersion: hmc.mirantis.com/v1alpha1kind: TemplateManagementmetadata:
name: hmcspec:
accessRules:
- clusterTemplateChains:
- demo-aws-hosted-cp-0.0.1targetNamespaces:
list:
- blue
- clusterTemplateChains:
- demo-aws-hosted-cp-0.0.2targetNamespaces:
list:
- green
but unfortunately it fails with:
error: application/strategic-merge-patch+json is not supported by hmc.mirantis.com/v1alpha1, Kind=TemplateManagement: the body of the request was in an unknown format - accepted media types include: application/json-patch+json, application/merge-patch+json, application/apply-patch+yaml
the other patch strategies unfortunately cause the existing accessRules to be overwriten and not merged together.
I can workaround this with some yq magic, but it would be great if we can support this with kubectl out of the box
The text was updated successfully, but these errors were encountered:
I’m not certain that implementing the strategic merge patch for our TemplateManagement CRD is feasible. The official Kubernetes documentation states that strategic merge patching is not supported for custom resources. For reference:
Additionally, for a strategic merge patch to work, the resource struct should include a field (e.g., name) to uniquely identify array elements during the merge (via patchMergeKey). In our TemplateManagement spec, we don’t have such a field that can be used as a key for merging array elements.
I’m not sure we need to introduce these API changes for our use case. Instead, I suggest using a JSON patch as an alternative. Below is an example of a JSON patch file (patch.json) that adds a new rule to the accessRules array:
Working with the TemplateManagement Object will include a lot of enabling of templatechains in namespaces, which itself can be done with
kubectl patch
.Assuming the provided TemplateManagement with a single Chain enabled in the target Namespace:
and the following green-patch1.yaml:
and then running
I would expect the hmc TemplateManagement object to look like this:
but unfortunately it fails with:
the other patch strategies unfortunately cause the existing accessRules to be overwriten and not merged together.
I can workaround this with some yq magic, but it would be great if we can support this with kubectl out of the box
The text was updated successfully, but these errors were encountered: