Separate third party NGINX configuration (#10470)
* Document container separation * Separate configurations
This commit is contained in:
parent
d6a0f46c32
commit
9ed0d7f7af
19 changed files with 158 additions and 36 deletions
|
|
@ -987,7 +987,7 @@ func NewDefault() Configuration {
|
|||
BindAddressIpv6: defBindAddress,
|
||||
OpentracingTrustIncomingSpan: true,
|
||||
OpentelemetryTrustIncomingSpan: true,
|
||||
OpentelemetryConfig: "/etc/nginx/opentelemetry.toml",
|
||||
OpentelemetryConfig: "/etc/ingress-controller/telemetry/opentelemetry.toml",
|
||||
OtlpCollectorPort: "4317",
|
||||
OtelServiceName: "nginx",
|
||||
OtelSampler: "AlwaysOn",
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
|
|
@ -180,7 +181,11 @@ func NewNGINXController(config *Configuration, mc metric.Collector) *NGINXContro
|
|||
}
|
||||
|
||||
filesToWatch := []string{}
|
||||
err = filepath.Walk("/etc/nginx/geoip/", func(path string, info os.FileInfo, err error) error {
|
||||
|
||||
if err := os.Mkdir("/etc/ingress-controller/geoip/", 0o755); err != nil && !os.IsExist(err) {
|
||||
klog.Fatalf("Error creating geoip dir: %v", err)
|
||||
}
|
||||
err = filepath.WalkDir("/etc/ingress-controller/geoip/", func(path string, info fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -1107,7 +1112,7 @@ func createOpentracingCfg(cfg *ngx_config.Configuration) error {
|
|||
// Expand possible environment variables before writing the configuration to file.
|
||||
expanded := os.ExpandEnv(configData)
|
||||
|
||||
return os.WriteFile("/etc/nginx/opentracing.json", []byte(expanded), file.ReadWriteByUser)
|
||||
return os.WriteFile("/etc/ingress-controller/telemetry/opentracing.json", []byte(expanded), file.ReadWriteByUser)
|
||||
}
|
||||
|
||||
func createOpentelemetryCfg(cfg *ngx_config.Configuration) error {
|
||||
|
|
|
|||
|
|
@ -1215,7 +1215,7 @@ func (s *k8sStore) setConfig(cmap *corev1.ConfigMap) {
|
|||
s.backendConfig.UseGeoIP2 = false
|
||||
}
|
||||
|
||||
s.writeSSLSessionTicketKey(cmap, "/etc/nginx/tickets.key")
|
||||
s.writeSSLSessionTicketKey(cmap, "/etc/ingress-controller/tickets.key")
|
||||
}
|
||||
|
||||
// Run initiates the synchronization of the informers and the initial
|
||||
|
|
|
|||
|
|
@ -1230,11 +1230,11 @@ func buildOpentracing(c, s interface{}) string {
|
|||
|
||||
//nolint:gocritic // rewriting if-else to switch statement is not more readable
|
||||
if cfg.DatadogCollectorHost != "" {
|
||||
buf.WriteString("opentracing_load_tracer /usr/local/lib/libdd_opentracing.so /etc/nginx/opentracing.json;")
|
||||
buf.WriteString("opentracing_load_tracer /usr/local/lib/libdd_opentracing.so /etc/ingress-controller/telemetry/opentracing.json;")
|
||||
} else if cfg.ZipkinCollectorHost != "" {
|
||||
buf.WriteString("opentracing_load_tracer /usr/local/lib/libzipkin_opentracing_plugin.so /etc/nginx/opentracing.json;")
|
||||
buf.WriteString("opentracing_load_tracer /usr/local/lib/libzipkin_opentracing_plugin.so /etc/ingress-controller/telemetry/opentracing.json;")
|
||||
} else if cfg.JaegerCollectorHost != "" || cfg.JaegerEndpoint != "" {
|
||||
buf.WriteString("opentracing_load_tracer /usr/local/lib/libjaegertracing_plugin.so /etc/nginx/opentracing.json;")
|
||||
buf.WriteString("opentracing_load_tracer /usr/local/lib/libjaegertracing_plugin.so /etc/ingress-controller/telemetry/opentracing.json;")
|
||||
}
|
||||
|
||||
buf.WriteString("\r\n")
|
||||
|
|
|
|||
|
|
@ -1663,7 +1663,7 @@ func TestBuildOpenTracing(t *testing.T) {
|
|||
EnableOpentracing: true,
|
||||
JaegerCollectorHost: "jaeger-host.com",
|
||||
}
|
||||
expected = "opentracing_load_tracer /usr/local/lib/libjaegertracing_plugin.so /etc/nginx/opentracing.json;\r\n"
|
||||
expected = "opentracing_load_tracer /usr/local/lib/libjaegertracing_plugin.so /etc/ingress-controller/telemetry/opentracing.json;\r\n"
|
||||
actual = buildOpentracing(cfgJaeger, []*ingress.Server{})
|
||||
|
||||
if expected != actual {
|
||||
|
|
@ -1674,7 +1674,7 @@ func TestBuildOpenTracing(t *testing.T) {
|
|||
EnableOpentracing: true,
|
||||
ZipkinCollectorHost: "zipkin-host.com",
|
||||
}
|
||||
expected = "opentracing_load_tracer /usr/local/lib/libzipkin_opentracing_plugin.so /etc/nginx/opentracing.json;\r\n"
|
||||
expected = "opentracing_load_tracer /usr/local/lib/libzipkin_opentracing_plugin.so /etc/ingress-controller/telemetry/opentracing.json;\r\n"
|
||||
actual = buildOpentracing(cfgZipkin, []*ingress.Server{})
|
||||
|
||||
if expected != actual {
|
||||
|
|
@ -1685,7 +1685,7 @@ func TestBuildOpenTracing(t *testing.T) {
|
|||
EnableOpentracing: true,
|
||||
DatadogCollectorHost: "datadog-host.com",
|
||||
}
|
||||
expected = "opentracing_load_tracer /usr/local/lib/libdd_opentracing.so /etc/nginx/opentracing.json;\r\n"
|
||||
expected = "opentracing_load_tracer /usr/local/lib/libdd_opentracing.so /etc/ingress-controller/telemetry/opentracing.json;\r\n"
|
||||
actual = buildOpentracing(cfgDatadog, []*ingress.Server{})
|
||||
|
||||
if expected != actual {
|
||||
|
|
@ -1696,7 +1696,7 @@ func TestBuildOpenTracing(t *testing.T) {
|
|||
EnableOpentracing: true,
|
||||
JaegerEndpoint: "http://jaeger-collector.com:14268/api/traces",
|
||||
}
|
||||
expected = "opentracing_load_tracer /usr/local/lib/libjaegertracing_plugin.so /etc/nginx/opentracing.json;\r\n"
|
||||
expected = "opentracing_load_tracer /usr/local/lib/libjaegertracing_plugin.so /etc/ingress-controller/telemetry/opentracing.json;\r\n"
|
||||
actual = buildOpentracing(cfgJaegerEndpoint, []*ingress.Server{})
|
||||
|
||||
if expected != actual {
|
||||
|
|
@ -1709,7 +1709,7 @@ func TestBuildOpenTracing(t *testing.T) {
|
|||
OpentracingOperationName: "my-operation-name",
|
||||
OpentracingLocationOperationName: "my-location-operation-name",
|
||||
}
|
||||
expected = "opentracing_load_tracer /usr/local/lib/libdd_opentracing.so /etc/nginx/opentracing.json;\r\n"
|
||||
expected = "opentracing_load_tracer /usr/local/lib/libdd_opentracing.so /etc/ingress-controller/telemetry/opentracing.json;\r\n"
|
||||
expected += "opentracing_operation_name \"my-operation-name\";\n"
|
||||
expected += "opentracing_location_operation_name \"my-location-operation-name\";\n"
|
||||
actual = buildOpentracing(cfgOpenTracing, []*ingress.Server{})
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ var MaxmindRetriesTimeout = time.Second * 0
|
|||
const minimumRetriesCount = 1
|
||||
|
||||
const (
|
||||
geoIPPath = "/etc/nginx/geoip"
|
||||
geoIPPath = "/etc/ingress-controller/geoip"
|
||||
dbExtension = ".mmdb"
|
||||
|
||||
maxmindURL = "https://download.maxmind.com/app/geoip_download?license_key=%v&edition_id=%v&suffix=tar.gz"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue