@@ -22,20 +22,24 @@ package eu.openanalytics.shinyproxyoperator
2222
2323import com.fasterxml.jackson.module.kotlin.registerKotlinModule
2424import eu.openanalytics.shinyproxyoperator.controller.IReconcileListener
25+ import eu.openanalytics.shinyproxyoperator.controller.IRecyclableChecker
2526import eu.openanalytics.shinyproxyoperator.controller.PodRetriever
27+ import eu.openanalytics.shinyproxyoperator.controller.RecyclableChecker
2628import eu.openanalytics.shinyproxyoperator.controller.ResourceListener
2729import eu.openanalytics.shinyproxyoperator.controller.ResourceRetriever
2830import eu.openanalytics.shinyproxyoperator.controller.ShinyProxyController
2931import eu.openanalytics.shinyproxyoperator.controller.ShinyProxyEvent
3032import eu.openanalytics.shinyproxyoperator.controller.ShinyProxyListener
3133import eu.openanalytics.shinyproxyoperator.crd.ShinyProxy
32- import eu.openanalytics.shinyproxyoperator.ingress.skipper .IngressController
34+ import eu.openanalytics.shinyproxyoperator.controller .IngressController
3335import io.fabric8.kubernetes.api.model.ConfigMap
3436import io.fabric8.kubernetes.api.model.ConfigMapList
3537import io.fabric8.kubernetes.api.model.Service
3638import io.fabric8.kubernetes.api.model.ServiceList
3739import io.fabric8.kubernetes.api.model.apps.ReplicaSet
3840import io.fabric8.kubernetes.api.model.apps.ReplicaSetList
41+ import io.fabric8.kubernetes.api.model.networking.v1.Ingress
42+ import io.fabric8.kubernetes.api.model.networking.v1.IngressList
3943import io.fabric8.kubernetes.client.DefaultKubernetesClient
4044import io.fabric8.kubernetes.client.KubernetesClientException
4145import io.fabric8.kubernetes.client.NamespacedKubernetesClient
@@ -62,7 +66,8 @@ class Operator(client: NamespacedKubernetesClient? = null,
6266 probeFailureThreshold : Int? = null ,
6367 probeTimeout : Int? = null ,
6468 startupProbeInitialDelay : Int? = null ,
65- logLevel : Level ? = null ) {
69+ logLevel : Level ? = null ,
70+ recyclableChecker : IRecyclableChecker ? = null ) {
6671
6772 private val logger = KotlinLogging .logger {}
6873 private val client: NamespacedKubernetesClient
@@ -77,11 +82,13 @@ class Operator(client: NamespacedKubernetesClient? = null,
7782
7883 val podRetriever: PodRetriever
7984 private val shinyProxyClient: ShinyProxyClient
85+ private val recyclableChecker: IRecyclableChecker
8086
8187 private val shinyProxyListener: ShinyProxyListener
8288 private val replicaSetListener: ResourceListener <ReplicaSet , ReplicaSetList , RollableScalableResource <ReplicaSet >>
8389 private val serviceListener: ResourceListener <Service , ServiceList , ServiceResource <Service >>
8490 private val configMapListener: ResourceListener <ConfigMap , ConfigMapList , Resource <ConfigMap >>
91+ private val ingressListener: ResourceListener <Ingress , IngressList , Resource <Ingress >>
8592 private val ingressController: IngressController
8693
8794 private val channel = Channel <ShinyProxyEvent >(10000 )
@@ -145,24 +152,27 @@ class Operator(client: NamespacedKubernetesClient? = null,
145152
146153 shinyProxyListener = ShinyProxyListener (sendChannel, this .shinyProxyClient)
147154 podRetriever = PodRetriever (this .client)
155+ this .recyclableChecker = recyclableChecker ? : RecyclableChecker (podRetriever)
148156
149157 if (this .mode == Mode .CLUSTERED ) {
150158 replicaSetListener = ResourceListener (sendChannel, this .client.inAnyNamespace().apps().replicaSets())
151159 serviceListener = ResourceListener (sendChannel, this .client.inAnyNamespace().services())
152160 configMapListener = ResourceListener (sendChannel, this .client.inAnyNamespace().configMaps())
153- ingressController = IngressController (sendChannel, this .client.inAnyNamespace(), this .client.inAnyNamespace().network().v1().ingresses())
161+ ingressListener = ResourceListener (sendChannel, this .client.inAnyNamespace().network().v1().ingresses())
162+ ingressController = IngressController (this .client.inAnyNamespace().network().v1().ingresses())
154163 } else {
155164 replicaSetListener = ResourceListener (sendChannel, this .client.inNamespace(namespace).apps().replicaSets())
156165 serviceListener = ResourceListener (sendChannel, this .client.inNamespace(namespace).services())
157166 configMapListener = ResourceListener (sendChannel, this .client.inNamespace(namespace).configMaps())
158- ingressController = IngressController (sendChannel, this .client.inNamespace(namespace), this .client.inNamespace(namespace).network().v1().ingresses())
167+ ingressListener = ResourceListener (sendChannel, this .client.inNamespace(namespace).network().v1().ingresses())
168+ ingressController = IngressController (this .client.inNamespace(namespace).network().v1().ingresses())
159169 }
160170 }
161171
162172 /* *
163173 * Controllers
164174 */
165- val shinyProxyController = ShinyProxyController (channel, this .client, shinyProxyClient, ingressController, podRetriever, reconcileListener )
175+ val shinyProxyController = ShinyProxyController (channel, this .client, shinyProxyClient, ingressController, reconcileListener, this .recyclableChecker )
166176
167177 private fun _checkCrdExists (name : String , shortName : String ) {
168178 try {
@@ -194,14 +204,13 @@ class Operator(client: NamespacedKubernetesClient? = null,
194204 logger.info { " Starting background processes of ShinyProxy Operator" }
195205
196206 _checkCrdExists (" shinyproxies.openanalytics.eu" , " ShinyProxy" )
197- _checkCrdExists (" routegroups.zalando.org" , " RouteGroup" )
198207
199208 try {
200209 val shinyProxyLister = Lister (shinyProxyListener.start())
201210 val replicaSetLister = Lister (replicaSetListener.start(shinyProxyLister))
202211 val serviceLister = Lister (serviceListener.start(shinyProxyLister))
203212 val configMapLister = Lister (configMapListener.start(shinyProxyLister))
204- val ingressLister = Lister (ingressController .start(shinyProxyLister))
213+ val ingressLister = Lister (ingressListener .start(shinyProxyLister))
205214 val resourceRetriever = ResourceRetriever (replicaSetLister, configMapLister, serviceLister, ingressLister)
206215 return resourceRetriever to shinyProxyLister
207216 } catch (e: KubernetesClientException ) {
@@ -228,7 +237,7 @@ class Operator(client: NamespacedKubernetesClient? = null,
228237 replicaSetListener.stop()
229238 serviceListener.stop()
230239 configMapListener.stop()
231- ingressController .stop()
240+ ingressListener .stop()
232241 }
233242
234243 companion object {
0 commit comments