Skip to content

Commit 83287c2

Browse files
authored
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]>
1 parent 9eed883 commit 83287c2

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎internal/controller/plugin_controller.go‎

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

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

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

‎internal/controller/plugin_controller_test.go‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ var _ = Describe("PluginReconciler", func() {
117117
serverSecretName = "plugin-server-secret"
118118
clientSecretName = "plugin-client-secret"
119119
pluginPort = "9090"
120+
serviceFQDN = serviceName + "." + testNamespace + ".svc"
120121
)
121122

122123
var (
@@ -215,7 +216,7 @@ var _ = Describe("PluginReconciler", func() {
215216
Expect(pluginRepository.registeredPlugins).To(HaveKey(pluginName))
216217
registration := pluginRepository.registeredPlugins[pluginName]
217218
Expect(registration.tlsConfig.ServerName).To(Equal(serviceName))
218-
Expect(registration.address).To(Equal(serviceName + ":" + pluginPort))
219+
Expect(registration.address).To(Equal(serviceFQDN + ":" + pluginPort))
219220
})
220221

221222
It("should use custom ServerName when annotation is provided", func() {
@@ -246,7 +247,7 @@ var _ = Describe("PluginReconciler", func() {
246247
Expect(pluginRepository.registeredPlugins).To(HaveKey(pluginName))
247248
registration := pluginRepository.registeredPlugins[pluginName]
248249
Expect(registration.tlsConfig.ServerName).To(Equal(customServerName))
249-
Expect(registration.address).To(Equal(serviceName + ":" + pluginPort))
250+
Expect(registration.address).To(Equal(serviceFQDN + ":" + pluginPort))
250251
})
251252

252253
It("should skip reconciliation when server secret annotation is missing", func() {
@@ -441,7 +442,7 @@ var _ = Describe("PluginReconciler", func() {
441442

442443
// Manually register the plugin
443444
pluginRepository.registeredPlugins[pluginName] = &pluginRegistration{
444-
address: serviceName + ":" + pluginPort,
445+
address: serviceFQDN + ":" + pluginPort,
445446
}
446447

447448
// Delete the service (without finalizer, it's immediately deleted)

0 commit comments

Comments
 (0)