blob: cbfd8a6a9cb66d9b1a3bcfb2d630b57441d2d870 [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 +00006
7{
8 onlyoffice:: {
radexc995c212023-11-24 12:01:49 +01009 local top = self,
10 local cfg = top.cfg,
Serge Bazanski06b61d42020-09-15 18:21:35 +000011 cfg:: {
12 namespace: error "cfg.namespace must be set",
Piotr Dobrowolski49787062022-02-09 21:30:16 +010013 image: "onlyoffice/documentserver:7.0.0.132",
Serge Bazanski06b61d42020-09-15 18:21:35 +000014 storageClassName: "waw-hdd-redundant-3",
15 domain: error "cfg.domain must be set",
16 },
17
radex1439fde2023-11-24 12:22:22 +010018 secretRefs:: {
19 jwt: { secretKeyRef: { name: "documentserver-jwt", key: "jwt", } },
20 },
21
radex99ed6a72023-11-24 11:42:55 +010022 local ns = kube.Namespace(cfg.namespace),
Serge Bazanski06b61d42020-09-15 18:21:35 +000023
radex99ed6a72023-11-24 11:42:55 +010024 pvc: ns.Contain(kube.PersistentVolumeClaim("documentserver")) {
radex36964dc2023-11-24 11:19:46 +010025 storage:: "10Gi",
26 storageClass:: cfg.storageClassName,
Serge Bazanski06b61d42020-09-15 18:21:35 +000027 },
28
radex99ed6a72023-11-24 11:42:55 +010029 deploy: ns.Contain(kube.Deployment("documentserver")) {
Serge Bazanski06b61d42020-09-15 18:21:35 +000030 spec+: {
31 template+: {
32 spec+: {
33 containers_: {
34 documentserver: kube.Container("default") {
35 image: cfg.image,
36 resources: {
37 requests: { memory: "4G", cpu: "100m" },
38 limits: { memory: "8G", cpu: "2" },
39 },
40 env_: {
41 JWT_ENABLED: "true",
radex1439fde2023-11-24 12:22:22 +010042 JWT_SECRET: top.secretRefs.jwt,
Serge Bazanski06b61d42020-09-15 18:21:35 +000043 },
44 ports_: {
45 http: { containerPort: 80 },
46 },
47 local make(sp, p) = { name: "data", mountPath: p, subPath: sp },
48 volumeMounts: [
49 // Per upstream Dockerfile:
Radek Pietruszewskif5844312023-10-27 22:41:18 +020050 // VOLUME /var/log/$COMPANY_NAME /var/lib/$COMPANY_NAME
Serge Bazanski06b61d42020-09-15 18:21:35 +000051 // /var/www/$COMPANY_NAME/Data /var/lib/postgresql
52 // /var/lib/rabbitmq /var/lib/redis
53 // /usr/share/fonts/truetype/custom
54 make("log", "/var/log/onlyoffice"),
55 make("www-data", "/var/www/onlyoffice/Data"),
56 make("postgres", "/var/lib/postgresql"),
57 make("rabbit", "/var/lib/rabbitmq"),
58 make("redis", "/var/lib/redis"),
59 make("fonts", "/usr/share/fonts/truetype/custom"),
60 ],
61 },
62 },
63 volumes_: {
radex4ffc64d2023-11-24 13:28:57 +010064 data: top.pvc.volume,
Serge Bazanski06b61d42020-09-15 18:21:35 +000065 },
66 },
67 },
68 },
69 },
70
radex99ed6a72023-11-24 11:42:55 +010071 svc: ns.Contain(kube.Service("documentserver")) {
radexc995c212023-11-24 12:01:49 +010072 target:: top.deploy,
Serge Bazanski06b61d42020-09-15 18:21:35 +000073 },
Radek Pietruszewskif5844312023-10-27 22:41:18 +020074
radex99ed6a72023-11-24 11:42:55 +010075 ingress: ns.Contain(kube.SimpleIngress("office")) {
Radek Pietruszewskif5844312023-10-27 22:41:18 +020076 hosts:: [cfg.domain],
radexd45584a2023-11-24 12:51:57 +010077 target:: top.svc,
Serge Bazanski06b61d42020-09-15 18:21:35 +000078 },
Serge Bazanski06b61d42020-09-15 18:21:35 +000079 },
80
81 prod: self.onlyoffice {
82 cfg+: {
83 namespace: "onlyoffice-prod",
84 domain: "office.hackerspace.pl",
85 },
86 },
87}