Skip to content

Commit

Permalink
config: Open cert-manager netpols by default
Browse files Browse the repository at this point in the history
And add config for cert-manager HTTP-01 egress.
  • Loading branch information
aarnq committed Sep 6, 2024
1 parent 5e1ce52 commit 3fe16df
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 3 deletions.
3 changes: 3 additions & 0 deletions config/common-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,9 @@ networkPolicies:
letsencrypt:
ips:
- set-me-if-(.networkPolicies.certManager.enabled)
# Configure this if HTTP-01 challenges need to be enabled in cert-manager for other endpoints than the ingress-controller
http01:
ips: []
# Configure this if DNS-01 challenges are enabled in cert-manager
dns01:
ips: []
Expand Down
13 changes: 13 additions & 0 deletions config/flavors/dev/common-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,16 @@ prometheus:

velero:
enabled: false

networkPolicies:
# ADR: https://elastisys.io/compliantkubernetes/adr/0051-open-cert-manager-netpols/
certManager:
letsencrypt:
ips:
- 0.0.0.0/0
http01:
ips:
- 0.0.0.0/0
dns01:
ips:
- 0.0.0.0/0
13 changes: 13 additions & 0 deletions config/flavors/prod/common-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,16 @@ prometheus:
size: 15Gi
retention:
size: 12GiB

networkPolicies:
# ADR: https://elastisys.io/compliantkubernetes/adr/0051-open-cert-manager-netpols/
certManager:
letsencrypt:
ips:
- 0.0.0.0/0
http01:
ips:
- 0.0.0.0/0
dns01:
ips:
- 0.0.0.0/0
8 changes: 8 additions & 0 deletions config/schemas/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6225,6 +6225,14 @@ properties:
additionalProperties: false
properties:
ips: true
http01:
title: Network Policies cert-manager HTTP-01
description: Configure network policy rule to allow cert-manager perform HTTP-01 challenges on other endpoints than the ingress-controller.
type: object
additionalProperties: false
properties:
ips:
$ref: '#/$defs/iplist'
dns01:
title: Network Policies cert-manager DNS-01
description: Configure network policy rule to allow cert-manager perform DNS-01 challenges.
Expand Down
10 changes: 10 additions & 0 deletions helmfile.d/values/networkpolicies/common/cert-manager.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ policies:
ports:
- tcp: 443
{{- end }}
{{- with .Values | get "networkPolicies.certManager.http01.ips" list }}
- name: egress-rule-http01
peers:
{{- range . }}
- cidr: {{ . }}
{{- end }}
ports:
- tcp: 443
- tcp: 80
{{- end }}
{{- with .Values | get "networkPolicies.certManager.dns01.ips" list }}
- name: egress-rule-dns01
peers:
Expand Down
18 changes: 18 additions & 0 deletions migration/v0.41/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,24 @@ As with all scripts in this repository `CK8S_CONFIG_PATH` is expected to be set.
./bin/ck8s upgrade wc v0.41 apply
```

1. For `dev` and `prod` flavours: The default network policies for cert-manager has changed, and now it is allowed egress to:

- `0.0.0.0/0:53/udp`
- `0.0.0.0/0:53/tcp`
- `0.0.0.0/0:80/tcp`
- `0.0.0.0/0:443/tcp`

To allow it to perform any DNS-01 or HTTP-01 challenge by default.
If you have previously overridden it you can remove the overrides to opt into the new defaults, and if you want to restrict it you need to configure the network policies manually.

To remove previous overrides:

```bash
yq4 -i 'del(.networkPolicies.certManager)' "${CK8S_CONFIG_PATH}/common-config.yaml"
yq4 -i 'del(.networkPolicies.certManager)' "${CK8S_CONFIG_PATH}/sc-config.yaml"
yq4 -i 'del(.networkPolicies.certManager)' "${CK8S_CONFIG_PATH}/wc-config.yaml"
```

1. If Tekton is enabled, ensure to add appropriate network policies for the pipeline.

To check if the tekton is enabled, run the following command
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/general/bin-conditional-set-me.bats
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ setup_file() {
gpg.setup
env.setup

env.init baremetal kubespray dev --skip-issuers --skip-network-policies
env.init baremetal kubespray air-gapped --skip-issuers --skip-network-policies
}

teardown_file() {
Expand Down Expand Up @@ -101,11 +101,11 @@ _refute_condition_and_warn() {
# bats test_tags=conditional_set_me_slack_alerts
@test "conditional-set-me - singular conditions: slack alerts" {

yq.set common .alerts.alertTo \"slack\"
yq.set sc .alerts.alertTo \"slack\"
run _apply_normalise_sc
_assert_condition_and_warn .\"alerts\".\"slack\".\"channel\"

yq.set common .alerts.alertTo \"\"
yq.set sc .alerts.alertTo \"\"
run _apply_normalise_sc
_refute_condition_and_warn .\"alerts\".\"slack\".\"channel\"
}
Expand Down

0 comments on commit 3fe16df

Please sign in to comment.