Skip to content

Commit a31c1ec

Browse files
committed
Merge pull request 'docs: break up text in motivational section in readme' (#4) from readme-line-breaks into develop
2 parents 0b2c425 + 0a645f4 commit a31c1ec

5 files changed

Lines changed: 33 additions & 33 deletions

File tree

README.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,33 @@ Easily run ShinyProxy on a Kubernetes cluster
77
## Why?
88

99
Deploying and managing ShinyProxy can get complex when many apps are used,
10-
especially when the configuration of ShinyProxy is often updated. When
11-
restarting a running ShinyProxy instance (in order to update its configuration),
10+
especially when the configuration of ShinyProxy is often updated.
11+
12+
When restarting a running ShinyProxy instance (in order to update its configuration),
1213
users will face a disconnect from their running applications. The only solution
1314
to guarantee that users do not lose their connection to running apps, is to keep
1415
the current instance alive when updating ShinyProxy's configuration. However,
1516
manually keeping track of these instances would be too cumbersome and should
1617
therefore be automated.
1718

1819
The ShinyProxy operator for Kubernetes is able to manage multiple ShinyProxy
19-
instances and their configuration. To give an example of the working of the
20-
operator, assume we have some ShinyProxy configuration `config1` which contains
21-
one app called `app1`. When the operator starts working, it checks whether a
22-
ShinyProxy instance exists with that configuration. If not, it starts a
23-
ShinyProxy instance and all other required configuration. Users can now start
24-
using `app1` on this instance. Some time later, the need for a second app
25-
arises. Therefore, the administrator adapts the configuration of ShinyProxy to
26-
include a second app `app2`. However, some users are still using `app1` on the
27-
old instance. These apps may have some state, which should not be lost.
28-
Therefore, the operator starts a second ShinyProxy instance using configuration
29-
`config2`. The operator ensures that users which are currently using the first
30-
instance, stay on that instance. All other users, are forwarded to the new
31-
server and can use the new application. Nevertheless, users using an old
32-
instance can choose to use the new instance, by clicking a button in the user
33-
interface. The operator stops the old instance once it has no apps running.
20+
instances and their configuration.
21+
22+
### example
23+
24+
Assume we have some ShinyProxy configuration `config1` which contains
25+
one app called `app1`. When the operator starts working, it checks whether a ShinyProxy instance exists with that configuration.
26+
If not, it starts a ShinyProxy instance and all other required configuration. Users can now start using `app1` on this instance.
27+
28+
Some time later, the need for a second app arises.
29+
Therefore the administrator adapts the configuration of ShinyProxy to
30+
include a second app `app2`.
31+
32+
However, some users are still using `app1` on the old instance.
33+
These apps may have some state, which should not be lost. Therefore, the operator starts a second ShinyProxy instance using configuration `config2`. The operator ensures that users which are currently using the first instance, stay on that instance.
34+
35+
All other users are forwarded to the new server and can use the new application. Nevertheless, users using an old
36+
instance can choose to use the new instance, by clicking a button in the user interface. The operator stops the old instance once it has no apps running.
3437

3538
## Building from source
3639

src/main/kotlin/eu/openanalytics/shinyproxyoperator/components/LabelFactory.kt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,25 @@ import eu.openanalytics.shinyproxyoperator.crd.ShinyProxyInstance
2525

2626
object LabelFactory {
2727

28-
fun labelsForCurrentShinyProxyInstance(shinyProxy: ShinyProxy): Map<String, String> {
29-
return mapOf(
30-
APP_LABEL to APP_LABEL_VALUE,
31-
NAME_LABEL to shinyProxy.metadata.name,
32-
INSTANCE_LABEL to shinyProxy.hashOfCurrentSpec
33-
)
34-
}
35-
3628
fun labelsForShinyProxyInstance(shinyProxy: ShinyProxy, shinyProxyInstance: ShinyProxyInstance): Map<String, String> {
3729
val hashOfSpec = shinyProxyInstance.hashOfSpec
3830
return mapOf(
3931
APP_LABEL to APP_LABEL_VALUE,
40-
NAME_LABEL to shinyProxy.metadata.name,
32+
REALM_ID_LABEL to shinyProxy.realmId,
4133
INSTANCE_LABEL to hashOfSpec
4234
)
4335
}
4436

4537
fun labelsForShinyProxy(shinyProxy: ShinyProxy): Map<String, String> {
4638
return mapOf(
4739
APP_LABEL to APP_LABEL_VALUE,
48-
NAME_LABEL to shinyProxy.metadata.name
40+
REALM_ID_LABEL to shinyProxy.realmId
4941
)
5042
}
5143

5244
const val APP_LABEL = "app"
5345
const val APP_LABEL_VALUE = "shinyproxy"
54-
const val NAME_LABEL = "openanalytics.eu/sp-resource-name"
46+
const val REALM_ID_LABEL = "openanalytics.eu/sp-realm-id"
5547
const val INSTANCE_LABEL = "openanalytics.eu/sp-instance"
5648
const val LATEST_INSTANCE_LABEL = "openanalytics.eu/sp-latest-instance"
5749
const val PROXIED_APP = "openanalytics.eu/sp-proxied-app"

src/main/kotlin/eu/openanalytics/shinyproxyoperator/components/PodTemplateSpecFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class PodTemplateSpecFactory {
7474
.build(),
7575
EnvVarBuilder()
7676
.withName("PROXY_REALM_ID")
77-
.withValue(shinyProxy.metadata.name + '-' + shinyProxy.metadata.namespace)
77+
.withValue(shinyProxy.realmId)
7878
.build()))
7979
.withVolumeMounts(VolumeMountBuilder()
8080
.withName("config-volume")

src/main/kotlin/eu/openanalytics/shinyproxyoperator/crd/ShinyProxy.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ class ShinyProxy : CustomResource<JsonNode, ShinyProxyStatus>(), Namespaced {
156156
return@lazy specAsYaml.sha1()
157157
}
158158

159+
@get:JsonIgnore
160+
val realmId: String by lazy {
161+
return@lazy "${metadata.name}-${metadata.namespace}"
162+
}
163+
159164

160165
fun logPrefix(shinyProxyInstance: ShinyProxyInstance): String {
161166
return "[${metadata.namespace}/${metadata.name}/${shinyProxyInstance.hashOfSpec}]"

src/test/kotlin/eu/openanalytics/shinyproxyoperator/helpers/ShinyProxyTestInstance.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class ShinyProxyTestInstance(private val namespace: String,
106106

107107
assertEquals(mapOf(
108108
LabelFactory.APP_LABEL to LabelFactory.APP_LABEL_VALUE,
109-
LabelFactory.NAME_LABEL to sp.metadata.name
109+
LabelFactory.REALM_ID_LABEL to sp.metadata.name
110110
), ingress.metadata.labels)
111111

112112
assertOwnerReferenceIsCorrect(ingress, sp)
@@ -131,7 +131,7 @@ class ShinyProxyTestInstance(private val namespace: String,
131131

132132
assertEquals(mapOf(
133133
LabelFactory.APP_LABEL to LabelFactory.APP_LABEL_VALUE,
134-
LabelFactory.NAME_LABEL to sp.metadata.name,
134+
LabelFactory.REALM_ID_LABEL to sp.metadata.name,
135135
LabelFactory.LATEST_INSTANCE_LABEL to sp.status.latestInstance()!!.hashOfSpec
136136
), service.metadata.labels)
137137

@@ -143,7 +143,7 @@ class ShinyProxyTestInstance(private val namespace: String,
143143
assertEquals(IntOrString(8080), service.spec.ports[0].targetPort)
144144
assertEquals(mapOf(
145145
LabelFactory.APP_LABEL to LabelFactory.APP_LABEL_VALUE,
146-
LabelFactory.NAME_LABEL to sp.metadata.name,
146+
LabelFactory.REALM_ID_LABEL to sp.metadata.name,
147147
LabelFactory.INSTANCE_LABEL to sp.status.latestInstance()!!.hashOfSpec // TODO
148148
), service.spec.selector)
149149

@@ -223,7 +223,7 @@ class ShinyProxyTestInstance(private val namespace: String,
223223
fun assertLabelsAreCorrect(resource: HasMetadata, sp: ShinyProxy) {
224224
assertEquals(mapOf(
225225
LabelFactory.APP_LABEL to LabelFactory.APP_LABEL_VALUE,
226-
LabelFactory.NAME_LABEL to sp.metadata.name,
226+
LabelFactory.REALM_ID_LABEL to sp.metadata.name,
227227
LabelFactory.INSTANCE_LABEL to hash
228228
), resource.metadata.labels)
229229
}

0 commit comments

Comments
 (0)