-
Notifications
You must be signed in to change notification settings - Fork 8
[ocp4_workload_rhacs] Pre-create CNAME to fix ACME DNS ENT issue on DDNS clusters #146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
prakhar1985
wants to merge
2
commits into
main
Choose a base branch
from
fix-rhacs-ddns-cname-pre-cert
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| --- | ||
| # Pre-create a CNAME record for the central route before ACME cert issuance. | ||
| # | ||
| # Problem: When cert-manager runs a DNS-01 ACME challenge for the central route, | ||
| # it creates a _acme-challenge TXT record which creates a DNS Empty Non-Terminal (ENT). | ||
| # The ENT causes the wildcard *.apps.* to stop matching the central hostname, | ||
| # resulting in NODATA and a failed ACME challenge regardless of which issuer is used. | ||
| # | ||
| # Fix: Pre-create a specific CNAME for the central hostname before cert issuance. | ||
| # The CNAME and the _acme-challenge record coexist as siblings — no ENT problem. | ||
| # | ||
| # Only runs on non-BareMetal platforms. BareMetal clusters use an explicit A record | ||
| # created by dns_registration.yml after Central is deployed — a CNAME would conflict. | ||
| # | ||
| # This task is issuer-agnostic: it finds any ready ClusterIssuer configured with | ||
| # a DDNS webhook and uses its credentials. Silently skips on non-DDNS clusters. | ||
|
|
||
| - name: Get cluster infrastructure platform | ||
| kubernetes.core.k8s_info: | ||
| api_version: config.openshift.io/v1 | ||
| kind: Infrastructure | ||
| name: cluster | ||
| register: r_pre_cert_infrastructure | ||
|
|
||
| - name: Set platform fact | ||
| ansible.builtin.set_fact: | ||
| _ocp4_workload_rhacs_pre_cert_platform: "{{ r_pre_cert_infrastructure.resources[0].status.platform | default('Unknown') }}" | ||
|
|
||
| - name: Find ClusterIssuer with DDNS webhook solver | ||
| when: _ocp4_workload_rhacs_pre_cert_platform not in ["BareMetal", "None"] | ||
| kubernetes.core.k8s_info: | ||
| api_version: cert-manager.io/v1 | ||
| kind: ClusterIssuer | ||
| register: r_pre_cert_cluster_issuers | ||
|
|
||
| - name: Set DDNS issuer fact | ||
| when: _ocp4_workload_rhacs_pre_cert_platform not in ["BareMetal", "None"] | ||
| ansible.builtin.set_fact: | ||
| _ocp4_workload_rhacs_pre_cert_ddns_issuer: >- | ||
| {{ | ||
| r_pre_cert_cluster_issuers.resources | ||
| | json_query("[?spec.acme.solvers[?dns01.webhook.config.ddnsServer]]") | ||
| | first | default({}) | ||
| }} | ||
|
|
||
| - name: Pre-create CNAME record to prevent DNS ENT issue during ACME challenge | ||
| when: | ||
| - _ocp4_workload_rhacs_pre_cert_platform not in ["BareMetal", "None"] | ||
| - _ocp4_workload_rhacs_pre_cert_ddns_issuer | default({}) | length > 0 | ||
| vars: | ||
| _solver: "{{ _ocp4_workload_rhacs_pre_cert_ddns_issuer.spec.acme.solvers[0].dns01.webhook.config }}" | ||
| block: | ||
| - name: Get TSIG secret from cert-manager namespace | ||
| kubernetes.core.k8s_info: | ||
| api_version: v1 | ||
| kind: Secret | ||
| name: "{{ _solver.tsigSecretRef.name }}" | ||
| namespace: cert-manager | ||
| register: r_pre_cert_tsig_secret | ||
|
|
||
| - name: Create CNAME record for central route | ||
| community.general.nsupdate: | ||
| server: "{{ _solver.ddnsServer }}" | ||
| zone: "{{ _solver.ddnsZone }}" | ||
| record: "central-{{ ocp4_workload_rhacs_central_namespace }}.{{ openshift_cluster_ingress_domain | regex_replace('\\.' + _solver.ddnsZone + '$', '') }}" | ||
| type: CNAME | ||
| ttl: 30 | ||
| value: "console-openshift-console.{{ openshift_cluster_ingress_domain }}." | ||
| key_name: "{{ _solver.tsigKeyName }}" | ||
| key_secret: "{{ r_pre_cert_tsig_secret.resources[0].data[_solver.tsigSecretRef.key] | b64decode }}" | ||
| key_algorithm: "{{ _solver.tsigAlgorithm }}" | ||
| state: present |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not doing the same thing in dns_registration.yml? We are already registering the CNAME.