Skip to content

Commit

Permalink
Added configmap key for upstream zone
Browse files Browse the repository at this point in the history
  • Loading branch information
victor committed Jul 25, 2019
1 parent 1d89339 commit faf7fa2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/configs/config_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func NewDefaultConfigParams() *ConfigParams {
SSLPorts: []int{443},
MaxFails: 1,
MaxConns: 0,
UpstreamZoneSize: "256k",
FailTimeout: "10s",
LBMethod: "random two least_conn",
MainErrorLogLevel: "notice",
Expand Down
4 changes: 4 additions & 0 deletions internal/configs/configmaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ func ParseConfigMap(cfgm *v1.ConfigMap, nginxPlus bool) *ConfigParams {
}
}

if upstreamZoneSize, exists := cfgm.Data["upstream-zone-size"]; exists {
cfgParams.UpstreamZoneSize = upstreamZoneSize
}

if failTimeout, exists := cfgm.Data["fail-timeout"]; exists {
cfgParams.FailTimeout = failTimeout
}
Expand Down
4 changes: 4 additions & 0 deletions internal/configs/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func createExpectedConfigForCafeIngressEx() version1.IngressNginxConfig {
coffeeUpstream := version1.Upstream{
Name: "default-cafe-ingress-cafe.example.com-coffee-svc-80",
LBMethod: "random two least_conn",
UpstreamZoneSize: "256k",
UpstreamServers: []version1.UpstreamServer{
{
Address: "10.0.0.1",
Expand All @@ -137,6 +138,7 @@ func createExpectedConfigForCafeIngressEx() version1.IngressNginxConfig {
teaUpstream := version1.Upstream{
Name: "default-cafe-ingress-cafe.example.com-tea-svc-80",
LBMethod: "random two least_conn",
UpstreamZoneSize: "256k",
UpstreamServers: []version1.UpstreamServer{
{
Address: "10.0.0.2",
Expand Down Expand Up @@ -476,6 +478,7 @@ func createExpectedConfigForMergeableCafeIngress() version1.IngressNginxConfig {
coffeeUpstream := version1.Upstream{
Name: "default-cafe-ingress-coffee-minion-cafe.example.com-coffee-svc-80",
LBMethod: "random two least_conn",
UpstreamZoneSize: "256k",
UpstreamServers: []version1.UpstreamServer{
{
Address: "10.0.0.1",
Expand All @@ -488,6 +491,7 @@ func createExpectedConfigForMergeableCafeIngress() version1.IngressNginxConfig {
teaUpstream := version1.Upstream{
Name: "default-cafe-ingress-tea-minion-cafe.example.com-tea-svc-80",
LBMethod: "random two least_conn",
UpstreamZoneSize: "256k",
UpstreamServers: []version1.UpstreamServer{
{
Address: "10.0.0.2",
Expand Down
1 change: 1 addition & 0 deletions internal/configs/version1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ type MainConfig struct {
func NewUpstreamWithDefaultServer(name string) Upstream {
return Upstream{
Name: name,
UpstreamZoneSize: "256k",
UpstreamServers: []UpstreamServer{
{
Address: "127.0.0.1",
Expand Down
2 changes: 1 addition & 1 deletion internal/configs/version1/nginx.ingress.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{{range $upstream := .Upstreams}}
upstream {{$upstream.Name}} {
{{if $upstream.UpstreamZoneSize }}zone {{$upstream.Name}} {{$upstream.UpstreamZoneSize}};{{end}}
{{if ne $upstream.UpstreamZoneSize "0" }}zone {{$upstream.Name}} {{$upstream.UpstreamZoneSize}};{{end}}
{{if $upstream.LBMethod }}{{$upstream.LBMethod}};{{end}}
{{range $server := $upstream.UpstreamServers}}
server {{$server.Address}}:{{$server.Port}} max_fails={{$server.MaxFails}} fail_timeout={{$server.FailTimeout}} max_conns={{$server.MaxConns}};{{end}}
Expand Down
1 change: 1 addition & 0 deletions internal/configs/version1/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const nginxPlusMainTmpl = "nginx-plus.tmpl"

var testUps = Upstream{
Name: "test",
UpstreamZoneSize: "256k",
UpstreamServers: []UpstreamServer{
{
Address: "127.0.0.1",
Expand Down

0 comments on commit faf7fa2

Please sign in to comment.