|
|
@@ -126,6 +126,7 @@ func configFromEnv() (*settings, error) {
|
|
|
IngressProxiesCfgPath: defaultEnv("TS_INGRESS_PROXIES_CONFIG_PATH", ""),
|
|
|
PodUID: defaultEnv("POD_UID", ""),
|
|
|
}
|
|
|
+
|
|
|
podIPs, ok := os.LookupEnv("POD_IPS")
|
|
|
if ok {
|
|
|
ips := strings.Split(podIPs, ",")
|
|
|
@@ -144,6 +145,7 @@ func configFromEnv() (*settings, error) {
|
|
|
cfg.PodIPv6 = parsed.String()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
// If cert share is enabled, set the replica as read or write. Only 0th
|
|
|
// replica should be able to write.
|
|
|
isInCertShareMode := defaultBool("TS_EXPERIMENTAL_CERT_SHARE", false)
|
|
|
@@ -165,9 +167,19 @@ func configFromEnv() (*settings, error) {
|
|
|
cfg.AcceptDNS = &acceptDNSNew
|
|
|
}
|
|
|
|
|
|
+ // In Kubernetes clusters, people like to use the "$(POD_IP):PORT" combination to configure the TS_LOCAL_ADDR_PORT
|
|
|
+ // environment variable (we even do this by default in the operator when enabling metrics), leading to a v6 address
|
|
|
+ // and port combo we cannot parse, as netip.ParseAddrPort expects the host segment to be enclosed in square brackets.
|
|
|
+ // We perform a check here to see if TS_LOCAL_ADDR_PORT is using the pod's IPv6 address and is not using brackets,
|
|
|
+ // adding the brackets in if need be.
|
|
|
+ if cfg.PodIPv6 != "" && strings.Contains(cfg.LocalAddrPort, cfg.PodIPv6) && !strings.ContainsAny(cfg.LocalAddrPort, "[]") {
|
|
|
+ cfg.LocalAddrPort = strings.Replace(cfg.LocalAddrPort, cfg.PodIPv6, "["+cfg.PodIPv6+"]", 1)
|
|
|
+ }
|
|
|
+
|
|
|
if err := cfg.validate(); err != nil {
|
|
|
return nil, fmt.Errorf("invalid configuration: %v", err)
|
|
|
}
|
|
|
+
|
|
|
return cfg, nil
|
|
|
}
|
|
|
|