-
Notifications
You must be signed in to change notification settings - Fork 37
/
src.rego
30 lines (26 loc) · 928 Bytes
/
src.rego
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# METADATA
# title: 'RHCOP-OCP_BESTPRACT-00021: Pod replica below 1'
# description: |-
# Never run a single Pod individually.
# See: Fault tolerance -> https://learnk8s.io/production-best-practices#application-development
# custom:
# matchers:
# kinds:
# - apiGroups:
# - apps
# kinds:
# - Deployment
# - apiGroups:
# - apps.openshift.io
# kinds:
# - DeploymentConfig
package ocp.bestpractices.pod_replicas_below_one
import data.lib.konstraint.core as konstraint_core
import data.lib.openshift
violation[msg] {
openshift.is_policy_active("RHCOP-OCP_BESTPRACT-00021")
openshift.pod
replicas := konstraint_core.resource.spec.replicas
replicas <= 1
msg := konstraint_core.format_with_id(sprintf("%s/%s: replicas is %d - expected replicas to be greater than 1 for HA guarantees.", [konstraint_core.kind, konstraint_core.name, replicas]), "RHCOP-OCP_BESTPRACT-00021")
}