Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ metadata:
policies.kyverno.io/minversion: 1.17.0
policies.kyverno.io/description: >-
Limits explicit ExternalDNS records to the owning product's namespace and
the approved DNS-only documentation CNAME. Tenant labels do not grant DNS
the approved DNS-only records: the documentation CNAME and company
Email's Amazon SES records. Tenant labels do not grant DNS
ownership. New records require a reviewed allow-list change.
spec:
validationActions:
Expand Down Expand Up @@ -47,13 +48,59 @@ spec:
"providerSpecific": dyn([{"name": "cloudflare/proxied", "value": "false"}])
}
]
# Company Email's Amazon SES records (platform#5481), DNS-only and owned by
# one platform-applied DNSEndpoint in the aws namespace: the MAIL FROM
# domain's MX and SPF records and the identity's three Easy DKIM CNAMEs.
# The mailbox domain's own SPF and DMARC records are not managed here.
- name: companyMailEndpoints
expression: >-
[
{
"dnsName": dyn("bounce.devantler.tech"),
"recordType": dyn("MX"),
"recordTTL": dyn(300),
"targets": dyn(["10 feedback-smtp.eu-central-1.amazonses.com"]),
"providerSpecific": dyn([{"name": "cloudflare/proxied", "value": "false"}])
},
{
"dnsName": dyn("bounce.devantler.tech"),
"recordType": dyn("TXT"),
"recordTTL": dyn(300),
"targets": dyn(["v=spf1 include:amazonses.com ~all"]),
"providerSpecific": dyn([{"name": "cloudflare/proxied", "value": "false"}])
},
{
"dnsName": dyn("svxhyimgvhbtlrpbuivbx6ievcg5iwiw._domainkey.devantler.tech"),
"recordType": dyn("CNAME"),
"recordTTL": dyn(300),
"targets": dyn(["svxhyimgvhbtlrpbuivbx6ievcg5iwiw.dkim.amazonses.com"]),
"providerSpecific": dyn([{"name": "cloudflare/proxied", "value": "false"}])
},
{
"dnsName": dyn("frps4kqaz6dyvptmesuiwlaendicjq5v._domainkey.devantler.tech"),
"recordType": dyn("CNAME"),
"recordTTL": dyn(300),
"targets": dyn(["frps4kqaz6dyvptmesuiwlaendicjq5v.dkim.amazonses.com"]),
"providerSpecific": dyn([{"name": "cloudflare/proxied", "value": "false"}])
},
{
"dnsName": dyn("caa46ibjaox7qooavcfri6ha3xbxxjld._domainkey.devantler.tech"),
"recordType": dyn("CNAME"),
"recordTTL": dyn(300),
"targets": dyn(["caa46ibjaox7qooavcfri6ha3xbxxjld.dkim.amazonses.com"]),
"providerSpecific": dyn([{"name": "cloudflare/proxied", "value": "false"}])
}
]
validations:
# CEL equality compares the complete endpoint list, field by field and
# without wildcard matching: extra targets, endpoints, routing fields or
# provider settings cannot slip through, and a missing list never matches.
- expression: >-
object.metadata.namespace == 'data-product-controller' &&
object.?spec.?endpoints.orValue([]) == variables.approvedEndpoints
(object.metadata.namespace == 'data-product-controller' &&
object.?spec.?endpoints.orValue([]) == variables.approvedEndpoints) ||
(object.metadata.namespace == 'aws' &&
object.metadata.name == 'company-mail-ses' &&
object.?spec.?endpoints.orValue([]) == variables.companyMailEndpoints)
message: >-
Explicit DNS records require platform ownership and an approved
endpoint, target, record type and DNS-only provider configuration.
56 changes: 56 additions & 0 deletions k8s/providers/hetzner/apps/aws/dns-endpoint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Company Email's Amazon SES DNS records (platform#5481), published DNS-only by
# the platform's external-dns. These are new names, so each has one owner: the
# MAIL FROM domain's MX and SPF records, so that SPF aligns with the mailbox
# domain for DMARC, and the identity's three Easy DKIM CNAMEs, whose tokens
# come from the EmailIdentity's status. The mailbox domain's own SPF and DMARC
# records are not managed here. restrict-explicit-dns-records admits exactly
# this endpoint list in this namespace and under this name.
apiVersion: externaldns.k8s.io/v1alpha1
kind: DNSEndpoint
metadata:
name: company-mail-ses
namespace: aws
labels:
app.kubernetes.io/managed-by: ksail
spec:
endpoints:
- dnsName: bounce.devantler.tech
recordTTL: 300
recordType: MX
targets:
- 10 feedback-smtp.eu-central-1.amazonses.com
providerSpecific:
- name: cloudflare/proxied
value: "false"
- dnsName: bounce.devantler.tech
recordTTL: 300
recordType: TXT
targets:
- v=spf1 include:amazonses.com ~all
providerSpecific:
- name: cloudflare/proxied
value: "false"
- dnsName: svxhyimgvhbtlrpbuivbx6ievcg5iwiw._domainkey.devantler.tech
recordTTL: 300
recordType: CNAME
targets:
- svxhyimgvhbtlrpbuivbx6ievcg5iwiw.dkim.amazonses.com
providerSpecific:
- name: cloudflare/proxied
value: "false"
- dnsName: frps4kqaz6dyvptmesuiwlaendicjq5v._domainkey.devantler.tech
recordTTL: 300
recordType: CNAME
targets:
- frps4kqaz6dyvptmesuiwlaendicjq5v.dkim.amazonses.com
providerSpecific:
- name: cloudflare/proxied
value: "false"
- dnsName: caa46ibjaox7qooavcfri6ha3xbxxjld._domainkey.devantler.tech
recordTTL: 300
recordType: CNAME
targets:
- caa46ibjaox7qooavcfri6ha3xbxxjld.dkim.amazonses.com
providerSpecific:
- name: cloudflare/proxied
value: "false"
1 change: 1 addition & 0 deletions k8s/providers/hetzner/apps/aws/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ resources:
- access-key-email-smtp.yaml
- push-secret-email-smtp.yaml
- role-ses-account-setup.yaml
- dns-endpoint.yaml
- external-secret.yaml
- oci-repository.yaml
- flux-kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ spec:
sources:
- gateway-httproute
- crd
# The chart default manages only A, AAAA and CNAME. Company Email's SES
# DNSEndpoint also declares MX and TXT records (platform#5481). The TXT
# registry still owns only records carrying this instance's marker, so
# existing MX, SPF and DMARC records that external-dns did not create stay
# untouched.
managedRecordTypes:
- A
- AAAA
- CNAME
- MX
- TXT
policy: sync
# TXT-registry ownership is what makes this single writer safe to reschedule:
# every managed record gets a paired "_externaldns." TXT carrying this
Expand Down
2 changes: 1 addition & 1 deletion scripts/validate-eks-ci-role-policy/approved-surface.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ helm.toolkit.fluxcd.io/v2|HelmRelease|crossplane-system|crossplane fb717f7c9adb2

helm.toolkit.fluxcd.io/v2|HelmRelease|dex|dex e2cbe6e6b5ace19ebded8d0e75f508277dd450c079ed51062d13649e148904b9

helm.toolkit.fluxcd.io/v2|HelmRelease|external-dns|external-dns 31c51b3b18a4d7dfbbe2fec098d6aad40f292dd29c6e91f0422217969ce24e45
helm.toolkit.fluxcd.io/v2|HelmRelease|external-dns|external-dns 107eaf8ad3d74abff5c6b1c6d7ca1b49ac75829fe425672f81cdc1e799457511

helm.toolkit.fluxcd.io/v2|HelmRelease|external-secrets|external-secrets 8f35691cdbe76b4011798a5adba69e8fc77415acf56aa0187e460015d8608087

Expand Down
15 changes: 15 additions & 0 deletions tests/restrict-explicit-dns-records-create/kyverno-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,18 @@ results:
- wedding-app/forged-label
kind: DNSEndpoint
result: fail
- policy: restrict-explicit-dns-records
resources:
- aws/company-mail-ses
kind: DNSEndpoint
result: pass
- policy: restrict-explicit-dns-records
resources:
- aws/other-mail-records
kind: DNSEndpoint
result: fail
- policy: restrict-explicit-dns-records
resources:
- data-product-controller/company-mail-ses
kind: DNSEndpoint
result: fail
144 changes: 144 additions & 0 deletions tests/restrict-explicit-dns-records-create/resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,147 @@ spec:
providerSpecific:
- name: cloudflare/proxied
value: "false"
---
apiVersion: externaldns.k8s.io/v1alpha1
kind: DNSEndpoint
metadata:
name: company-mail-ses
namespace: aws
spec:
endpoints:
- dnsName: bounce.devantler.tech
recordTTL: 300
recordType: MX
targets:
- 10 feedback-smtp.eu-central-1.amazonses.com
providerSpecific:
- name: cloudflare/proxied
value: "false"
- dnsName: bounce.devantler.tech
recordTTL: 300
recordType: TXT
targets:
- v=spf1 include:amazonses.com ~all
providerSpecific:
- name: cloudflare/proxied
value: "false"
- dnsName: svxhyimgvhbtlrpbuivbx6ievcg5iwiw._domainkey.devantler.tech
recordTTL: 300
recordType: CNAME
targets:
- svxhyimgvhbtlrpbuivbx6ievcg5iwiw.dkim.amazonses.com
providerSpecific:
- name: cloudflare/proxied
value: "false"
- dnsName: frps4kqaz6dyvptmesuiwlaendicjq5v._domainkey.devantler.tech
recordTTL: 300
recordType: CNAME
targets:
- frps4kqaz6dyvptmesuiwlaendicjq5v.dkim.amazonses.com
providerSpecific:
- name: cloudflare/proxied
value: "false"
- dnsName: caa46ibjaox7qooavcfri6ha3xbxxjld._domainkey.devantler.tech
recordTTL: 300
recordType: CNAME
targets:
- caa46ibjaox7qooavcfri6ha3xbxxjld.dkim.amazonses.com
providerSpecific:
- name: cloudflare/proxied
value: "false"
---
apiVersion: externaldns.k8s.io/v1alpha1
kind: DNSEndpoint
metadata:
name: other-mail-records
namespace: aws
spec:
endpoints:
- dnsName: bounce.devantler.tech
recordTTL: 300
recordType: MX
targets:
- 10 feedback-smtp.eu-central-1.amazonses.com
providerSpecific:
- name: cloudflare/proxied
value: "false"
- dnsName: bounce.devantler.tech
recordTTL: 300
recordType: TXT
targets:
- v=spf1 include:amazonses.com ~all
providerSpecific:
- name: cloudflare/proxied
value: "false"
- dnsName: svxhyimgvhbtlrpbuivbx6ievcg5iwiw._domainkey.devantler.tech
recordTTL: 300
recordType: CNAME
targets:
- svxhyimgvhbtlrpbuivbx6ievcg5iwiw.dkim.amazonses.com
providerSpecific:
- name: cloudflare/proxied
value: "false"
- dnsName: frps4kqaz6dyvptmesuiwlaendicjq5v._domainkey.devantler.tech
recordTTL: 300
recordType: CNAME
targets:
- frps4kqaz6dyvptmesuiwlaendicjq5v.dkim.amazonses.com
providerSpecific:
- name: cloudflare/proxied
value: "false"
- dnsName: caa46ibjaox7qooavcfri6ha3xbxxjld._domainkey.devantler.tech
recordTTL: 300
recordType: CNAME
targets:
- caa46ibjaox7qooavcfri6ha3xbxxjld.dkim.amazonses.com
providerSpecific:
- name: cloudflare/proxied
value: "false"
---
apiVersion: externaldns.k8s.io/v1alpha1
kind: DNSEndpoint
metadata:
name: company-mail-ses
namespace: data-product-controller
spec:
endpoints:
- dnsName: bounce.devantler.tech
recordTTL: 300
recordType: MX
targets:
- 10 feedback-smtp.eu-central-1.amazonses.com
providerSpecific:
- name: cloudflare/proxied
value: "false"
- dnsName: bounce.devantler.tech
recordTTL: 300
recordType: TXT
targets:
- v=spf1 include:amazonses.com ~all
providerSpecific:
- name: cloudflare/proxied
value: "false"
- dnsName: svxhyimgvhbtlrpbuivbx6ievcg5iwiw._domainkey.devantler.tech
recordTTL: 300
recordType: CNAME
targets:
- svxhyimgvhbtlrpbuivbx6ievcg5iwiw.dkim.amazonses.com
providerSpecific:
- name: cloudflare/proxied
value: "false"
- dnsName: frps4kqaz6dyvptmesuiwlaendicjq5v._domainkey.devantler.tech
recordTTL: 300
recordType: CNAME
targets:
- frps4kqaz6dyvptmesuiwlaendicjq5v.dkim.amazonses.com
providerSpecific:
- name: cloudflare/proxied
value: "false"
- dnsName: caa46ibjaox7qooavcfri6ha3xbxxjld._domainkey.devantler.tech
recordTTL: 300
recordType: CNAME
targets:
- caa46ibjaox7qooavcfri6ha3xbxxjld.dkim.amazonses.com
providerSpecific:
- name: cloudflare/proxied
value: "false"
16 changes: 16 additions & 0 deletions tests/restrict-explicit-dns-records-ses-drift/kyverno-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: cli.kyverno.io/v1alpha1
kind: Test
metadata:
name: restrict-explicit-dns-records-ses-drift
policies:
- ../../k8s/bases/infrastructure/cluster-policies/best-practices/restrict-explicit-dns-records.yaml
resources:
- resources.yaml
variables: ../restrict-explicit-dns-records-create/values.yaml
results:
- policy: restrict-explicit-dns-records
resources:
- aws/company-mail-ses
kind: DNSEndpoint
result: fail
34 changes: 34 additions & 0 deletions tests/restrict-explicit-dns-records-ses-drift/resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
# The approved name and namespace with drifted content: one record is proxied
# and an extra endpoint is appended. Equality over the complete list refuses it.
apiVersion: externaldns.k8s.io/v1alpha1
kind: DNSEndpoint
metadata:
name: company-mail-ses
namespace: aws
spec:
endpoints:
- dnsName: bounce.devantler.tech
recordTTL: 300
recordType: MX
targets:
- 10 feedback-smtp.eu-central-1.amazonses.com
providerSpecific:
- name: cloudflare/proxied
value: "true"
- dnsName: bounce.devantler.tech
recordTTL: 300
recordType: TXT
targets:
- v=spf1 include:amazonses.com ~all
providerSpecific:
- name: cloudflare/proxied
value: "false"
- dnsName: mail.devantler.tech
recordTTL: 300
recordType: A
targets:
- 192.0.2.1
providerSpecific:
- name: cloudflare/proxied
value: "false"
Loading
Loading