Skip to content

Commit bd2f1f3

Browse files
kdautreyleonardoce
authored andcommitted
fix(plugin): update plugin address to use FQDN (#10921)
Use FQDN instead of short name to connect to plugins. This is a best practice and avoids issues when a proxy is set at cluster level and automatically injected in pods. Closes #7947 Signed-off-by: kevin.dautrey <[email protected]> (cherry picked from commit 83287c2) (cherry picked from commit 89e3cb5)
1 parent f79df7e commit bd2f1f3

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎internal/controller/plugin_controller.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ func (r *PluginReconciler) reconcile(
212212
return ctrl.Result{}, err
213213
}
214214

215-
pluginAddress := fmt.Sprintf("%s:%d", service.Name, pluginPort)
215+
// Use the in-cluster service FQDN to match common NO_PROXY patterns
216+
// in managed environments where proxy env vars are injected.
217+
pluginAddress := fmt.Sprintf("%s.%s.svc:%d", service.Name, service.Namespace, pluginPort)
216218

217219
// Use custom server name if provided, otherwise default to service name
218220
serverName := service.Annotations[utils.PluginServerNameAnnotationName]

‎internal/controller/plugin_controller_test.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ var _ = Describe("PluginReconciler", func() {
113113
serverSecretName = "plugin-server-secret"
114114
clientSecretName = "plugin-client-secret"
115115
pluginPort = "9090"
116+
serviceFQDN = serviceName + "." + testNamespace + ".svc"
116117
)
117118

118119
var (
@@ -210,7 +211,7 @@ var _ = Describe("PluginReconciler", func() {
210211
Expect(pluginRepository.registeredPlugins).To(HaveKey(pluginName))
211212
registration := pluginRepository.registeredPlugins[pluginName]
212213
Expect(registration.tlsConfig.ServerName).To(Equal(serviceName))
213-
Expect(registration.address).To(Equal(serviceName + ":" + pluginPort))
214+
Expect(registration.address).To(Equal(serviceFQDN + ":" + pluginPort))
214215
})
215216

216217
It("should use custom ServerName when annotation is provided", func() {
@@ -241,7 +242,7 @@ var _ = Describe("PluginReconciler", func() {
241242
Expect(pluginRepository.registeredPlugins).To(HaveKey(pluginName))
242243
registration := pluginRepository.registeredPlugins[pluginName]
243244
Expect(registration.tlsConfig.ServerName).To(Equal(customServerName))
244-
Expect(registration.address).To(Equal(serviceName + ":" + pluginPort))
245+
Expect(registration.address).To(Equal(serviceFQDN + ":" + pluginPort))
245246
})
246247

247248
It("should skip reconciliation when server secret annotation is missing", func() {

0 commit comments

Comments
 (0)