Skip to content

Commit f90fcf1

Browse files
committed
feat(k3s): add outline setup
1 parent 09ab018 commit f90fcf1

File tree

8 files changed

+377
-0
lines changed

8 files changed

+377
-0
lines changed
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+
namespace: outline
4+
5+
resources:
6+
- namespace.yaml
7+
8+
secretGenerator:
9+
- name: outline-secrets
10+
type: Opaque
11+
envs:
12+
- secrets/.secrets.env
13+
options:
14+
disableNameSuffixHash: true
15+
- name: outline-tls-cloudflare
16+
type: kubernetes.io/tls
17+
files:
18+
- tls.crt=secrets/tls.crt
19+
- tls.key=secrets/tls.key
20+
options:
21+
disableNameSuffixHash: true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: outline
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Outline secrets for outline.freecodecamp.net
2+
# All values must be unquoted
3+
# Generate secrets with: openssl rand -hex 32
4+
5+
# =============================================================================
6+
# REQUIRED - Application Secrets
7+
# =============================================================================
8+
SECRET_KEY=<openssl-rand-hex-32>
9+
UTILS_SECRET=<openssl-rand-hex-32>
10+
11+
# =============================================================================
12+
# REQUIRED - Database (internal, don't change unless you know what you're doing)
13+
# =============================================================================
14+
POSTGRES_USER=outline
15+
POSTGRES_PASSWORD=<generate-secure-password>
16+
POSTGRES_DB=outline
17+
18+
# =============================================================================
19+
# REQUIRED - Google OAuth
20+
# =============================================================================
21+
# Create at: https://console.cloud.google.com/apis/credentials
22+
# Authorized redirect URI: https://outline.freecodecamp.net/auth/google.callback
23+
GOOGLE_CLIENT_ID=<your-google-client-id>
24+
GOOGLE_CLIENT_SECRET=<your-google-client-secret>
25+
26+
# =============================================================================
27+
# OPTIONAL - Restrict to specific domain(s)
28+
# =============================================================================
29+
# Comma-separated list of allowed domains for signup
30+
# GOOGLE_ALLOWED_DOMAINS=freecodecamp.org
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: outline
5+
namespace: outline
6+
labels:
7+
app: outline
8+
spec:
9+
replicas: 1
10+
strategy:
11+
type: Recreate
12+
selector:
13+
matchLabels:
14+
app: outline
15+
template:
16+
metadata:
17+
labels:
18+
app: outline
19+
spec:
20+
initContainers:
21+
- name: fix-permissions
22+
image: busybox:1.36
23+
command: ["sh", "-c", "chown -R 1001:1001 /var/lib/outline/data"]
24+
volumeMounts:
25+
- name: outline-data
26+
mountPath: /var/lib/outline/data
27+
containers:
28+
# Outline application
29+
- name: outline
30+
image: docker.getoutline.com/outlinewiki/outline:latest
31+
ports:
32+
- containerPort: 3000
33+
name: http
34+
env:
35+
- name: NODE_ENV
36+
value: "production"
37+
- name: URL
38+
value: "https://outline.freecodecamp.net"
39+
- name: PORT
40+
value: "3000"
41+
- name: DATABASE_URL
42+
value: "postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@localhost:5432/$(POSTGRES_DB)"
43+
- name: PGSSLMODE
44+
value: "disable"
45+
- name: REDIS_URL
46+
value: "redis://localhost:6379"
47+
- name: FILE_STORAGE
48+
value: "local"
49+
- name: FILE_STORAGE_LOCAL_ROOT_DIR
50+
value: "/var/lib/outline/data"
51+
- name: FILE_STORAGE_UPLOAD_MAX_SIZE
52+
value: "262144000"
53+
- name: FORCE_HTTPS
54+
value: "true"
55+
- name: ENABLE_UPDATES
56+
value: "false"
57+
- name: WEB_CONCURRENCY
58+
value: "1"
59+
- name: LOG_LEVEL
60+
value: "info"
61+
- name: DEFAULT_LANGUAGE
62+
value: "en_US"
63+
envFrom:
64+
- secretRef:
65+
name: outline-secrets
66+
volumeMounts:
67+
- name: outline-data
68+
mountPath: /var/lib/outline/data
69+
resources:
70+
requests:
71+
cpu: 250m
72+
memory: 512Mi
73+
limits:
74+
cpu: 1000m
75+
memory: 1Gi
76+
livenessProbe:
77+
httpGet:
78+
path: /_health
79+
port: 3000
80+
initialDelaySeconds: 60
81+
periodSeconds: 30
82+
timeoutSeconds: 10
83+
readinessProbe:
84+
httpGet:
85+
path: /_health
86+
port: 3000
87+
initialDelaySeconds: 30
88+
periodSeconds: 10
89+
timeoutSeconds: 5
90+
91+
# PostgreSQL database
92+
- name: postgres
93+
image: postgres:16-alpine
94+
ports:
95+
- containerPort: 5432
96+
env:
97+
- name: POSTGRES_USER
98+
valueFrom:
99+
secretKeyRef:
100+
name: outline-secrets
101+
key: POSTGRES_USER
102+
- name: POSTGRES_PASSWORD
103+
valueFrom:
104+
secretKeyRef:
105+
name: outline-secrets
106+
key: POSTGRES_PASSWORD
107+
- name: POSTGRES_DB
108+
valueFrom:
109+
secretKeyRef:
110+
name: outline-secrets
111+
key: POSTGRES_DB
112+
- name: PGDATA
113+
value: /var/lib/postgresql/data/pgdata
114+
volumeMounts:
115+
- name: postgres-data
116+
mountPath: /var/lib/postgresql/data
117+
resources:
118+
requests:
119+
cpu: 100m
120+
memory: 256Mi
121+
limits:
122+
cpu: 500m
123+
memory: 512Mi
124+
livenessProbe:
125+
exec:
126+
command:
127+
- pg_isready
128+
- -U
129+
- outline
130+
initialDelaySeconds: 30
131+
periodSeconds: 10
132+
readinessProbe:
133+
exec:
134+
command:
135+
- pg_isready
136+
- -U
137+
- outline
138+
initialDelaySeconds: 5
139+
periodSeconds: 5
140+
141+
# Redis cache
142+
- name: redis
143+
image: redis:7-alpine
144+
ports:
145+
- containerPort: 6379
146+
command:
147+
- redis-server
148+
- --appendonly
149+
- "no"
150+
- --save
151+
- ""
152+
resources:
153+
requests:
154+
cpu: 50m
155+
memory: 64Mi
156+
limits:
157+
cpu: 200m
158+
memory: 128Mi
159+
livenessProbe:
160+
exec:
161+
command:
162+
- redis-cli
163+
- ping
164+
initialDelaySeconds: 10
165+
periodSeconds: 10
166+
readinessProbe:
167+
exec:
168+
command:
169+
- redis-cli
170+
- ping
171+
initialDelaySeconds: 5
172+
periodSeconds: 5
173+
174+
volumes:
175+
- name: postgres-data
176+
persistentVolumeClaim:
177+
claimName: outline-postgres
178+
- name: outline-data
179+
persistentVolumeClaim:
180+
claimName: outline-data
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: Gateway
3+
metadata:
4+
name: outline-gateway
5+
namespace: outline
6+
spec:
7+
gatewayClassName: traefik
8+
listeners:
9+
- name: websecure
10+
protocol: HTTPS
11+
port: 8443
12+
hostname: outline.freecodecamp.net
13+
tls:
14+
mode: Terminate
15+
certificateRefs:
16+
- name: outline-tls-cloudflare
17+
allowedRoutes:
18+
namespaces:
19+
from: Same
20+
- name: web
21+
protocol: HTTP
22+
port: 8000
23+
hostname: outline.freecodecamp.net
24+
allowedRoutes:
25+
namespaces:
26+
from: Same
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
apiVersion: traefik.io/v1alpha1
3+
kind: Middleware
4+
metadata:
5+
name: secure-headers
6+
namespace: outline
7+
spec:
8+
headers:
9+
customRequestHeaders:
10+
X-Forwarded-Proto: "https"
11+
12+
---
13+
apiVersion: traefik.io/v1alpha1
14+
kind: Middleware
15+
metadata:
16+
name: redirect-https
17+
namespace: outline
18+
spec:
19+
redirectScheme:
20+
scheme: https
21+
permanent: true
22+
23+
---
24+
# HTTP to HTTPS redirect
25+
apiVersion: gateway.networking.k8s.io/v1
26+
kind: HTTPRoute
27+
metadata:
28+
name: http-redirect
29+
namespace: outline
30+
spec:
31+
parentRefs:
32+
- name: outline-gateway
33+
namespace: outline
34+
sectionName: web
35+
hostnames:
36+
- outline.freecodecamp.net
37+
rules:
38+
- filters:
39+
- type: ExtensionRef
40+
extensionRef:
41+
group: traefik.io
42+
kind: Middleware
43+
name: redirect-https
44+
backendRefs:
45+
- name: outline
46+
port: 80
47+
48+
---
49+
# Main Outline route
50+
apiVersion: gateway.networking.k8s.io/v1
51+
kind: HTTPRoute
52+
metadata:
53+
name: outline-route
54+
namespace: outline
55+
spec:
56+
parentRefs:
57+
- name: outline-gateway
58+
namespace: outline
59+
sectionName: websecure
60+
hostnames:
61+
- outline.freecodecamp.net
62+
rules:
63+
- matches:
64+
- path:
65+
type: PathPrefix
66+
value: /
67+
filters:
68+
- type: ExtensionRef
69+
extensionRef:
70+
group: traefik.io
71+
kind: Middleware
72+
name: secure-headers
73+
backendRefs:
74+
- name: outline
75+
port: 80
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: outline-postgres
5+
namespace: outline
6+
spec:
7+
accessModes:
8+
- ReadWriteOnce
9+
storageClassName: longhorn
10+
resources:
11+
requests:
12+
storage: 10Gi
13+
---
14+
apiVersion: v1
15+
kind: PersistentVolumeClaim
16+
metadata:
17+
name: outline-data
18+
namespace: outline
19+
spec:
20+
accessModes:
21+
- ReadWriteOnce
22+
storageClassName: longhorn
23+
resources:
24+
requests:
25+
storage: 10Gi
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: outline
5+
namespace: outline
6+
labels:
7+
app: outline
8+
spec:
9+
type: ClusterIP
10+
ports:
11+
- port: 80
12+
targetPort: 3000
13+
protocol: TCP
14+
name: http
15+
selector:
16+
app: outline

0 commit comments

Comments
 (0)