Enable download of GeoLite2 databases (#4896)

This commit is contained in:
Manuel Alejandro de Brito Fontes 2020-01-08 19:46:43 -03:00 committed by GitHub
parent 58146c803b
commit 74944b99e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 167 additions and 0 deletions

View file

@ -181,6 +181,9 @@ Takes the form "<host>:port". If not provided, no admission controller is starte
flags.MarkDeprecated("enable-dynamic-certificates", `Only dynamic mode is supported`)
flags.StringVar(&nginx.MaxmindLicenseKey, "maxmind-license-key", "", `Maxmind license key to download GeoLite2 Databases.
https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-geolite2-databases`)
flag.Set("logtostderr", "true")
flags.AddGoFlagSet(flag.CommandLine)
@ -297,5 +300,13 @@ Takes the form "<host>:port". If not provided, no admission controller is starte
config.RootCAFile = *rootCAFile
}
if nginx.MaxmindLicenseKey != "" {
klog.Info("downloading maxmind GeoIP2 databases...")
err := nginx.DownloadGeoLite2DB()
if err != nil {
klog.Errorf("unexpected error downloading GeoIP2 database: %v", err)
}
}
return false, config, nil
}