-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttps-only.yml
More file actions
28 lines (28 loc) · 1.02 KB
/
Copy pathhttps-only.yml
File metadata and controls
28 lines (28 loc) · 1.02 KB
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
apiVersion: templates.gatekeeper.sh/v1beta1
kind: ConstraintTemplate
metadata:
name: k8shttpsonly
annotations:
description: Requires Ingress resources to be HTTPS only; TLS configuration should
be set and `kubernetes.io/ingress.allow-http` annotation equals false.
spec:
crd:
spec:
names:
kind: K8sHttpsOnly
targets:
- target: admission.k8s.gatekeeper.sh
rego: |
package k8shttpsonly
violation[{"msg": msg}] {
input.review.object.kind == "Ingress"
re_match("^(extensions|networking.k8s.io)/", input.review.object.apiVersion)
ingress := input.review.object
not https_complete(ingress)
msg := sprintf("Ingress should be https. tls configuration and allow-http=false annotation are required for %v", [ingress.metadata.name])
}
https_complete(ingress) = true {
ingress.spec["tls"]
count(ingress.spec.tls) > 0
ingress.metadata.annotations["kubernetes.io/ingress.allow-http"] == "false"
}