-
Notifications
You must be signed in to change notification settings - Fork 53
fix: Set unique ingress hostnames for local Kind clusters #326
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
Conversation
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
// 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
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
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
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
|
||
// 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
Signed-off-by: ruokun-niu <[email protected]>
Signed-off-by: ruokun-niu <[email protected]>
Signed-off-by: ruokun-niu <[email protected]>
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
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
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:
Let's say we have the following reactions deployed:
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:
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
Fixes: #323