Skip to content

Commit

Permalink
Add separate cluster for configured kiali instance (#6927)
Browse files Browse the repository at this point in the history
  • Loading branch information
nrfox committed Jan 4, 2024
1 parent 0b93460 commit f443264
Show file tree
Hide file tree
Showing 28 changed files with 821 additions and 213 deletions.
45 changes: 35 additions & 10 deletions business/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,29 +82,54 @@ func SetWithBackends(cf kubernetes.ClientFactory, prom prometheus.ClientInterfac
// 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 {
return newLayer(userClients, kialiSAClients, prom, traceClient, 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, traceClient 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, traceClient, cache, cpm, conf), nil
}

0 comments on commit f443264

Please sign in to comment.