@@ -20,49 +20,48 @@ import mu.KotlinLogging
2020suspend fun main () {
2121 val logger = KotlinLogging .logger {}
2222 try {
23- DefaultKubernetesClient ().use { client ->
24- var namespace = client.namespace
25- if (namespace == null ) {
26- logger.info { " No namespace found via config, assuming default." }
27- namespace = " default"
28- }
29- logger.info { " Using namespace : $namespace " }
30- var podSetCustomResourceDefinition = client.customResourceDefinitions().withName(" shinyproxies.openanalytics.eu" ).get()
31- if (podSetCustomResourceDefinition == null ) {
32- podSetCustomResourceDefinition = client.customResourceDefinitions().load(object : Any () {}.javaClass.getResourceAsStream(" /crd.yaml" )).get()
33- client.customResourceDefinitions().create(podSetCustomResourceDefinition)
34- logger.info { " Created CustomResourceDefinition" }
35- }
36-
37- val podSetCustomResourceDefinitionContext = CustomResourceDefinitionContext .Builder ()
38- .withVersion(" v1alpha1" )
39- .withScope(" Namespaced" )
40- .withGroup(" openanalytics.eu" )
41- .withPlural(" shinyproxies" )
42- .build()
23+ val client = DefaultKubernetesClient ()
24+ var namespace = client.namespace
25+ if (namespace == null ) {
26+ logger.info { " No namespace found via config, assuming default." }
27+ namespace = " default"
28+ }
29+ logger.info { " Using namespace : $namespace " }
30+ var podSetCustomResourceDefinition = client.customResourceDefinitions().withName(" shinyproxies.openanalytics.eu" ).get()
31+ if (podSetCustomResourceDefinition == null ) {
32+ podSetCustomResourceDefinition = client.customResourceDefinitions().load(object : Any () {}.javaClass.getResourceAsStream(" /crd.yaml" )).get()
33+ client.customResourceDefinitions().create(podSetCustomResourceDefinition)
34+ logger.info { " Created CustomResourceDefinition" }
35+ }
4336
44- val informerFactory = client.informers ()
45- val podSetClient : MixedOperation < ShinyProxy , ShinyProxyList , DoneableShinyProxy , Resource < ShinyProxy , DoneableShinyProxy >> = client.customResources(podSetCustomResourceDefinitionContext, ShinyProxy :: class .java, ShinyProxyList :: class .java, DoneableShinyProxy :: class .java )
46- val replicaSetIndexInformer = informerFactory.sharedIndexInformerFor( ReplicaSet :: class .java, ReplicaSetList :: class .java, 10 * 60 * 1000 .toLong() )
47- val serviceIndexInformer = informerFactory.sharedIndexInformerFor( Service :: class .java, ServiceList :: class .java, 10 * 60 * 1000 .toLong() )
48- val configMapIndexInformer = informerFactory.sharedIndexInformerFor( ConfigMap :: class .java, ConfigMapList :: class .java, 10 * 60 * 1000 .toLong() )
49- val shinyProxyIndexInformer = informerFactory.sharedIndexInformerForCustomResource(podSetCustomResourceDefinitionContext, ShinyProxy :: class .java, ShinyProxyList :: class .java, 10 * 60 * 1000 )
37+ val podSetCustomResourceDefinitionContext = CustomResourceDefinitionContext . Builder ()
38+ .withVersion( " v1alpha1 " )
39+ .withScope( " Namespaced " )
40+ .withGroup( " openanalytics.eu " )
41+ .withPlural( " shinyproxies " )
42+ .build( )
5043
51- val shinyProxyController = ShinyProxyController ( client,
52- replicaSetIndexInformer,
53- serviceIndexInformer,
54- configMapIndexInformer,
55- shinyProxyIndexInformer,
56- namespace )
44+ val informerFactory = client.informers()
45+ val podSetClient : MixedOperation < ShinyProxy , ShinyProxyList , DoneableShinyProxy , Resource < ShinyProxy , DoneableShinyProxy >> = client.customResources(podSetCustomResourceDefinitionContext, ShinyProxy :: class .java, ShinyProxyList :: class .java, DoneableShinyProxy :: class .java)
46+ val replicaSetIndexInformer = informerFactory.sharedIndexInformerFor( ReplicaSet :: class .java, ReplicaSetList :: class .java, 10 * 60 * 1000 .toLong())
47+ val serviceIndexInformer = informerFactory.sharedIndexInformerFor( Service :: class .java, ServiceList :: class .java, 10 * 60 * 1000 .toLong())
48+ val configMapIndexInformer = informerFactory.sharedIndexInformerFor( ConfigMap :: class .java, ConfigMapList :: class .java, 10 * 60 * 1000 .toLong())
49+ val shinyProxyIndexInformer = informerFactory.sharedIndexInformerForCustomResource(podSetCustomResourceDefinitionContext, ShinyProxy :: class .java, ShinyProxyList :: class .java, 10 * 60 * 1000 )
5750
58- informerFactory.startAllRegisteredInformers()
51+ val shinyProxyController = ShinyProxyController (client,
52+ replicaSetIndexInformer,
53+ serviceIndexInformer,
54+ configMapIndexInformer,
55+ shinyProxyIndexInformer,
56+ namespace)
5957
60- informerFactory.addSharedInformerEventListener {
61- logger.warn { " Exception occurred, but caught $it " }
62- }
58+ informerFactory.startAllRegisteredInformers()
6359
64- shinyProxyController.run ()
60+ informerFactory.addSharedInformerEventListener {
61+ logger.warn { " Exception occurred, but caught $it " }
6562 }
63+
64+ shinyProxyController.run ()
6665 } catch (exception: KubernetesClientException ) {
6766 logger.warn { " Kubernetes Client Exception : ${exception.message} " }
6867 exception.printStackTrace()
0 commit comments