blob: d1ea8754f49d51192126fbf7f67f5ed25fdd5405 [file] [log] [blame]
Serge Bazanski06b61d42020-09-15 18:21:35 +00001// ONLYOFFICE document server.
2// JWT secret needs to be generated as follows per environment:
3// kubectl -n onlyoffice-prod create secret generic documentserver-jwt --from-literal=jwt=$(pwgen 32 1)
4
Radek Pietruszewskif5844312023-10-27 22:41:18 +02005local kube = import "../../kube/hscloud.libsonnet";
Serge Bazanski06b61d42020-09-15 18:21:35 +00006local policies = import "../../kube/policies.libsonnet";
7
8{
9 onlyoffice:: {
radexc995c212023-11-24 12:01:49 +010010 local top = self,
11 local cfg = top.cfg,
Serge Bazanski06b61d42020-09-15 18:21:35 +000012 cfg:: {
13 namespace: error "cfg.namespace must be set",
Piotr Dobrowolski49787062022-02-09 21:30:16 +010014 image: "onlyoffice/documentserver:7.0.0.132",
Serge Bazanski06b61d42020-09-15 18:21:35 +000015 storageClassName: "waw-hdd-redundant-3",
16 domain: error "cfg.domain must be set",
17 },
18
radex1439fde2023-11-24 12:22:22 +010019 secretRefs:: {
20 jwt: { secretKeyRef: { name: "documentserver-jwt", key: "jwt", } },
21 },
22
radex99ed6a72023-11-24 11:42:55 +010023 local ns = kube.Namespace(cfg.namespace),
Serge Bazanski06b61d42020-09-15 18:21:35 +000024
radex99ed6a72023-11-24 11:42:55 +010025 pvc: ns.Contain(kube.PersistentVolumeClaim("documentserver")) {
radex36964dc2023-11-24 11:19:46 +010026 storage:: "10Gi",
27 storageClass:: cfg.storageClassName,
Serge Bazanski06b61d42020-09-15 18:21:35 +000028 },
29
radex99ed6a72023-11-24 11:42:55 +010030 deploy: ns.Contain(kube.Deployment("documentserver")) {
Serge Bazanski06b61d42020-09-15 18:21:35 +000031 spec+: {
32 template+: {
33 spec+: {
34 containers_: {
35 documentserver: kube.Container("default") {
36 image: cfg.image,
37 resources: {
38 requests: { memory: "4G", cpu: "100m" },
39 limits: { memory: "8G", cpu: "2" },
40 },
41 env_: {
42 JWT_ENABLED: "true",
radex1439fde2023-11-24 12:22:22 +010043 JWT_SECRET: top.secretRefs.jwt,
Serge Bazanski06b61d42020-09-15 18:21:35 +000044 },
45 ports_: {
46 http: { containerPort: 80 },
47 },
48 local make(sp, p) = { name: "data", mountPath: p, subPath: sp },
49 volumeMounts: [
50 // Per upstream Dockerfile:
Radek Pietruszewskif5844312023-10-27 22:41:18 +020051 // VOLUME /var/log/$COMPANY_NAME /var/lib/$COMPANY_NAME
Serge Bazanski06b61d42020-09-15 18:21:35 +000052 // /var/www/$COMPANY_NAME/Data /var/lib/postgresql
53 // /var/lib/rabbitmq /var/lib/redis
54 // /usr/share/fonts/truetype/custom
55 make("log", "/var/log/onlyoffice"),
56 make("www-data", "/var/www/onlyoffice/Data"),
57 make("postgres", "/var/lib/postgresql"),
58 make("rabbit", "/var/lib/rabbitmq"),
59 make("redis", "/var/lib/redis"),
60 make("fonts", "/usr/share/fonts/truetype/custom"),
61 ],
62 },
63 },
64 volumes_: {
radexc995c212023-11-24 12:01:49 +010065 data: kube.PersistentVolumeClaimVolume(top.pvc),
Serge Bazanski06b61d42020-09-15 18:21:35 +000066 },
67 },
68 },
69 },
70 },
71
radex99ed6a72023-11-24 11:42:55 +010072 svc: ns.Contain(kube.Service("documentserver")) {
radexc995c212023-11-24 12:01:49 +010073 target:: top.deploy,
Serge Bazanski06b61d42020-09-15 18:21:35 +000074 },
Radek Pietruszewskif5844312023-10-27 22:41:18 +020075
radex99ed6a72023-11-24 11:42:55 +010076 ingress: ns.Contain(kube.SimpleIngress("office")) {
Radek Pietruszewskif5844312023-10-27 22:41:18 +020077 hosts:: [cfg.domain],
radexd45584a2023-11-24 12:51:57 +010078 target:: top.svc,
Serge Bazanski06b61d42020-09-15 18:21:35 +000079 },
80
81 // Needed because the documentserver runs its own supervisor, and:
82 // - rabbitmq wants to mkdir in /run, which starts out with the wrong permissions
83 // - nginx wants to bind to port 80
84 insecure: policies.AllowNamespaceInsecure(cfg.namespace),
85 },
86
87 prod: self.onlyoffice {
88 cfg+: {
89 namespace: "onlyoffice-prod",
90 domain: "office.hackerspace.pl",
91 },
92 },
93}