Skip to content

Commit 117f9cf

Browse files
committed
Update docs
1 parent 384d224 commit 117f9cf

9 files changed

Lines changed: 271 additions & 56 deletions

File tree

1.1 MB
Loading
72.4 KB
Loading
23.7 KB
Loading

.github/screenshots/prometheus.png

85.4 KB
Loading

.github/workflows/workflows.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
fail-fast: false
1010
matrix:
1111
java: [ 11 ]
12-
kubernetes: [ '1.21.4', '1.20.10', 'v1.19.14', 'v1.18.20', 'v1.17.17', 'v1.16.15']
12+
kubernetes: [ '1.21.3', '1.20.9', 'v1.19.14', 'v1.18.20', 'v1.17.17', 'v1.16.15']
1313

1414
steps:
1515
- uses: actions/checkout@v2

README.md

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,35 @@ Easily run ShinyProxy on a Kubernetes cluster
44

55
**(c) Copyright Open Analytics NV, 2020-2021 - Apache License 2.0**
66

7+
## Why?
8+
9+
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),
12+
users will face a disconnect from their running applications. The only solution
13+
to guarantee that users do not lose their connection to running apps, is to keep
14+
the current instance alive when updating ShinyProxy's configuration. However,
15+
manually keeping track of these instances would be too cumbersome and should
16+
therefore be automated.
17+
18+
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.
34+
35+
736
## Building from source
837

938
Clone this repository and run
@@ -41,13 +70,13 @@ now these options are specified using environment variables. All variables start
4170
used Kubernetes version does not support startup probes.
4271
- `SPO_STARTUP_PROBE_INITIAL_DELAY`: specifies the initial delay of the StartUp probe. By default this is 60 seconds.
4372
- `SPO_LOG_LEVEL`: configures the log level of the operator, may be one of the following:
44-
- `OFF`: disables logging
45-
- `ERROR`
46-
- `WARN`
47-
- `INFO`
48-
- `DEBUG`: default (may change)
49-
- `TRACE`
50-
- `ALL`: enables all logging
73+
- `OFF`: disables logging
74+
- `ERROR`
75+
- `WARN`
76+
- `INFO`
77+
- `DEBUG`: default (may change)
78+
- `TRACE`
79+
- `ALL`: enables all logging
5180

5281
Note: in our deployments where startup probes aren't supported we have success with the following configuration:
5382

@@ -57,20 +86,27 @@ Note: in our deployments where startup probes aren't supported we have success w
5786

5887
## Supported Versions
5988

60-
| ShinyProxy Version | Operator 0.0.1-20201215.112635 or older | Operator 0.0.1-SNAPSHOT-20210302.095930 or newer |
61-
| ------------------- | --------------------------------------- | ------------------------------------------------------- |
62-
| 2.4.3 or older | Compatible | Not Compatible |
63-
| 2.5.0 or newer | Not Compatible | Compatible |
89+
The first stable release of the operator (0.1.0) is compatible with ShinyProxy
90+
2.6.0. Older ShinyProxy versions are supported by running development snapshots
91+
of the operator, however, we strongly advice to upgrade to the latest version of
92+
ShinyProxy and the operator for the best experience.
93+
94+
| ShinyProxy Version | Minimum operator version | Maximum operator version (inclusive) |
95+
|--------------------|----------------------------------|--------------------------------------|
96+
| 2.4.3 | `0.0.1-SNAPSHOT-20201215.112635` | `0.0.1-SNAPSHOT-20201215.112635` |
97+
| 2.5.0 | `0.0.1-SNAPSHOT-20210302.095930` | `0.0.1-SNAPSHOT-20210607.070151` |
98+
| 2.6.0 | 0.1.0 | N/A |
6499

65100
## Kubernetes versions
66101

67-
| Kubernetes Version | Minimal required operator version | Notes |
68-
| ------------------ | -------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
69-
| v1.16 | Any version | Requires the use of `SPO_PROBE_INITIAL_DELAY` and `SPO_PROBE_FAILURE_THRESHOL` due to lack of startup probes. |
70-
| v1.17 | Any version | Requires the use of `SPO_PROBE_INITIAL_DELAY` and `SPO_PROBE_FAILURE_THRESHOL` due to lack of startup probes. |
71-
| v1.18 | Any version | Includes startup probes (as beta). |
72-
| v1.19 | Any version | |
73-
| v1.20 | 0.0.1-SNAPSHOT-20210113.083121 | |
102+
| Kubernetes Version | Minimal required operator version | Notes |
103+
|--------------------|-----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
104+
| v1.16 | Any version | Requires the use of `SPO_PROBE_INITIAL_DELAY` and `SPO_PROBE_FAILURE_THRESHOL` due to lack of startup probes. |
105+
| v1.17 | Any version | Requires the use of `SPO_PROBE_INITIAL_DELAY` and `SPO_PROBE_FAILURE_THRESHOL` due to lack of startup probes. |
106+
| v1.18 | Any version | Includes startup probes (as beta). |
107+
| v1.19 | Any version | |
108+
| v1.20 | 0.0.1-SNAPSHOT-20210113.083121 | This version is not officially supported by the Kubernetes API Client we use, however, integration and manual tests are performed against this version. Version 0.2.0 of the operator will officially support this version. |
109+
| v1.21 | 0.1.0 | Idem as for v1.20 |
74110

75111
## Java Version
76112

docs/deployment/README.md

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ directory.
66

77
## Component and dependencies
88

9-
Before showing how to deploy the operator, this section describes the components and dependencies of the operator.
9+
Before showing how to deploy the operator, this section describes the components
10+
and dependencies of the operator.
1011

11-
- **Operator**: the operator itself which manages the different ShinyProxy servers.
12+
- **Operator**: the operator itself which manages the different ShinyProxy
13+
servers.
1214
- **ShinyProxy**: the ShinyProxy servers, these host the Shiny apps. You do not
13-
need to create these servers manually, since these are created by the operator.
14-
Instead you define which servers to create and the operator creates all
15-
necessary Kubernetes resources, without affecting any existing server or
15+
need to create these servers manually, since these are created by the
16+
operator. Instead you define which servers to create and the operator creates
17+
all necessary Kubernetes resources, without affecting any existing server or
1618
causing downtime.
1719
- **Redis**: Redis is used by ShinyProxy (not by the operator) to implement
1820
session persistence. This ensures that when a ShinyProxy server is replaced,
@@ -34,9 +36,9 @@ ShinyProxy operator on minikube.
3436

3537
1. This tutorial requires that you install some tools:
3638

37-
- [minikube](https://github.com/kubernetes/minikube)
38-
- [kubectl](https://github.com/kubernetes/kubectl)
39-
- [kustomize](https://github.com/kubernetes-sigs/kustomize)
39+
- [minikube](https://github.com/kubernetes/minikube)
40+
- [kubectl](https://github.com/kubernetes/kubectl)
41+
- [kustomize](https://github.com/kubernetes-sigs/kustomize)
4042

4143
2. Start minikube:
4244

@@ -58,8 +60,8 @@ ShinyProxy operator on minikube.
5860
```
5961

6062
5. Wait for all the resources to startup. At this point the operator should
61-
start. It is now time to configure web access to the cluster.
62-
First get the IP of minikube using:
63+
start. It is now time to configure web access to the cluster. First get the
64+
IP of minikube using:
6365

6466
```bash
6567
minikube ip
@@ -105,8 +107,7 @@ ShinyProxy operator on minikube.
105107

106108
## Overview of examples
107109

108-
The Operator is designed to be flexible and fit many type of deployments. This
109-
repository includes examples for many kind of deployments:
110+
The Operator is designed to be flexible and fit many type of deployments. This repository includes examples for many kind of deployments:
110111

111112
- *1-namespaced-hpa*:
112113
- Operator-mode: `namespaced`
@@ -117,8 +118,7 @@ repository includes examples for many kind of deployments:
117118
- ShinyProxy-namespace: `shinyproxy`
118119
- URLs: `https://shinyproxy-demo.local`
119120

120-
This is a very simple deployment of the operator, were everything runs in the same
121-
namespace.
121+
This is a very simple deployment of the operator, were everything runs in the same namespace.
122122

123123
- *2-namespaced-ds*:
124124
- Operator-mode: `namespaced`
@@ -129,14 +129,8 @@ repository includes examples for many kind of deployments:
129129
- ShinyProxy-namespace: `shinyproxy`
130130
- URLs: `https://shinyproxy-demo.local`
131131

132-
This deployment is very similar to the previous one, except that it runs
133-
Skipper using a `DaemonSet` instead of an automatically scaling `Deployment`.
134-
Using the `DaemonSet` ensures that every Kubernetes nodes contains a Skipper
135-
pod. This is useful when you want an predictable amount of Skipper pods. In
136-
the previous example, the cluster automatically scales the amount of Skipper
137-
pods according to the load of these pods. When properly configured, this
138-
ensures that Skipper has enough resources to do its work, while not waisting
139-
resources.
132+
This deployment is very similar to the previous one, except that it runs Skipper using a `DaemonSet` instead of an automatically scaling `Deployment`. Using the `DaemonSet` ensures that every Kubernetes nodes contains a Skipper pod. This is useful when you want an predictable amount of Skipper pods. In the previous example, the cluster automatically scales the amount of Skipper pods according to the load of these pods. When properly configured, this ensures that Skipper has enough resources to
133+
do its work, while not waisting resources.
140134

141135
- *3-clustered-hpa*:
142136
- Operator-mode: `clustered`
@@ -149,14 +143,8 @@ repository includes examples for many kind of deployments:
149143
- `https://shinyproxy-demo.local`
150144
- `https://shinyproxy-demo2.local`
151145

152-
In this example, the operator runs in `clustered` mode. Therefore the operator
153-
will look into all namespaces for `ShinyProxy` resources and deploy these
154-
resources in their respective namespace. This also requires Skipper to be run
155-
in clustered mode (in the previous examples it would only look at `Ingress`
156-
definitions in the `shinyproxy` namespace.) This example also demonstrates how
157-
the Operator can be used in a multi-tenancy or multi-realm way. Each
158-
ShinyProxy server runs in its own namespace, isolated from the other servers.
159-
However, they are managed by a single operator.
146+
In this example, the operator runs in `clustered` mode. Therefore the operator will look into all namespaces for `ShinyProxy` resources and deploy these resources in their respective namespace. This also requires Skipper to be run in clustered mode (in the previous examples it would only look at `Ingress`
147+
definitions in the `shinyproxy` namespace.) This example also demonstrates how the Operator can be used in a multi-tenancy or multi-realm way. Each ShinyProxy server runs in its own namespace, isolated from the other servers. However, they are managed by a single operator.
160148

161149
- *4-clustered-ds*:
162150
- Operator-mode: `clustered`
@@ -181,9 +169,7 @@ repository includes examples for many kind of deployments:
181169
- URLs: `https://shinyproxy-demo.local`
182170

183171
Similar to example example 1, however, the `01_hello` app will now run in the
184-
`my-namespace` namespace instead of the `shinyproxy` namespace. In addition to
185-
the change in the `shinyproxy.yaml`, this configuration requires the
186-
definition of the extra namespace and the modification of the `ServiceAccount`
172+
`my-namespace` namespace instead of the `shinyproxy` namespace. In addition to the change in the `shinyproxy.yaml`, this configuration requires the definition of the extra namespace and the modification of the `ServiceAccount`
187173
of the ShinyProxy server.
188174

189175
- *6-namespaced-ds-multi*:
@@ -200,17 +186,23 @@ repository includes examples for many kind of deployments:
200186

201187
Based on example 2, this example shows how multi-tenancy can be achieved using
202188
sub-paths instead of multiple domainnames. Each ShinyProxy server is made
203-
available at the same domainname but at a different path under that domainname.
189+
available at the same domainname but at a different path under that
190+
domainname.
204191

205192
## ShinyProxy CRD
206193

207194
The `CustomResourceDefinition` of the operator can be found in the
208195
`bases/namespaced/operator/crd.yaml` directory (the CRD is equal for `clustered`
209-
and `namespaced` deployments). The following sections of this file are important:
196+
and `namespaced` deployments). The following sections of this file are
197+
important:
210198

211199
- `spring` config related to Spring, such as the redis connection information
212-
- `proxy` the configuration of ShinyProxy, this is the same configuration as if you were manually deploying ShinyProxy
200+
- `proxy` the configuration of ShinyProxy, this is the same configuration as if
201+
you were manually deploying ShinyProxy
213202
- `kubernetesPodTemplateSpecPatches` allows to patch the PodTemplate
214203
- `image` the docker image to use for the ShinyProxy instances
215204
- `fqdn` the FQDN at which the service should be available
216-
- `appNamespaces` a list of namespaces in which apps will be deployed. This is only needed when you change the namespace of an app using the `kubernetes-pod-patches` feature. The namespace of the operator and ShinyProxy instance are automatically included
205+
- `appNamespaces` a list of namespaces in which apps will be deployed. This is
206+
only needed when you change the namespace of an app using the
207+
`kubernetes-pod-patches` feature. The namespace of the operator and ShinyProxy
208+
instance are automatically included

docs/prometheus.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Prometheus Usage Statistics
2+
3+
This page describes how the usage statistics feature of ShinyProxy works in
4+
combination with the operator.
5+
6+
**Note:** this page is only applicable to ShinyProxy 2.6.0.
7+
8+
Before diving into the details, have a look at the setup of Prometheus
9+
monitoring with ShinyProxy in a [regular deployment](https://shinyproxy.io/documentation/usage-statistics/#micrometer).
10+
11+
Because the operator is meant to dynamically create ShinyProxy servers, it does
12+
not suffice to configure static list of ShinyProxy servers in Prometheus.
13+
Fortunately, Prometheus has the concept of [Service Discover](https://prometheus.io/docs/prometheus/latest/configuration/configuration/),
14+
which allows Prometheus to automatically *discover* ShinyProxy servers. We
15+
assume here that Prometheus is running in the same Kubernetes cluster as the
16+
ShinyProxy operator.
17+
18+
What follows is an example configuration of Prometheus:
19+
20+
```yaml
21+
scrape_configs:
22+
- job_name: 'k8pods'
23+
kubernetes_sd_configs:
24+
- role: pod
25+
relabel_configs:
26+
- source_labels: [__meta_kubernetes_pod_container_port_name]
27+
regex: metrics
28+
action: keep
29+
- source_labels: [__meta_kubernetes_pod_container_name]
30+
target_label: job
31+
- job_name: 'shinyproxy'
32+
metrics_path: '/actuator/prometheus'
33+
kubernetes_sd_configs:
34+
- role: pod
35+
relabel_configs:
36+
# instruct Prometheus to only look for ShinyProxy servers
37+
- source_labels: [__meta_kubernetes_pod_label_app]
38+
regex: shinyproxy
39+
action: keep
40+
# instruct Prometheus to use the special actuator port (9090)
41+
- source_labels: [__meta_kubernetes_pod_container_port_name]
42+
regex: actuator
43+
action: keep
44+
# provide a value for the job label
45+
- source_labels: [__meta_kubernetes_pod_container_name]
46+
target_label: job
47+
```
48+
49+
This configuration automatically discovers all ShinyProxy servers.
50+
51+
![Prometheus UI](../.github/screenshots/prometheus.png)
52+
53+
The above screenshot shows the `absolute_users_active` metric int the Prometheus
54+
UI. The `shinyproxy_realm` label is automatically added by ShinyProxy to every
55+
metric. The tag contains the resource name of the ShinyProxy server. Therefore
56+
this tag is not added to the metrics when ShinyProxy is not being run using the
57+
Operator. In the screenshot there are three ShinyProxy servers being managed by
58+
the ShinyProxy server and two servers using a traditional deployment. The
59+
`shinyproxy` realm has has two severs (instances) running (see the
60+
`shinyproxy_instance` label). The dashboard provided on the [ShinyProxy website](https://shinyproxy.io/documentation/usage-statistics/#micrometer)
61+
is designed to work with multiple realms and multiple servers inside each realm.
62+
For example, when displaying the Active Users, the dashboard differentiates
63+
between the different realms:
64+
65+
![Grafana UI](../.github/screenshots/grafana_active_users.png)
66+
67+
The dashboard contains two variables which allow you to filter the panels by
68+
realm or app name. By default these are hidden, check the [ShinyProxy website](https://shinyproxy.io/documentation/usage-statistics/#variable-filters)
69+
to makes these visible.

0 commit comments

Comments
 (0)