1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-29 10:55:05 +00:00

add require_probes.yaml

This commit is contained in:
Shuting Zhao 2019-10-09 17:49:00 -07:00
parent ea25ed8460
commit 3e1ef320a8
5 changed files with 57 additions and 2 deletions

View file

@ -10,8 +10,8 @@
| Require read only root filesystem | [policy_validate_not_readonly_rootfilesystem.yaml](policy_validate_not_readonly_rootfilesystem.yaml) | best_practices |
| Disallow node ports | [policy_validate_disallow_node_port.yaml](policy_validate_disallow_node_port.yaml) | best_practices |
| Allow trusted registries | [policy_validate_whitelist_image_registries.yaml](policy_validate_whitelist_image_registries.yaml) |
| Require resource requests and limits | [policy_validate_pod_resources.yaml](policy_validate_pod_resources.yaml) |
| Require pod liveness and readiness probes | [policy_validate_pod_probes.yaml](policy_validate_pod_probes.yaml) |
| Require resource requests and limits | [policy_validate_pod_resources.yaml](policy_validate_pod_resources.yaml) | best_practices |
| Require pod liveness and readiness probes | [policy_validate_pod_probes.yaml](policy_validate_pod_probes.yaml) | best_practices |
| Require an image tag | [policy_validate_image_tag_notspecified_deny.yaml](policy_validate_image_tag_notspecified_deny.yaml) |
| Disallow latest tag and pull IfNotPresent | [policy_validate_image_latest_ifnotpresent_deny.yaml](policy_validate_image_latest_ifnotpresent_deny.yaml) |
| Require a namespace (disallow default) | [policy_validate_default_namespace.yaml](policy_validate_default_namespace.yaml) |

View file

@ -143,3 +143,7 @@ func Test_validate_whitelist_image_registries(t *testing.T) {
func Test_require_pod_requests_limits(t *testing.T) {
testScenario(t, "test/scenarios/test/scenario_validate_require_pod_requests_limits.yaml")
}
func Test_require_probes(t *testing.T) {
testScenario(t, "test/scenarios/test/scenario_validate_probes.yaml")
}

View file

@ -0,0 +1,21 @@
apiVersion: kyverno.io/v1alpha1
kind: ClusterPolicy
metadata:
name: validate-probes
spec:
rules:
- name: check-probes
match:
resources:
kinds:
- Pod
validate:
message: "Liveness and readiness probes are required"
pattern:
spec:
containers:
- livenessProbe:
periodSeconds: ">0"
readinessProbe:
periodSeconds: ">0"

View file

@ -0,0 +1,12 @@
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
spec:
containers:
- name: nginx
image: nginx
readinessProbe:
periodSeconds: 5

View file

@ -0,0 +1,18 @@
# file path relative to project root
input:
policy: samples/best_practices/require_probes.yaml
resource: test/manifest/require_probes.yaml
expected:
validation:
policyresponse:
policy: validate-probes
resource:
kind: Pod
apiVersion: v1
namespace: ''
name: myapp-pod
rules:
- name: check-probes
type: Validation
message: Validation rule 'check-probes' failed at '/spec/containers/0/livenessProbe/' for resource Pod//myapp-pod. Liveness and readiness probes are required
success: false