Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cmd/caddy/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"flag"
"strings"

"github.com/caddyserver/ingress/internal/caddy/ingress"
"github.com/caddyserver/ingress/pkg/store"
)

Expand All @@ -29,8 +30,15 @@ func parseFlags() store.Options {
var pluginsOrder string
flag.StringVar(&pluginsOrder, "plugins-order", "", "defines the order plugins should be used")

var clusterDomain string
flag.StringVar(&clusterDomain, "cluster-domain", "", "sets the cluster domain")

flag.Parse()

if clusterDomain != "" {
ingress.ClusterDomain = clusterDomain
}

return store.Options{
WatchNamespace: namespace,
ClassName: className,
Expand Down
4 changes: 3 additions & 1 deletion internal/caddy/ingress/reverseproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/caddyserver/ingress/pkg/converter"
)

var ClusterDomain = "cluster.local"

type ReverseProxyPlugin struct{}

func (p ReverseProxyPlugin) IngressPlugin() converter.PluginInfo {
Expand All @@ -33,7 +35,7 @@ func (p ReverseProxyPlugin) IngressHandler(input converter.IngressMiddlewareInpu
// when setting the upstream url we should bypass kube-dns and get the ip address of
// the pod for the deployment we are proxying to so that we can proxy to that ip address port.
// this is good for session affinity and increases performance.
clusterHostName := fmt.Sprintf("%v.%v.svc.cluster.local:%d", path.Backend.Service.Name, ing.Namespace, path.Backend.Service.Port.Number)
clusterHostName := fmt.Sprintf("%v.%v.svc.%s:%d", path.Backend.Service.Name, ing.Namespace, ClusterDomain, path.Backend.Service.Port.Number)

transport := &reverseproxy.HTTPTransport{}

Expand Down