diff --git a/TAG b/TAG index e423d7464..69d2fe8a3 100644 --- a/TAG +++ b/TAG @@ -1 +1 @@ -v0.44.0 \ No newline at end of file +v0.45.0-dev.0 \ No newline at end of file diff --git a/cmd/nginx/flags.go b/cmd/nginx/flags.go index 55249679a..5fb63b430 100644 --- a/cmd/nginx/flags.go +++ b/cmd/nginx/flags.go @@ -138,7 +138,7 @@ extension for this to succeed.`) `Define the sync frequency upper limit`) publishStatusAddress = flags.String("publish-status-address", "", - `Customized address to set as the load-balancer status of Ingress objects this controller satisfies. + `Customized address (or addresses, separated by comma) to set as the load-balancer status of Ingress objects this controller satisfies. Requires the update-status parameter.`) enableMetrics = flags.Bool("enable-metrics", true, diff --git a/docs/user-guide/cli-arguments.md b/docs/user-guide/cli-arguments.md index fc5634697..799ce7324 100644 --- a/docs/user-guide/cli-arguments.md +++ b/docs/user-guide/cli-arguments.md @@ -38,7 +38,7 @@ They are set in the container spec of the `nginx-ingress-controller` Deployment | `--profiler-port` | Port to use for expose the ingress controller Go profiler when it is enabled. (default 10245) | | `--profiling` | Enable profiling via web interface host:port/debug/pprof/ (default true) | | `--publish-service` | Service fronting the Ingress controller. Takes the form "namespace/name". When used together with update-status, the controller mirrors the address of this service's endpoints to the load-balancer status of all Ingress objects it satisfies. | -| `--publish-status-address` | Customized address to set as the load-balancer status of Ingress objects this controller satisfies. Requires the update-status parameter. | +| `--publish-status-address` | Customized address (or addresses, separated by comma) to set as the load-balancer status of Ingress objects this controller satisfies. Requires the update-status parameter. | | `--report-node-internal-ip-address`| Set the load-balancer status of Ingress objects to internal Node addresses instead of external. Requires the update-status parameter. | | `--skip_headers` | If true, avoid header prefixes in the log messages | | `--skip_log_headers` | If true, avoid headers when opening log files | diff --git a/internal/ingress/status/status.go b/internal/ingress/status/status.go index 51591cc77..506ae398c 100644 --- a/internal/ingress/status/status.go +++ b/internal/ingress/status/status.go @@ -20,6 +20,7 @@ import ( "context" "fmt" "net" + "regexp" "sort" "strings" "time" @@ -165,7 +166,9 @@ func NewStatusSyncer(config Config) Syncer { // ingress controller is currently running func (s *statusSync) runningAddresses() ([]string, error) { if s.PublishStatusAddress != "" { - return []string{s.PublishStatusAddress}, nil + re := regexp.MustCompile(`,\s*`) + multipleAddrs := re.Split(s.PublishStatusAddress, -1) + return multipleAddrs, nil } if s.PublishService != "" { diff --git a/internal/ingress/status/status_test.go b/internal/ingress/status/status_test.go index 1b4b48cf4..9ad0c29cf 100644 --- a/internal/ingress/status/status_test.go +++ b/internal/ingress/status/status_test.go @@ -594,6 +594,51 @@ func TestRunningAddressesWithPublishStatusAddress(t *testing.T) { t.Errorf("returned %v but expected %v", rv, "127.0.0.1") } } + +func TestRunningAddressesWithPublishStatusAddresses(t *testing.T) { + fk := buildStatusSync() + fk.PublishStatusAddress = "127.0.0.1,1.1.1.1" + + ra, _ := fk.runningAddresses() + if ra == nil { + t.Fatalf("returned nil but expected valid []string") + } + rl := len(ra) + if len(ra) != 2 { + t.Errorf("returned %v but expected %v", rl, 2) + } + rv := ra[0] + rv2 := ra[1] + if rv != "127.0.0.1" { + t.Errorf("returned %v but expected %v", rv, "127.0.0.1") + } + if rv2 != "1.1.1.1" { + t.Errorf("returned %v but expected %v", rv2, "1.1.1.1") + } +} + +func TestRunningAddressesWithPublishStatusAddressesAndSpaces(t *testing.T) { + fk := buildStatusSync() + fk.PublishStatusAddress = "127.0.0.1, 1.1.1.1" + + ra, _ := fk.runningAddresses() + if ra == nil { + t.Fatalf("returned nil but expected valid []string") + } + rl := len(ra) + if len(ra) != 2 { + t.Errorf("returned %v but expected %v", rl, 2) + } + rv := ra[0] + rv2 := ra[1] + if rv != "127.0.0.1" { + t.Errorf("returned %v but expected %v", rv, "127.0.0.1") + } + if rv2 != "1.1.1.1" { + t.Errorf("returned %v but expected %v", rv2, "1.1.1.1") + } +} + func TestSliceToStatus(t *testing.T) { fkEndpoints := []string{ "10.0.0.1",