The Kubernetes client code was wrapping all IP addresses (both IPv4 and
IPv6) in square brackets when constructing the API server URL. This was
based on an incorrect assumption that IPv4 addresses in brackets are valid
in a URL.
Recent versions of Go (1.25.2 and later) have stricter URL parsing
that conforms to RFC 3986. This causes a failure when running Dex in a
Kubernetes environment where the KUBERNETES_SERVICE_HOST is an IPv4
address, leading to the error "invalid IPv6 host".
This commit changes the logic to only wrap IPv6 addresses in square
brackets. It uses `ip.To4() == nil` to reliably detect if an IP address
is IPv6 before wrapping it. This ensures that URLs are correctly
formatted for both IPv4 and IPv6 addresses, fixing the incompatibility
with newer Go versions.
Signed-off-by: Rene Dekker <rene@tigera.io>
If something causes the number k8s resources to increase beyond a
certain threshold, garbage collection can fail because the query to
retrieve those resources will time out, resulting in a perpetual cycle
of being unable to garbage collect resources.
In lieu of trying to get *every* object each cycle, we can limit the
number of resources retrieved per GC cycle to some reasonable number.
Signed-off-by: Michael Kelly <mkelly@arista.com>
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
When constructing the host address string, the address is
not wrapped in square brackets. This does not work in IPv6
Kubernetes deployments. This commit adds square brackets
around the address. IPv4 was also tested to ensure it works
with wrapped address.
Signed-off-by: Jerry Sun <jerry.sun@windriver.com>
Third Party Resources (TPR) have been removed from Kubernetes for
roughly 2 years. This commit removes the support dex had for them.
Documentation has been updated to reflect this and to instruct users
on how to migrate from TPR-powered dex environment to a Custom Resource
Defintion (CRD) based one that dex > v2.17 will support