Skip to content

Commit d1c9bef

Browse files
committed
Improve docs
1 parent aa1d675 commit d1c9bef

1 file changed

Lines changed: 169 additions & 21 deletions

File tree

docs/deployment/README.md

Lines changed: 169 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -182,34 +182,182 @@ The `CustomResourceDefinition` of the operator can be found in the
182182
and `namespaced` deployments). The following sections of this file are
183183
important:
184184
185-
- `spring` config related to Spring, such as the redis connection information
186-
- `proxy` the configuration of ShinyProxy, this is the same configuration as if
185+
- `spring`: config related to Spring, such as the redis connection information
186+
- `proxy`: the configuration of ShinyProxy, this is the same configuration as if
187187
you were manually deploying ShinyProxy
188-
- `kubernetesPodTemplateSpecPatches` allows to patch the PodTemplate
189-
- `image` the docker image to use for the ShinyProxy instances
190-
- `fqdn` the FQDN at which the service should be available
191-
- `appNamespaces` a list of namespaces in which apps will be deployed. This is
188+
- `kubernetesPodTemplateSpecPatches`: allows to patch the `PodTemplate` of the
189+
ReplicaSet created by the operator (see
190+
the [example](#modify-the-shinyproxy-pod))
191+
- `kubernetesIngressPatches`: allows to patch the `Ingress` resources created by
192+
the operator (see the [example](#modify-the-ingress-resource)
193+
- `image`: the docker image to use for the ShinyProxy server (
194+
e.g. `openanalytics/shinyproxy:3.0.0`)
195+
- `imagePullPolicy`: the pull policy for ShinyProxy Image; the default value is
196+
`IfNotPresent`; valid options are `Never`, `IfNotPresent` and `Always`.
197+
- `fqdn`: the FQDN at which the service should be available, e.g. `
198+
shinyproxy-demo.local
199+
- `appNamespaces`: a list of namespaces in which apps will be deployed. This is
192200
only needed when you change the namespace of an app using the
193201
`kubernetes-pod-patches` feature. The namespace of the operator and ShinyProxy
194202
instance are automatically included
195203
196-
## Troubleshooting
197-
198-
You may get the following exception:
204+
## Modify the Ingress Resource
205+
206+
The ShinyProxy Operator automatically creates an ingress resource for each
207+
ShinyProxy resource you create. This ingress resource points to the correct
208+
Kubernetes service (which is also created by the operator). The created Ingress
209+
resource contains everything that is needed for a working ShinyProxy deployment.
210+
However, in some cases it is required to modify the resource. This can be
211+
achieved using the `kubernetesIngressPatches` field. This field should contain a
212+
string which contains a list of [JSON Patches](https://jsonpatch.com/) to apply
213+
to the Ingress resource. The above examples already include the following patch:
214+
215+
```yaml
216+
apiVersion: openanalytics.eu/v1
217+
kind: ShinyProxy
218+
metadata:
219+
name: shinyproxy
220+
namespace: shinyproxy
221+
spec:
222+
proxy:
223+
# ...
224+
kubernetesIngressPatches: |
225+
- op: add
226+
path: /metadata/annotations
227+
value:
228+
nginx.ingress.kubernetes.io/proxy-buffer-size: "128k"
229+
nginx.ingress.kubernetes.io/ssl-redirect: "true"
230+
nginx.ingress.kubernetes.io/proxy-body-size: 300m
231+
- op: add
232+
path: /spec/ingressClassName
233+
value: nginx
234+
image: openanalytics/shinyproxy:3.0.0
235+
imagePullPolicy: Always
236+
fqdn: shinyproxy-demo.local
237+
```
199238
200-
```text
201-
io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: POST at: https://10.96.0.1/apis/networking.k8s.io/v1beta1/namespaces/shinyproxy/ingresses. Message: admission webhook "validate.nginx.ingress.kubernetes.io" denied the request: host "shinyproxy-demo.local" and path "/" is already defined in ingress shinyproxy/nginx-to-skipper-ingress. Received status: Status(apiVersion=v1, code=400, details=null, kind=Status, message=admission webhook "validate.nginx.ingress.kubernetes.io" denied the request: host "shinyproxy-demo.local" and path "/" is already defined in ingress shinyproxy/nginx-to-skipper-ingress, metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=BadRequest, status=Failure, additionalProperties={}).
239+
The first patch adds some additional annotations to the ShinyProx resource. For
240+
example, in order to set up a redirect from HTTP to HTTPS. The second patch
241+
changes the ingressClassName to `nginx`. Any patch is accepted, but make sure
242+
that the resulting Ingress resource still works for the ShinyProxy Deployment.
243+
The ShinyProxy Operator logs the manifest before and after applying the patch,
244+
this can be useful while creating the patches.
245+
246+
**Note:** the previous section only applies to version 2 of the operator.
247+
Version 1 behaves differently since it used Skipper as (intermediate) ingress
248+
controller.
249+
250+
## Modify the ShinyProxy Pod
251+
252+
The Operator automatically creates a ReplicaSet for each ShinyProxy resource you
253+
create. This ReplicaSet contains a `PodTemplate`, which contains all necessary
254+
settings for creating a proper ShinyProxy pod. In a lot of cases, it can be
255+
useful to adapt this `PodTemplate` for the specific context in which ShinyProxy
256+
is running. For example, it's a good idea to specify the resource requests and
257+
limits, or sometimes it's required to add a toleration to the pod. These
258+
modification can be achieved using the `kubernetesPodTemplateSpecPatches` field.
259+
This field should contain a string which contains a list
260+
of [JSON Patches](https://jsonpatch.com/) to apply to the `PodTemplate`. The
261+
above examples already include the following patch:
262+
263+
```yaml
264+
apiVersion: openanalytics.eu/v1
265+
kind: ShinyProxy
266+
metadata:
267+
name: shinyproxy
268+
namespace: shinyproxy
269+
spec:
270+
proxy:
271+
# ...
272+
kubernetesPodTemplateSpecPatches: |
273+
- op: add
274+
path: /spec/containers/0/env/-
275+
value:
276+
name: REDIS_PASSWORD
277+
valueFrom:
278+
secretKeyRef:
279+
name: redis
280+
key: redis-password
281+
- op: add
282+
path: /spec/containers/0/resources
283+
value:
284+
limits:
285+
cpu: 1
286+
memory: 1Gi
287+
requests:
288+
cpu: 0.5
289+
memory: 1Gi
290+
- op: add
291+
path: /spec/serviceAccountName
292+
value: shinyproxy-sa
293+
image: openanalytics/shinyproxy:3.0.0
294+
imagePullPolicy: Always
295+
fqdn: shinyproxy-demo.local
202296
```
203297
204-
This exception is caused by a
205-
[bug](https://github.com/kubernetes/ingress-nginx/issues/7546) in the latest
206-
(v1.0.0) version of the ingress-nginx controller. There are two workarounds for this bug:
298+
The above configuration contains three patches. The first patch adds an
299+
environment variable with the password used for connecting to the Redis server.
300+
The second patch configures the resource limits and requests of the ShinyProxy
301+
pod. Finally, the last patch configures the `ServiceAccount` of the pod.
302+
303+
**Note:** it is important when using this feature to not break any existing
304+
configuration of the pod. For example, when you want to mount additional
305+
configmaps, use the following configuration:
306+
307+
```yaml
308+
apiVersion: openanalytics.eu/v1
309+
kind: ShinyProxy
310+
metadata:
311+
name: shinyproxy
312+
namespace: shinyproxy
313+
spec:
314+
kubernetesPodTemplateSpecPatches: |
315+
- op: add
316+
path: /spec/volumes/-
317+
value:
318+
name: myconfig
319+
configMap:
320+
name: some-configmnap
321+
- op: add
322+
path: /spec/containers/0/volumeMounts/-
323+
value:
324+
mountPath: /mnt/configmap
325+
name: myconfig
326+
readOnly: true
327+
```
207328
208-
- use a version of the ingress controller older than v1.0.0 (e.g. v0.49.2)
209-
- remove the validating webhook using, this is **not recommended** since it
210-
removes an important part of how the ingress controller works. However, it is
211-
an easy solution when you are following the above tutorial in minikube:
329+
In this example, the `path` property of the patch always ends with a `-`, this
330+
indicates that the patch adds a new entry to the end of the array
331+
( e.g. `spec/volumes/`).
332+
333+
The following patch breaks the behavior of the ShinyProxy pod and should
334+
therefore not be used:
335+
336+
```yaml
337+
# NOTE: this is a demo of a WRONG configuration - do not use
338+
apiVersion: openanalytics.eu/v1
339+
kind: ShinyProxy
340+
metadata:
341+
name: shinyproxy
342+
namespace: shinyproxy
343+
spec:
344+
kubernetesPodTemplateSpecPatches: |
345+
- op: add
346+
path: /spec/volumes
347+
value:
348+
- name: myconfig
349+
configMap:
350+
name: some-configmnap
351+
- op: add
352+
path: /spec/containers/0/volumeMounts
353+
value:
354+
- mountPath: /mnt/configmap
355+
name: myconfig
356+
readOnly: true
357+
```
212358
213-
```bash
214-
kubectl delete -A ValidatingWebhookConfiguration ingress-nginx-admission
215-
```
359+
This patch replaces the existing `/spec/volumes`
360+
and `/spec/containers/0/volumeMounts` arrays of the pod. The ShinyProxy Operator
361+
automatically creates a mount for a configmap which contains the ShinyProxy
362+
configuration. By overriding these mounts, this configmap is not be mounted and
363+
the default (demo) configuration of ShinyProxy is loaded.

0 commit comments

Comments
 (0)