helm collabora kubernetes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

330 lines
10 KiB

11 months ago
  1. # Collabora Online for Kubernetes
  2. In order for Collaborative Editing and copy/paste to function correctly on kubernetes, it is vital to ensure that all users editing the same document and all the clipboard request end up being served by the same pod. Using the WOPI protocol, the https URL includes a unique identifier (WOPISrc) for use with this document. Thus load balancing can be done by using WOPISrc -- ensuring that all URLs that contain the same WOPISrc are sent to the same pod.
  3. ## Deploying Collabora Online in Kubernetes
  4. 1. Install [helm](https://helm.sh/docs/intro/install/)
  5. 2. Setting up Kubernetes Ingress Controller
  6. A. Nginx:
  7. Install [Nginx Ingress
  8. Controller](https://kubernetes.github.io/ingress-nginx/deploy/)
  9. B. HAProxy:
  10. Install [HAProxy Ingress
  11. Controller](https://www.haproxy.com/documentation/kubernetes-ingress/)
  12. ---
  13. **Note:**
  14. **Openshift** uses minimized version of HAproxy called
  15. [Router](https://docs.openshift.com/container-platform/3.11/install_config/router) that doesn\'t support all functionality of HAProxy but for COOL we need advance annotations Therefore it is recommended deploy [HAproxy Kubernetes Ingress](https://artifacthub.io/packages/helm/haproxytech/kubernetes-ingress) in `collabora` namespace
  16. ---
  17. 3. Create an `my_values.yaml` (if your setup differs e.g. take an look in then `values.yaml ./collabora-online/values.yaml`) of the
  18. helmchart
  19. A. HAproxy:
  20. ``` yaml
  21. replicaCount: 3
  22. ingress:
  23. enabled: true
  24. className: "haproxy"
  25. annotations:
  26. haproxy.org/timeout-tunnel: "3600s"
  27. haproxy.org/backend-config-snippet: |
  28. balance url_param WOPISrc check_post
  29. hash-type consistent
  30. hosts:
  31. - host: chart-example.local
  32. paths:
  33. - path: /
  34. pathType: ImplementationSpecific
  35. image:
  36. tag: "latest"
  37. autoscaling:
  38. enabled: false
  39. collabora:
  40. aliasgroups:
  41. - host: "https://example.integrator.com:443"
  42. extra_params: --o:ssl.enable=false --o:ssl.termination=true
  43. resources:
  44. limits:
  45. cpu: "1800m"
  46. memory: "2000Mi"
  47. requests:
  48. cpu: "1800m"
  49. memory: "2000Mi"
  50. ```
  51. B. Nginx:
  52. ``` yaml
  53. replicaCount: 3
  54. ingress:
  55. enabled: true
  56. className: "nginx"
  57. annotations:
  58. nginx.ingress.kubernetes.io/upstream-hash-by: "$arg_WOPISrc"
  59. nginx.ingress.kubernetes.io/proxy-body-size: "0"
  60. nginx.ingress.kubernetes.io/proxy-read-timeout: "600"
  61. nginx.ingress.kubernetes.io/proxy-send-timeout: "600"
  62. hosts:
  63. - host: chart-example.local
  64. paths:
  65. - path: /
  66. pathType: ImplementationSpecific
  67. image:
  68. tag: "latest"
  69. autoscaling:
  70. enabled: false
  71. collabora:
  72. aliasgroups:
  73. - host: "https://example.integrator.com:443"
  74. extra_params: --o:ssl.enable=false --o:ssl.termination=true
  75. resources:
  76. limits:
  77. cpu: "1800m"
  78. memory: "2000Mi"
  79. requests:
  80. cpu: "1800m"
  81. memory: "2000Mi"
  82. ```
  83. ---
  84. **Note:**
  85. - **Horizontal Pod Autoscaling(HPA) is disabled for now. Because after scaling it breaks the collaborative editing and copy/paste
  86. Therefore please set replicaCount as per your needs**
  87. - If you have multiple host and aliases setup set aliasgroups in `my_values.yaml`:
  88. ``` yaml
  89. collabora:
  90. - host: "<protocol>://<host-name>:<port>"
  91. # if there are no aliases you can ignore the below line
  92. aliases: ["<protocol>://<its-first-alias>:<port>, <protocol>://<its-second-alias>:<port>"]
  93. # more host and aliases list is possible
  94. ```
  95. - Specify `server_name` when the hostname is not reachable directly for example behind reverse-proxy
  96. ``` yaml
  97. collabora:
  98. server_name: <hostname>:<port>
  99. ```
  100. - In **Openshift** , it is recommended to use HAproxy deployment instead of default router. And add `className` in ingress block
  101. so that Openshift uses HAProxy Ingress Controller instead of `Router`:
  102. ``` yaml
  103. ingress:
  104. className: "haproxy"
  105. ```
  106. ---
  107. 4. Install helm-chart using below command, it should deploy the collabora-online
  108. ``` bash
  109. helm repo add collabora https://collaboraonline.github.io/online/
  110. helm install --create-namespace --namespace collabora collabora-online collabora/collabora-online -f my_values.yaml
  111. ```
  112. 5. Follow only if you are using `NodePort` service type in HAProxy and/or using minikube to setup, otherwise skip
  113. A. HAProxy service is deployed as NodePort so we can access it with node's ip address. To get node ip
  114. ```bash
  115. minikube ip
  116. ```
  117. Example output:
  118. ```
  119. 192.168.0.106
  120. ```
  121. B. Each container port is mapped to a `NodePort` port via the `Service` object. To find those ports
  122. ```
  123. kubectl get svc --namespace=haproxy-controller
  124. ```
  125. Example output:
  126. ```
  127. |----------------|---------|--------------|------------|------------------------------------------|
  128. |NAME |TYPE |CLUSTER-IP |EXTERNAL-IP |PORT(S) |
  129. |----------------|---------|--------------|------------|------------------------------------------|
  130. |haproxy-ingress |NodePort |10.108.214.98 |<none> |80:30536/TCP,443:31821/TCP,1024:30480/TCP |
  131. |----------------|---------|--------------|------------|------------------------------------------|
  132. ```
  133. In this instance, the following ports were mapped:
  134. - Container port 80 to NodePort 30536
  135. - Container port 443 to NodePort 31821
  136. - Container port 1024 to NodePort 30480
  137. 6. Additional step if deploying on minikube for testing:
  138. 1. Get minikube ip:
  139. ``` bash
  140. minikube ip
  141. ```
  142. Example output:
  143. ``` bash
  144. 192.168.0.106
  145. ```
  146. 2. Add hostname to `/etc/hosts`
  147. ``` bash
  148. 192.168.0.106 chart-example.local
  149. ```
  150. 3. To check if everything is setup correctly you can run:
  151. ``` bash
  152. curl -I -H 'Host: chart-example.local' 'http://192.168.0.106:30536/'
  153. ```
  154. It should return a similar output as below:
  155. ``` bash
  156. HTTP/1.1 200 OK
  157. last-modified: Tue, 18 May 2021 10:46:29
  158. user-agent: COOLWSD WOPI Agent 6.4.8
  159. content-length: 2
  160. content-type: text/plain
  161. ```
  162. ## Kubernetes cluster monitoring
  163. 1. Install [kube-prometheus-stack](https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack), a collection of [Grafana](http://grafana.com/) dashboards, and [Prometheus rules](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/) combined with documentation and scripts to provide easy to operate end-to-end Kubernetes cluster monitoring with
  164. [Prometheus](https://prometheus.io/) using the [Prometheus Operator](https://prometheus-operator.dev/).
  165. 2. Enable prometheus service monitor, rules and grafana in your
  166. `my_values.yaml`
  167. ``` yaml
  168. prometheus:
  169. servicemonitor:
  170. enabled: true
  171. labels:
  172. release: "kube-prometheus-stack"
  173. rules:
  174. enabled: true # will deploy alert rules
  175. additionalLabels:
  176. release: "kube-prometheus-stack"
  177. grafana:
  178. dashboards:
  179. enabled: true # will deploy default dashboards
  180. ```
  181. ---
  182. **Note:**
  183. Use `kube-prometheus-stack` as release name when installing [kube-prometheus-stack](https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack) helm chart because we have passed `release=kube-prometheus-stack` label in our `my_values.yaml`. For Grafana Dashboards you may need to enable scan in correct namespaces (or ALL), enabled by `sidecar.dashboards.searchNamespace` in [Helmchart of grafana](https://artifacthub.io/packages/helm/grafana/grafana) (which is part of PrometheusOperator, so `grafana.sidecar.dashboards.searchNamespace`)
  184. ---
  185. ## Dynamic/Remote configuration in kubernetes
  186. For big setups, you may not want to restart every pod to modify WOPI
  187. hosts, therefore it is possible to setup an additional webserver to
  188. serve a ConfigMap for using [Remote/Dynamic
  189. Configuration](https://sdk.collaboraonline.com/docs/installation/Configuration.html#remote-dynamic-configuration)
  190. ``` yaml
  191. collabora:
  192. env:
  193. - name: remoteconfigurl
  194. value: https://dynconfig.public.example.com/config/config.json
  195. dynamicConfig:
  196. enabled: true
  197. ingress:
  198. enabled: true
  199. annotations:
  200. "cert-manager.io/issuer": letsencrypt-zprod
  201. hosts:
  202. - host: "dynconfig.public.example.com"
  203. tls:
  204. - secretName: "collabora-online-dynconfig-tls"
  205. hosts:
  206. - "dynconfig.public.example.com"
  207. configuration:
  208. kind: "configuration"
  209. storage:
  210. wopi:
  211. alias_groups:
  212. groups:
  213. - host: "https://domain1\\.xyz\\.abc\\.com/"
  214. allow: true
  215. - host: "https://domain2\\.pqr\\.def\\.com/"
  216. allow: true
  217. aliases:
  218. - "https://domain2\\.ghi\\.leno\\.de/"
  219. ```
  220. ---
  221. **Note:**
  222. In current state of COOL remoteconfigurl for [Remote/DynamicConfiguration](https://sdk.collaboraonline.com/docs/installation/Configuration.html#remote-dynamic-configuration) only uses HTTPS. see [here in wsd/COOLWSD.cpp](https://github.com/CollaboraOnline/online/blob/8591d323c6db99e592ac8ac8ebef0e3a95f2e6ba/wsd/COOLWSD.cpp#L1069-L1096)
  223. ---
  224. ## Useful commands to check what is happening
  225. Where is this pods, are they ready?
  226. ``` bash
  227. kubectl -n collabora get pod
  228. ```
  229. example output :
  230. ``` bash
  231. NAME READY STATUS RESTARTS AGE
  232. collabora-online-5fb4869564-dnzmk 1/1 Running 0 28h
  233. collabora-online-5fb4869564-fb4cf 1/1 Running 0 28h
  234. collabora-online-5fb4869564-wbrv2 1/1 Running 0 28h
  235. ```
  236. What is the outside host that multiple coolwsd servers actually
  237. answering?
  238. ``` bash
  239. kubectl get ingress -n collabora
  240. ```
  241. example output :
  242. ``` bash
  243. |-----------|------------------|--------------------------|------------------------|-------|
  244. | NAMESPACE | NAME | HOSTS | ADDRESS | PORTS |
  245. |-----------|------------------|--------------------------|------------------------|-------|
  246. | collabora | collabora-online |chart-example.local | | 80 |
  247. |-----------|------------------|--------------------------|------------------------|-------|
  248. ```
  249. To uninstall the helm chart
  250. ``` bash
  251. helm uninstall collabora-online -n collabora
  252. ```