Skip to content

Conversation

ruokun-niu
Copy link
Contributor

@ruokun-niu ruokun-niu commented Oct 13, 2025

Description

In local Kind clusters without LoadBalancer IPs, ingress resources had no host field set, causing all ingresses to become catch-all routes. Multiple reactions routed to the last created ingress regardless of hostname.

Solution:

  • Enhanced CLI --local-cluster flag to auto-set --ingress-ip-address 127.0.0.1 for nip.io DNS
  • Updated the kind config file
  • Modified reconciler.rs to always generate unique hostnames (uses localhost suffix when external IP unavailable)
  • Updated e2e SignalR fixture to use 127.0.0.1.nip.io hostname format

Let's say we have the following reactions deployed:

  drasi list reaction
            ID          | AVAILABLE |                    INGRESS URL                    | MESSAGES
  ----------------------+-----------+---------------------------------------------------+-----------
    hello-world-debug-2 | true      | http://hello-world-debug-2.drasi.127.0.0.1.nip.io |
    hello-world-debug   | true      | http://hello-world-debug.drasi.127.0.0.1.nip.io   |

There are two ways to access the ingress:

Option 1: Using Kind extraPortMappings (Recommended)

Configure your Kind cluster with port mappings in kind-config.yaml:

  kind: Cluster
  apiVersion: kind.x-k8s.io/v1alpha4
  nodes:
  - role: control-plane
    extraPortMappings:
    - containerPort: 30080  # Maps to Contour NodePort 30080
      hostPort: 8001
      listenAddress: "0.0.0.0"
    - containerPort: 30443  # Maps to Contour NodePort 30443
      hostPort: 443
      listenAddress: "0.0.0.0"

Access in browser:
http://hello-world-debug.drasi.127.0.0.1.nip.io:8001
http://hello-world-debug-2.drasi.127.0.0.1.nip.io:8001

Option 2: Using kubectl port-forward

Forward the Contour service to localhost:

kubectl port-forward -n projectcontour svc/contour-envoy 8080:80

Then add entries to /etc/hosts:
echo "127.0.0.1 hello-world-debug.drasi.127.0.0.1.nip.io" | sudo tee -a /etc/hosts
echo "127.0.0.1 hello-world-debug-2.drasi.127.0.0.1.nip.io" | sudo tee -a /etc/hosts

Access in browser:
http://hello-world-debug.drasi.127.0.0.1.nip.io:8080
http://hello-world-debug-2.drasi.127.0.0.1.nip.io:8080

Alternative - using curl with Host header (no /etc/hosts needed):
curl http://localhost:8080 -H "Host: hello-world-debug.drasi.127.0.0.1.nip.io"
curl http://localhost:8080 -H "Host: hello-world-debug-2.drasi.127.0.0.1.nip.io"

Type of change

  • This pull request fixes a bug in Drasi and has an approved issue (issue link required).
  • This pull request adds or changes features of Drasi and has an approved issue (issue link required).
  • This pull request is a minor refactor, code cleanup, test improvement, or other maintenance task and doesn't change the functionality of Drasi (issue link optional).

Fixes: #323

Signed-off-by: ruokun-niu <[email protected]>
Signed-off-by: ruokun-niu <[email protected]>
IngressClassName: installerConfig.ClassName,
IngressService: installerConfig.ServiceName,
IngressNamespace: installerConfig.Namespace,
GatewayIPAddress: "127.0.0.1",

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production
// Format: {reaction-name}.drasi.{ip}.nip.io
// For local testing with kind, we can use localhost
this.hostname = `${this.reactionManifest.name}.drasi.localhost`;
// Format: {reaction-name}.drasi.127.0.0.1.nip.io

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production
this.hostname = `${this.reactionManifest.name}.drasi.localhost`;
// Format: {reaction-name}.drasi.127.0.0.1.nip.io
// This matches the format used by drasi ingress init --local-cluster
this.hostname = `${this.reactionManifest.name}.drasi.127.0.0.1.nip.io`;

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production
Signed-off-by: ruokun-niu <[email protected]>
Signed-off-by: ruokun-niu <[email protected]>
const hubUrl = `http://localhost:${this.localPort}/hub`;

// Create SignalR connection through ingress using nip.io hostname
// nip.io automatically resolves *.127.0.0.1.nip.io to 127.0.0.1

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production
const hubUrl = `http://localhost:${this.localPort}/hub`;

// Create SignalR connection through ingress using nip.io hostname
// nip.io automatically resolves *.127.0.0.1.nip.io to 127.0.0.1

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production

// Create SignalR connection through ingress using nip.io hostname
// nip.io automatically resolves *.127.0.0.1.nip.io to 127.0.0.1
const hubUrl = `http://${this.hostname}:${this.localPort}/hub`;

Check warning

Code scanning / devskim

An HTTP-based URL without TLS was detected. Warning

Insecure URL
Signed-off-by: ruokun-niu <[email protected]>
@ruokun-niu ruokun-niu marked this pull request as ready for review October 13, 2025 23:22
@ruokun-niu ruokun-niu requested a review from a team as a code owner October 13, 2025 23:22
log::warn!("Could not determine external IP, using None");
rule.host = None;
log::warn!(
"Could not determine external IP, using 127.0.0.1"

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production
log::warn!(
"Could not determine external IP, using 127.0.0.1"
);
rule.host = Some(host.replace("PLACEHOLDER", "127.0.0.1"));

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production
@danielgerlag danielgerlag merged commit 1d22c3c into drasi-project:main Oct 15, 2025
71 of 72 checks passed
@ruokun-niu ruokun-niu deleted the ingress-host-fix branch October 15, 2025 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ingress Host not set

3 participants