Skip to content

Commit b1ad4c4

Browse files
authored
feat: add nextcloud (#1609)
1 parent 886c845 commit b1ad4c4

11 files changed

Lines changed: 604 additions & 0 deletions

nextcloud/certificate.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: cert-manager.io/v1
2+
kind: Certificate
3+
metadata:
4+
name: nextcloud-tls
5+
spec:
6+
secretName: nextcloud-tls
7+
duration: 2160h0m0s # 90d
8+
renewBefore: 720h0m0s # 30d
9+
issuerRef:
10+
kind: ClusterIssuer
11+
name: dns-cluster-issuer
12+
dnsNames:
13+
- "drive.trap.jp"

nextcloud/config.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: nextcloud-config
5+
data:
6+
base.config.php: |
7+
<?php
8+
$CONFIG = array (
9+
'passwordsalt' => getenv('NEXTCLOUD_PASSWORDSALT'),
10+
'secret' => getenv('NEXTCLOUD_SECRET'),
11+
'instanceid' => getenv('NEXTCLOUD_INSTANCEID'),
12+
'overwrite.cli.url' => 'https://drive.trap.jp',
13+
'upgrade.disable-web' => true,
14+
'trusted_domains' => ['drive.trap.jp'],
15+
'apps_paths' => array (
16+
0 => array (
17+
'path' => '/var/www/html/apps',
18+
'url' => '/apps',
19+
'writable' => false,
20+
),
21+
1 => array (
22+
'path' => '/var/www/html/custom_apps',
23+
'url' => '/custom_apps',
24+
'writable' => true,
25+
),
26+
),
27+
28+
'mail_smtpmode' => 'smtp',
29+
'mail_smtphost' => 'smtp.sendgrid.host',
30+
'mail_smtpport' => '465',
31+
'mail_smtpsecure' => 'ssl',
32+
'mail_smtpauth' => true,
33+
'mail_smtpauthtype' => 'LOGIN',
34+
'mail_smtpname' => 'apikey',
35+
'mail_smtppassword' => getenv('SMTP_PASSWORD'),
36+
'mail_from_address' => 'drive.system',
37+
'mail_domain' => 'trap.jp',
38+
39+
'memcache.local' => '\OC\Memcache\APCu',
40+
'memcache.distributed' => '\OC\Memcache\Redis',
41+
'memcache.locking' => '\OC\Memcache\Redis',
42+
'redis' => array(
43+
'host' => 'valkey',
44+
'user' => 'default',
45+
'password' => getenv('VALKEY_PASSWORD'),
46+
),
47+
48+
'objectstore' => array(
49+
'class' => '\OC\Files\ObjectStore\S3',
50+
'arguments' => array(
51+
'bucket' => 'trap-nextcloud',
52+
'region' => 'ap-northeast-1',
53+
'hostname' => 's3.ap-northeast-1.wasabisys.com',
54+
'use_ssl' => true,
55+
'key' => getenv('S3_ACCESS_KEY'),
56+
'secret' => getenv('S3_SECRET_KEY'),
57+
'objectPrefix' => 'urn:oid:',
58+
'autocreate' => false,
59+
'use_path_style' => true,
60+
),
61+
),
62+
63+
'dbtype' => 'mysql',
64+
'dbhost' => 'tailscale.kmbk.tokyotech.org',
65+
'dbuser' => 'service_drive',
66+
'dbpassword' => getenv('DB_PASSWORD'),
67+
'dbname' => 'service_drive',
68+
'dbtableprefix' => 'oc_',
69+
'mysql.utf8mb4' => true,
70+
);

nextcloud/deployment.yaml

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
labels:
5+
app.kubernetes.io/name: nextcloud
6+
name: nextcloud
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app.kubernetes.io/name: nextcloud
12+
strategy:
13+
type: Recreate
14+
template:
15+
metadata:
16+
labels:
17+
app.kubernetes.io/name: nextcloud
18+
spec:
19+
affinity:
20+
nodeAffinity:
21+
requiredDuringSchedulingIgnoredDuringExecution:
22+
nodeSelectorTerms:
23+
- matchExpressions:
24+
- key: kubernetes.io/hostname
25+
operator: In
26+
values:
27+
- las211.tokyotech.org
28+
containers:
29+
- name: nextcloud
30+
image: ghcr.io/traptitech/nextcloud:29.0.5
31+
imagePullPolicy: IfNotPresent
32+
resources:
33+
limits:
34+
cpu: 500m
35+
memory: 256Mi
36+
requests:
37+
cpu: 50m
38+
memory: 128Mi
39+
env:
40+
- name: VALKEY_PASSWORD
41+
valueFrom:
42+
secretKeyRef:
43+
name: valkey
44+
key: default
45+
envFrom:
46+
- secretRef:
47+
name: secret-env
48+
volumeMounts:
49+
- mountPath: /var/www/
50+
name: nextcloud-main
51+
subPath: root
52+
- mountPath: /var/www/html
53+
name: nextcloud-main
54+
subPath: html
55+
- mountPath: /var/www/html/data
56+
name: nextcloud-main
57+
subPath: data
58+
- mountPath: /var/www/html/config
59+
name: nextcloud-main
60+
subPath: config
61+
- mountPath: /var/www/html/custom_apps
62+
name: nextcloud-main
63+
subPath: custom_apps
64+
- mountPath: /var/www/tmp
65+
name: nextcloud-main
66+
subPath: tmp
67+
- mountPath: /var/www/html/themes
68+
name: nextcloud-main
69+
subPath: themes
70+
- mountPath: /var/www/html/config/base.config.php
71+
name: base-config
72+
subPath: base.config.php
73+
- name: nextcloud-nginx
74+
image: library/nginx:alpine
75+
imagePullPolicy: IfNotPresent
76+
livenessProbe:
77+
failureThreshold: 3
78+
httpGet:
79+
httpHeaders:
80+
- name: Host
81+
value: drive.trap.jp
82+
path: /status.php
83+
port: 80
84+
initialDelaySeconds: 10
85+
periodSeconds: 10
86+
successThreshold: 1
87+
timeoutSeconds: 5
88+
ports:
89+
- containerPort: 80
90+
name: http
91+
protocol: TCP
92+
readinessProbe:
93+
failureThreshold: 3
94+
httpGet:
95+
httpHeaders:
96+
- name: Host
97+
value: drive.trap.jp
98+
path: /status.php
99+
port: 80
100+
initialDelaySeconds: 10
101+
periodSeconds: 10
102+
successThreshold: 1
103+
timeoutSeconds: 5
104+
resources:
105+
limits:
106+
cpu: 100m
107+
memory: 128Mi
108+
requests:
109+
cpu: 10m
110+
memory: 32Mi
111+
volumeMounts:
112+
- mountPath: /var/www/
113+
name: nextcloud-main
114+
subPath: root
115+
- mountPath: /var/www/html
116+
name: nextcloud-main
117+
subPath: html
118+
- mountPath: /var/www/html/data
119+
name: nextcloud-main
120+
subPath: data
121+
- mountPath: /var/www/html/config
122+
name: nextcloud-main
123+
subPath: config
124+
- mountPath: /var/www/html/custom_apps
125+
name: nextcloud-main
126+
subPath: custom_apps
127+
- mountPath: /var/www/tmp
128+
name: nextcloud-main
129+
subPath: tmp
130+
- mountPath: /var/www/html/themes
131+
name: nextcloud-main
132+
subPath: themes
133+
- mountPath: /etc/nginx/conf.d/
134+
name: nextcloud-nginx-config
135+
- name: nextcloud-cron
136+
command:
137+
- /cron.sh
138+
image: ghcr.io/traptitech/nextcloud:29.0.5
139+
imagePullPolicy: IfNotPresent
140+
resources:
141+
limits:
142+
cpu: 100m
143+
memory: 128Mi
144+
requests:
145+
cpu: 10m
146+
memory: 64Mi
147+
env:
148+
- name: VALKEY_PASSWORD
149+
valueFrom:
150+
secretKeyRef:
151+
name: valkey
152+
key: default
153+
envFrom:
154+
- secretRef:
155+
name: secret-env
156+
volumeMounts:
157+
- mountPath: /var/www/
158+
name: nextcloud-main
159+
subPath: root
160+
- mountPath: /var/www/html
161+
name: nextcloud-main
162+
subPath: html
163+
- mountPath: /var/www/html/data
164+
name: nextcloud-main
165+
subPath: data
166+
- mountPath: /var/www/html/config
167+
name: nextcloud-main
168+
subPath: config
169+
- mountPath: /var/www/html/custom_apps
170+
name: nextcloud-main
171+
subPath: custom_apps
172+
- mountPath: /var/www/tmp
173+
name: nextcloud-main
174+
subPath: tmp
175+
- mountPath: /var/www/html/themes
176+
name: nextcloud-main
177+
subPath: themes
178+
- mountPath: /var/www/html/config/base.config.php
179+
name: base-config
180+
subPath: base.config.php
181+
securityContext:
182+
fsGroup: 82
183+
volumes:
184+
- name: nextcloud-main
185+
persistentVolumeClaim:
186+
claimName: nextcloud-nextcloud
187+
- name: nextcloud-nginx-config
188+
configMap:
189+
name: nextcloud-nginxconfig
190+
- name: base-config
191+
configMap:
192+
name: nextcloud-config
193+
---
194+
apiVersion: v1
195+
kind: PersistentVolumeClaim
196+
metadata:
197+
labels:
198+
app.kubernetes.io/name: nextcloud
199+
name: nextcloud-nextcloud
200+
spec:
201+
accessModes:
202+
- ReadWriteOnce
203+
storageClassName: longhorn
204+
resources:
205+
requests:
206+
storage: 5Gi

nextcloud/ingress-route.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: traefik.io/v1alpha1
2+
kind: IngressRoute
3+
metadata:
4+
name: nextcloud
5+
spec:
6+
entryPoints:
7+
- websecure
8+
routes:
9+
- kind: Rule
10+
match: Host(`drive.trap.jp`)
11+
services:
12+
- name: nextcloud
13+
port: 8080
14+
tls:
15+
secretName: nextcloud-tls

nextcloud/ksops.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: viaduct.ai/v1
2+
kind: ksops
3+
metadata:
4+
name: ksops
5+
annotations:
6+
config.kubernetes.io/function: |
7+
exec:
8+
path: ksops
9+
10+
files:
11+
- ./secrets/secret-env.enc.yaml
12+
- ./secrets/valkey.enc.yaml

nextcloud/kustomization.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
helmCharts:
5+
- repo: https://valkey.io/valkey-helm/
6+
name: valkey
7+
version: 0.9.4
8+
namespace: nextcloud
9+
releaseName: valkey
10+
valuesFile: valkey-values.yaml
11+
12+
resources:
13+
- deployment.yaml
14+
- service.yaml
15+
- config.yaml
16+
- nginx-config.yaml
17+
- certificate.yaml
18+
- ingress-route.yaml
19+
20+
generators:
21+
- ksops.yaml

0 commit comments

Comments
 (0)