1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-04-09 10:42:22 +00:00

Update writing-policies-validate.md

This commit is contained in:
Denys Bielyshev 2019-06-24 11:06:39 +03:00 committed by GitHub
parent 6cdb7c3abb
commit b219088e26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -66,6 +66,39 @@ spec :
````
### Check if one exist
A variation of an anchor, is to check existance of one element. This is done by using the ^(...) notation for the field.
For example, this pattern will check the existance of "name" field in the list:
````yaml
apiVersion : kyverno.io/v1alpha1
kind : Policy
metadata :
name : validation-example2
spec :
rules:
- name: check-memory_requests_link_in_yaml_relative
resource:
# Kind specifies one or more resource types to match
kinds:
- Deployment
# Name is optional and can use wildcards
name: "*"
# Selector is optional
selector:
validate:
pattern:
spec:
containers:
- ^(name): "*"
resources:
requests:
memory: "$(<=./../../lim(its/mem)ory)"
lim(its:
mem)ory: "2048Mi"
````
Additional examples are available in [examples](/examples/)