Replace is not supported in kyverno1.10. So, used a combination of remove and add.
Add a rule to restrict-adding-capabilities-other-than-net-bind-service.
The patchesJson6902 method can be useful when a specific mutation is needed which cannot be performed by patchesStrategicMerge. For example, when needing to mutate a specific object within an array, the index can be specified as part of a patchesJson6902 mutation rule.
One distinction between this and other mutation methods is that patchesJson6902 does not support the use of conditional anchors. Use preconditions instead. Also, mutations using patchesJson6902 to Pods directly are not converted to higher-level controllers such as Deployments and StatefulSets through the use of the auto-gen feature. Therefore, when writing such mutation rules for Pods, it may be necessary to create multiple rules to cover all relevant Pod controllers.
Since we cannot use conditional anchors had to use two pre conditions.
Previously, the existing rule for drop all capabilities was clearing all entries in securityContext. Fixed it
Description:
Final Changes:
Replace is not supported in kyverno1.10. So, used a combination of
remove and add.
Add a rule to restrict-adding-capabilities-other-than-net-bind-service.
Since we cannot use conditional anchors had to use two pre conditions.