Skip to content

Commit 220e367

Browse files
Deploy a pinnwand instance that used lovelace's pg database (#293)
* add a deployment config for pinnwand on lovelace * add a dns entry for the new pastebin * Add database URI for pinnwand to connect to psql on lovelace --------- Co-authored-by: Chris Lovering <[email protected]>
1 parent b3a642d commit 220e367

File tree

8 files changed

+150
-1
lines changed

8 files changed

+150
-1
lines changed

ansible/roles/nftables

Submodule nftables deleted from 015a7ed

dns/zones/pythondiscord.com.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ grafana:
128128
type: A
129129
value: 194.195.247.228
130130

131+
lovelace-paste:
132+
octodns:
133+
cloudflare:
134+
proxied: true
135+
ttl: 300
136+
type: A
137+
value: 194.195.247.228
138+
131139
mailo._domainkey:
132140
octodns:
133141
cloudflare:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# pinnwand
2+
These manifests provision an instance of the pinnwand service used on https://paste.pythondiscord.com.
3+
4+
A init-service is used to download the Python Discord banner logo and save it to a volume, as pinnwand expects it to be present within the image.
5+
6+
## Secrets & config
7+
This deployment expects an env var named `PINNWAND_DATABASE_URI` to exist in a secret called `pinnwand-postgres-connection`.
8+
All other configuration can be found in `defaults-configmap.yaml`.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: pinnwand-lovelace-config
5+
namespace: web
6+
data:
7+
config.toml: |
8+
# Maximum size in bytes of pastes
9+
paste_size = 524288
10+
11+
default_selected_lexer = "python"
12+
# List of lexers to pin to the top of the dropdown list
13+
preferred_lexers = ["python", "autodetect", "pytb", "pycon", "text", "markdown", "restructuredtext", "sql"]
14+
15+
page_list = ["about", "removal"]
16+
footer = 'View <a href="//github.com/supakeen/pinnwand" target="_BLANK">source code</a>, <a href="/removal">removal</a> information, or read the <a href="/about">about</a> page.'
17+
18+
paste_help = '''<p>Welcome to Python Discord's pastebin, powered by <a href="//github.com/supakeen/pinnwand" target="_BLANK">pinnwand</a>. It allows you to share code with others. If you write code in the text area below and press the paste button you will be given a link you can share with others so they can view your code as well.</p><p>People with the link can view your pasted code, only you can remove your paste and it expires automatically. Note that anyone could guess the URI to your paste so don't rely on it being private.</p>'''
19+
expiries.30days = 2592000
20+
expiries.7days = 604800
21+
expiries.1day = 86400
22+
23+
ratelimit.read.capacity = 100
24+
ratelimit.read.consume = 1
25+
ratelimit.read.refill = 2
26+
27+
ratelimit.create.capacity = 10 # Default is 2
28+
ratelimit.create.consume = 1 # Default is 2
29+
ratelimit.create.refill = 10 # Default is 1
30+
31+
ratelimit.delete.capacity = 2
32+
ratelimit.delete.consume = 2
33+
ratelimit.delete.refill = 1
34+
35+
report_email = "[email protected]"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: pinnwand-lovelace
5+
namespace: web
6+
spec:
7+
replicas: 1
8+
selector:
9+
matchLabels:
10+
app: pinnwand-lovelace
11+
template:
12+
metadata:
13+
labels:
14+
app: pinnwand-lovelace
15+
spec:
16+
initContainers:
17+
- name: init-service
18+
image: busybox:latest
19+
command: ["wget", "https://raw.githubusercontent.com/python-discord/branding/main/logos/badge/badge_512x172.png", "-O", "/tmp/logo.png"]
20+
volumeMounts:
21+
- name: pinnwand-lovelace-logo
22+
mountPath: /tmp/
23+
containers:
24+
- name: pinnwand-lovelace
25+
image: ghcr.io/python-discord/pinnwand:latest-psql
26+
command: ["venv/bin/python3", "-m", "pinnwand", "-vvvvvvvv", "--configuration-path", "/config/config.toml", "http"]
27+
imagePullPolicy: Always
28+
resources:
29+
requests:
30+
cpu: 5m
31+
memory: 100Mi
32+
limits:
33+
cpu: 100m
34+
memory: 200Mi
35+
ports:
36+
- containerPort: 8000
37+
envFrom:
38+
- secretRef:
39+
name: pinnwand-lovelace-postgres-connection
40+
securityContext:
41+
readOnlyRootFilesystem: true
42+
volumeMounts:
43+
- name: pinnwand-lovelace-config
44+
mountPath: /config/
45+
- name: pinnwand-lovelace-logo
46+
mountPath: /usr/app/pinnwand/static/logo.png
47+
subPath: logo.png
48+
volumes:
49+
- name: pinnwand-lovelace-logo
50+
emptyDir: {}
51+
- name: pinnwand-lovelace-config
52+
configMap:
53+
name: pinnwand-lovelace-config
54+
securityContext:
55+
fsGroup: 2000
56+
runAsUser: 1000
57+
runAsNonRoot: true
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: Ingress
3+
metadata:
4+
annotations:
5+
nginx.ingress.kubernetes.io/auth-tls-verify-client: "on"
6+
nginx.ingress.kubernetes.io/auth-tls-secret: "kube-system/mtls-client-crt-bundle"
7+
nginx.ingress.kubernetes.io/auth-tls-error-page: "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
8+
# block HEAD requests
9+
nginx.ingress.kubernetes.io/configuration-snippet: |
10+
if ($request_method = HEAD) {
11+
return 444;
12+
}
13+
name: pinnwand-lovelace
14+
namespace: web
15+
spec:
16+
tls:
17+
- hosts:
18+
- "*.pythondiscord.com"
19+
secretName: pythondiscord.com-tls
20+
rules:
21+
- host: lovelace-paste.pythondiscord.com
22+
http:
23+
paths:
24+
- path: /
25+
pathType: Prefix
26+
backend:
27+
service:
28+
name: pinnwand-lovelace
29+
port:
30+
number: 80
Binary file not shown.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: pinnwand-lovelace
5+
namespace: web
6+
spec:
7+
selector:
8+
app: pinnwand-lovelace
9+
ports:
10+
- protocol: TCP
11+
port: 80
12+
targetPort: 8000

0 commit comments

Comments
 (0)