Skip to content

Commit

Permalink
feat: support redering custom DNS resolvers on Nginx conf
Browse files Browse the repository at this point in the history
  • Loading branch information
nettoclaudio committed Jul 10, 2023
1 parent 435cf11 commit e4eab84
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/v1alpha1/rpaasplan_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ type NginxConfig struct {
VTSEnabled *bool `json:"vtsEnabled,omitempty"`
VTSStatusHistogramBuckets string `json:"vtsStatusHistogramBuckets,omitempty"`

ResolverAddresses []string `json:"resolverAddresses,omitempty"`
ResolverTTL string `json:"resolverTTL,omitempty"`

SyslogEnabled *bool `json:"syslogEnabled,omitempty"`
SyslogServerAddress string `json:"syslogServerAddress,omitempty"`
SyslogFacility string `json:"syslogFacility,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions config/crd/bases/extensions.tsuru.io_rpaasflavors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,12 @@ spec:
type: integer
mapHashMaxSize:
type: integer
resolverAddresses:
items:
type: string
type: array
resolverTTL:
type: string
syslogEnabled:
type: boolean
syslogFacility:
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/extensions.tsuru.io_rpaasinstances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,12 @@ spec:
type: integer
mapHashMaxSize:
type: integer
resolverAddresses:
items:
type: string
type: array
resolverTTL:
type: string
syslogEnabled:
type: boolean
syslogFacility:
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/extensions.tsuru.io_rpaasplans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ spec:
type: integer
mapHashMaxSize:
type: integer
resolverAddresses:
items:
type: string
type: array
resolverTTL:
type: string
syslogEnabled:
type: boolean
syslogFacility:
Expand Down
4 changes: 4 additions & 0 deletions internal/pkg/rpaas/nginx/configuration_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ http {
include mime.types;
default_type application/octet-stream;
{{- if $config.ResolverAddresses }}
resolver {{ join " " $config.ResolverAddresses }}{{ with $config.ResolverTTL }} ttl={{ . }}{{ end }};
{{- end }}
{{- $logFormatName := default "rpaasv2" $config.LogFormatName }}
{{- if $config.LogFormat }}
Expand Down
25 changes: 25 additions & 0 deletions internal/pkg/rpaas/nginx/configuration_render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,31 @@ func TestRpaasConfigurationRenderer_Render(t *testing.T) {
`, result)
},
},
{
name: "with custom resolver",
data: ConfigurationData{
Config: &v1alpha1.NginxConfig{
ResolverAddresses: []string{"kube-dns.kube-system.svc.cluster.local.", "169.196.255.254:3553"},
},
Instance: &v1alpha1.RpaasInstance{},
},
assertion: func(t *testing.T, result string) {
assert.Regexp(t, `\s+resolver kube-dns\.kube-system\.svc\.cluster\.local\. 169\.196\.255\.254:3553;\n`, result)
},
},
{
name: "with custom resolvers and TTL",
data: ConfigurationData{
Config: &v1alpha1.NginxConfig{
ResolverAddresses: []string{"kube-dns.kube-system.svc.cluster.local.", "169.196.255.254:3553"},
ResolverTTL: "30m",
},
Instance: &v1alpha1.RpaasInstance{},
},
assertion: func(t *testing.T, result string) {
assert.Regexp(t, `\s+resolver kube-dns\.kube-system\.svc\.cluster\.local\. 169\.196\.255\.254:3553 ttl=30m;\n`, result)
},
},
}

for _, tt := range tests {
Expand Down

0 comments on commit e4eab84

Please sign in to comment.