-
Notifications
You must be signed in to change notification settings - Fork 0
[feature]: Added support for external DNS using dns endpoint #56
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e0be114
[feature]: Added support for external DNS using dns endpoint
sebasnallar ee523fd
[feature]: waiting on balancer recognition for route
sebasnallar 44d4d89
[chore]: rename dns type to 'external_dns' in mninus
sebasnallar eae23d0
[chore]: merge beta
sebasnallar acf9491
[chore]: revert values.yaml
sebasnallar b4f040f
[chore]: get information from providers for gateways
sebasnallar 3b5f118
[chore]: rework, we now apply the dns ednpoint only on scope creation
sebasnallar 38fe2a8
[chore]: rework, we now apply the dns ednpoint only on scope creation
sebasnallar abf20f7
[chore]: pr review
sebasnallar 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,22 @@ | ||
| apiVersion: externaldns.k8s.io/v1alpha1 | ||
| kind: DNSEndpoint | ||
| metadata: | ||
| name: k-8-s-{{ .scope.slug }}-{{ .scope.id }}-dns | ||
| namespace: {{ .k8s_namespace }} | ||
| labels: | ||
| nullplatform: "true" | ||
| account: {{ .account.slug }} | ||
| account_id: "{{ .account.id }}" | ||
| namespace: {{ .namespace.slug }} | ||
| namespace_id: "{{ .namespace.id }}" | ||
| application: {{ .application.slug }} | ||
| application_id: "{{ .application.id }}" | ||
| scope: {{ .scope.slug }} | ||
| scope_id: "{{ .scope.id }}" | ||
| spec: | ||
| endpoints: | ||
| - dnsName: {{ .scope.domain }} | ||
| recordTTL: 60 | ||
| recordType: A | ||
| targets: | ||
| - "{{ .gateway_ip }}" |
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
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
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
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,59 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| if [ "$ACTION" = "CREATE" ]; then | ||
| echo "Building DNSEndpoint manifest for ExternalDNS..." | ||
|
|
||
| echo "Getting IP for gateway: $GATEWAY_NAME" | ||
|
|
||
| GATEWAY_IP=$(kubectl get gateway "$GATEWAY_NAME" -n gateways \ | ||
| -o jsonpath='{.status.addresses[?(@.type=="IPAddress")].value}' 2>/dev/null) | ||
|
|
||
| if [ -z "$GATEWAY_IP" ]; then | ||
| echo "Warning: Could not get gateway IP for $GATEWAY_NAME" | ||
|
|
||
| GATEWAY_IP=$(kubectl get service "$GATEWAY_NAME" -n gateways \ | ||
| -o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null) | ||
| fi | ||
|
|
||
| if [ -z "$GATEWAY_IP" ]; then | ||
| echo "Warning: Could not determine gateway IP address yet, DNSEndpoint will be created later" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Gateway IP: $GATEWAY_IP" | ||
|
|
||
| DNS_ENDPOINT_TEMPLATE="${DNS_ENDPOINT_TEMPLATE:-$SERVICE_PATH/deployment/templates/dns-endpoint.yaml.tpl}" | ||
|
|
||
| if [ -f "$DNS_ENDPOINT_TEMPLATE" ]; then | ||
| DNS_ENDPOINT_FILE="$OUTPUT_DIR/dns-endpoint-$SCOPE_ID.yaml" | ||
| CONTEXT_PATH="$OUTPUT_DIR/context-$SCOPE_ID-dns.json" | ||
|
|
||
| echo "$CONTEXT" | jq --arg gateway_ip "$GATEWAY_IP" '. + {gateway_ip: $gateway_ip}' > "$CONTEXT_PATH" | ||
|
|
||
| echo "Building DNSEndpoint Template: $DNS_ENDPOINT_TEMPLATE to $DNS_ENDPOINT_FILE" | ||
|
|
||
| gomplate -c .="$CONTEXT_PATH" \ | ||
| --file "$DNS_ENDPOINT_TEMPLATE" \ | ||
| --out "$DNS_ENDPOINT_FILE" | ||
|
|
||
| echo "DNSEndpoint manifest created at: $DNS_ENDPOINT_FILE" | ||
|
|
||
| rm "$CONTEXT_PATH" | ||
|
|
||
| else | ||
| echo "Error: DNSEndpoint template not found at $DNS_ENDPOINT_TEMPLATE" | ||
| exit 1 | ||
| fi | ||
|
|
||
| elif [ "$ACTION" = "DELETE" ]; then | ||
| echo "Deleting DNSEndpoint for external_dns..." | ||
|
|
||
| SCOPE_SLUG=$(echo "$CONTEXT" | jq -r '.scope.slug') | ||
| DNS_ENDPOINT_NAME="k-8-s-${SCOPE_SLUG}-${SCOPE_ID}-dns" | ||
| echo "Attempting to delete DNSEndpoint by name: $DNS_ENDPOINT_NAME" | ||
| kubectl delete dnsendpoint "$DNS_ENDPOINT_NAME" -n "$K8S_NAMESPACE" || echo "DNSEndpoint may already be deleted" | ||
|
|
||
| echo "DNSEndpoint deletion completed" | ||
| fi | ||
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
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 |
|---|---|---|
|
|
@@ -15,4 +15,5 @@ gomplate -c .="$CONTEXT_PATH" \ | |
| --file "$TEMPLATE" \ | ||
| --out "$INGRESS_FILE" | ||
|
|
||
|
|
||
| rm "$CONTEXT_PATH" | ||
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,59 @@ | ||
| #!/bin/bash | ||
|
|
||
| echo "Waiting for balancer/DNS setup to complete..." | ||
|
|
||
| MAX_ITERATIONS=${MAX_ITERATIONS:-30} | ||
| iteration=0 | ||
|
|
||
| case "$DNS_TYPE" in | ||
| external_dns) | ||
| SCOPE_DOMAIN=$(echo "$CONTEXT" | jq -r '.scope.domain') | ||
| SCOPE_SLUG=$(echo "$CONTEXT" | jq -r '.scope.slug') | ||
| SCOPE_ID=$(echo "$CONTEXT" | jq -r '.scope.id') | ||
|
|
||
| echo "Checking ExternalDNS record creation for domain: $SCOPE_DOMAIN" | ||
|
|
||
| while true; do | ||
| iteration=$((iteration + 1)) | ||
| if [ $iteration -gt $MAX_ITERATIONS ]; then | ||
| echo "⚠️ DNS record creation timeout after $((MAX_ITERATIONS * 10))s" | ||
| echo "ExternalDNS may still be processing the DNSEndpoint resource" | ||
| echo "You can check manually with: kubectl get dnsendpoint -A" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Checking DNS resolution for $SCOPE_DOMAIN (attempt $iteration/$MAX_ITERATIONS)" | ||
|
|
||
| DNS_ENDPOINT_NAME="k-8-s-${SCOPE_SLUG}-${SCOPE_ID}-dns" | ||
| echo "Checking DNSEndpoint status: $DNS_ENDPOINT_NAME" | ||
|
|
||
| DNS_STATUS=$(kubectl get dnsendpoint "$DNS_ENDPOINT_NAME" -n "$K8S_NAMESPACE" -o jsonpath='{.status}' 2>/dev/null || echo "not found") | ||
|
|
||
| if [ "$DNS_STATUS" != "not found" ] && [ -n "$DNS_STATUS" ]; then | ||
| echo "DNSEndpoint status: $DNS_STATUS" | ||
| fi | ||
|
|
||
| if nslookup "$SCOPE_DOMAIN" 8.8.8.8 >/dev/null 2>&1; then | ||
| echo "✓ DNS record for $SCOPE_DOMAIN is now resolvable" | ||
|
|
||
| RESOLVED_IP=$(nslookup "$SCOPE_DOMAIN" 8.8.8.8 | grep -A1 "Name:" | tail -1 | awk '{print $2}' 2>/dev/null || echo "unknown") | ||
| echo "✓ Domain $SCOPE_DOMAIN resolves to: $RESOLVED_IP" | ||
|
|
||
| break | ||
| fi | ||
|
|
||
| echo "DNS record not yet available, waiting 10s..." | ||
| sleep 10 | ||
| done | ||
|
|
||
| echo "✓ ExternalDNS setup completed successfully" | ||
| ;; | ||
| route53|azure) | ||
| echo "DNS Type $DNS_TYPE - DNS should already be configured" | ||
| echo "Skipping DNS wait check" | ||
| ;; | ||
| *) | ||
| echo "Unknown DNS type: $DNS_TYPE" | ||
| echo "Skipping DNS wait check" | ||
| ;; | ||
| esac |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.