Skip to content

Commit

Permalink
Add separate cluster for configured kiali instance
Browse files Browse the repository at this point in the history
  • Loading branch information
nrfox committed Dec 20, 2023
1 parent c777d85 commit 6744ef7
Show file tree
Hide file tree
Showing 21 changed files with 464 additions and 198 deletions.
47 changes: 36 additions & 11 deletions business/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,55 @@ func SetWithBackends(cf kubernetes.ClientFactory, prom prometheus.ClientInterfac
// NewWithBackends creates the business layer using the passed k8sClients and prom clients.
// Note that the client passed here should *not* be the Kiali ServiceAccount client.
// It should be the user client based on the logged in user's token.
func NewWithBackends(userClients map[string]kubernetes.ClientInterface, kialiSAClients map[string]kubernetes.ClientInterface, prom prometheus.ClientInterface, traceClient tracing.ClientInterface) *Layer {
func NewWithBackends(userClients map[string]kubernetes.ClientInterface, kialiSAClients map[string]kubernetes.ClientInterface, prom prometheus.ClientInterface, tracingClient tracing.ClientInterface) *Layer {
return newLayer(userClients, kialiSAClients, prom, tracingClient, kialiCache, poller, config.Get())
}

func newLayer(
userClients map[string]kubernetes.ClientInterface,
kialiSAClients map[string]kubernetes.ClientInterface,
prom prometheus.ClientInterface,
traceClient tracing.ClientInterface,
cache cache.KialiCache,
cpm ControlPlaneMonitor,
conf *config.Config,
) *Layer {
temporaryLayer := &Layer{}
conf := config.Get()

homeClusterName := conf.KubernetesConfig.ClusterName

// TODO: Modify the k8s argument to other services to pass the whole k8s map if needed
temporaryLayer.App = AppService{prom: prom, userClients: userClients, businessLayer: temporaryLayer}
temporaryLayer.Health = HealthService{prom: prom, businessLayer: temporaryLayer, userClients: userClients}
temporaryLayer.IstioConfig = IstioConfigService{config: *conf, userClients: userClients, kialiCache: kialiCache, businessLayer: temporaryLayer, controlPlaneMonitor: poller}
temporaryLayer.IstioConfig = IstioConfigService{config: *conf, userClients: userClients, kialiCache: cache, businessLayer: temporaryLayer, controlPlaneMonitor: poller}
temporaryLayer.IstioStatus = NewIstioStatusService(userClients, temporaryLayer, poller)
temporaryLayer.IstioCerts = IstioCertsService{k8s: userClients[homeClusterName], businessLayer: temporaryLayer}
temporaryLayer.Namespace = NewNamespaceService(userClients, kialiSAClients, kialiCache, *conf)
temporaryLayer.Mesh = NewMeshService(kialiSAClients, kialiCache, temporaryLayer.Namespace, *conf)
temporaryLayer.Namespace = NewNamespaceService(userClients, kialiSAClients, cache, *conf)
temporaryLayer.Mesh = NewMeshService(kialiSAClients, cache, temporaryLayer.Namespace, *conf)
temporaryLayer.OpenshiftOAuth = OpenshiftOAuthService{k8s: userClients[homeClusterName], kialiSAClient: kialiSAClients[homeClusterName]}
temporaryLayer.ProxyStatus = ProxyStatusService{kialiSAClients: kialiSAClients, kialiCache: kialiCache, businessLayer: temporaryLayer}
temporaryLayer.ProxyStatus = ProxyStatusService{kialiSAClients: kialiSAClients, kialiCache: cache, businessLayer: temporaryLayer}
// Out of order because it relies on ProxyStatus
temporaryLayer.ProxyLogging = ProxyLoggingService{userClients: userClients, proxyStatus: &temporaryLayer.ProxyStatus}
temporaryLayer.RegistryStatus = RegistryStatusService{kialiCache: kialiCache}
temporaryLayer.TLS = TLSService{userClients: userClients, kialiCache: kialiCache, businessLayer: temporaryLayer}
temporaryLayer.Svc = SvcService{config: *conf, kialiCache: kialiCache, businessLayer: temporaryLayer, prom: prom, userClients: userClients}
temporaryLayer.RegistryStatus = RegistryStatusService{kialiCache: cache}
temporaryLayer.TLS = TLSService{userClients: userClients, kialiCache: cache, businessLayer: temporaryLayer}
temporaryLayer.Svc = SvcService{config: *conf, kialiCache: cache, businessLayer: temporaryLayer, prom: prom, userClients: userClients}
temporaryLayer.TokenReview = NewTokenReview(userClients[homeClusterName])
temporaryLayer.Validations = IstioValidationsService{userClients: userClients, businessLayer: temporaryLayer}
temporaryLayer.Workload = *NewWorkloadService(userClients, prom, kialiCache, temporaryLayer, conf)
temporaryLayer.Tracing = NewTracingService(conf, traceClient, &temporaryLayer.Svc, &temporaryLayer.Workload)
temporaryLayer.Workload = *NewWorkloadService(userClients, prom, cache, temporaryLayer, conf)

temporaryLayer.Tracing = NewTracingService(conf, traceClient, &temporaryLayer.Svc, &temporaryLayer.Workload)
return temporaryLayer
}

// NewLayer creates the business layer using the passed k8sClients and prom clients.
// Note that the client passed here should *not* be the Kiali ServiceAccount client.
// It should be the user client based on the logged in user's token.
func NewLayer(conf config.Config, cache cache.KialiCache, cf kubernetes.ClientFactory, prom prometheus.ClientInterface, tracingClient tracing.ClientInterface, cpm ControlPlaneMonitor, authInfo *api.AuthInfo) (*Layer, error) {
userClients, err := cf.GetClients(authInfo)
if err != nil {
return nil, err
}

kialiSAClients := cf.GetSAClients()
return newLayer(userClients, kialiSAClients, prom, tracingClient, cache, cpm, &conf), nil
}

0 comments on commit 6744ef7

Please sign in to comment.