Skip to content

Commit

Permalink
Kubernetes Service Discovery Custom Settings (#313)
Browse files Browse the repository at this point in the history
* - Added configNamespace in Kubernetes settings object, so that users can create different settings based on config path
- Added "Settings" object to KubernetesApiServiceDiscovery constructor so that users are able to provide their different settings for discovery

* - Added defaultConfig as fallback to user provided config
  • Loading branch information
shakeeb-upstart authored Oct 2, 2024
1 parent 5b235ec commit cca5ce0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,14 @@ object KubernetesApiServiceDiscovery {
* An alternative implementation that uses the Kubernetes API. The main advantage of this method is that it allows
* you to define readiness/health checks that don't affect the bootstrap mechanism.
*/
class KubernetesApiServiceDiscovery(implicit system: ActorSystem) extends ServiceDiscovery {
class KubernetesApiServiceDiscovery(settings: Settings)(
implicit system: ActorSystem) extends ServiceDiscovery {

import system.dispatcher

private val http = Http()

private val settings = Settings(system)
def this()(implicit system: ActorSystem) = this(Settings(system))

private val log = Logging(system, getClass)(LogSource.fromClass)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import com.typesafe.config.Config

import org.apache.pekko.util.OptionConverters._

final class Settings(system: ExtendedActorSystem) extends Extension {
final class Settings(kubernetesApi: Config) extends Extension {

def this(system: ExtendedActorSystem) = this(system.settings.config.getConfig("pekko.discovery.kubernetes-api"))

/**
* Copied from PekkoManagementSettings, which we don't depend on.
Expand All @@ -35,8 +37,6 @@ final class Settings(system: ExtendedActorSystem) extends Extension {
if (hasDefined(key)) Some(config.getString(key)) else None
}

private val kubernetesApi = system.settings.config.getConfig("pekko.discovery.kubernetes-api")

val apiCaPath: String =
kubernetesApi.getString("api-ca-path")

Expand Down

0 comments on commit cca5ce0

Please sign in to comment.