Last active
May 23, 2024 18:56
-
-
Save ondrejmo/a6a016effa65a69d65fff210b8107495 to your computer and use it in GitHub Desktop.
Aria2 with RPC for downloading Linux ISOs through Wireguard in a k3s cluster with Cilium.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
apiVersion: networking.k8s.io/v1 | |
kind: NetworkPolicy | |
metadata: | |
name: aria | |
spec: | |
podSelector: | |
matchLabels: | |
app.kubernetes.io/name: aria | |
policyTypes: | |
- Egress | |
egress: | |
- to: | |
- ipBlock: | |
cidr: 123.123.123.123/32 | |
ports: | |
- protocol: UDP | |
port: 51820 | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: aria-config | |
data: | |
aria.conf: | | |
## downloads | |
dir=/data | |
max-concurrent-downloads=8 | |
max-connection-per-server=16 | |
disable-ipv6=true | |
user-agent=User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_8_0) AppleWebKit/5312 (KHTML, like Gecko) Chrome/37.0.821.0 Mobile Safari/5312 | |
disk-cache=0 | |
file-allocation=none | |
console-log-level=info | |
## sessions | |
force-save=true | |
input-file=/data/sessions | |
save-session=/data/sessions | |
save-session-interval=10 | |
## rpc | |
enable-rpc=true | |
rpc-listen-port=6800 | |
rpc-listen-all=true | |
rpc-allow-origin-all=true | |
rpc-secret=changeme | |
## torrents | |
max-upload-limit=16k | |
dht-file-path=/data/dht.dat | |
enable-dht=true | |
seed-time=0 | |
wg0.conf: | | |
[Interface] | |
PrivateKey = k2bLsMBfFgn4DqzwJN/cXWqI0NQml/uer0NeKfB/x5k= | |
Address = 192.168.0.123/32 | |
DNS = 192.168.0.1 | |
# work arround for kube-proxy free cilium | |
PostUp = ip rule add table main to 10.42.0.0/16 | |
[Peer] | |
PublicKey = 4vGWBlflhLdiMKVMC7wowIosCzi9OQrB5VuZ3bQtf/U= | |
AllowedIPs = 0.0.0.0/0 | |
Endpoint = 123.123.123.123:51820 | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: aria | |
spec: | |
# DISCLAIMER: while it is a statefulset, it doesn't need headless svc, not a deployment only because pod name predictability | |
selector: | |
app.kubernetes.io/name: aria | |
ports: | |
- name: rpc | |
port: 6800 | |
--- | |
apiVersion: apps/v1 | |
kind: StatefulSet | |
metadata: | |
name: aria | |
spec: | |
serviceName: aria | |
revisionHistoryLimit: 3 | |
selector: | |
matchLabels: | |
app.kubernetes.io/name: aria | |
template: | |
metadata: | |
labels: | |
app.kubernetes.io/name: aria | |
spec: | |
automountServiceAccountToken: false | |
containers: | |
- name: aria | |
image: registry.home.arpa/infrastructure/aria:v8 | |
resources: | |
requests: | |
cpu: 5m | |
memory: 32Mi | |
ports: | |
- name: rpc | |
containerPort: 6800 | |
volumeMounts: | |
- name: config | |
mountPath: /home/aria/config | |
- name: data02 | |
mountPath: /data | |
subPath: download | |
- name: wireguard | |
image: registry.home.arpa/infrastructure/wireguard:v7 | |
command: [ "/bin/bash", "-c", "--" ] | |
args: [ "wg-quick up /config/wg0.conf; sleep infinity" ] | |
resources: | |
requests: | |
cpu: 5m | |
memory: 32Mi | |
securityContext: | |
capabilities: | |
add: | |
- NET_ADMIN | |
volumeMounts: | |
- name: wg | |
mountPath: /config | |
volumes: | |
- name: config | |
configMap: | |
name: aria-config | |
items: | |
- key: aria.conf | |
path: aria.conf | |
- name: data02 | |
nfs: | |
server: mynas | |
path: /myshare | |
- name: wg | |
configMap: | |
name: aria-config | |
items: | |
- key: wg0.conf | |
path: wg0.conf | |
--- | |
apiVersion: cert-manager.io/v1 | |
kind: Certificate | |
metadata: | |
name: aria | |
spec: | |
commonName: ariang.home.arpa | |
dnsNames: | |
- ariang.home.arpa | |
secretName: aria-certificate | |
issuerRef: | |
name: trusted-ca | |
kind: ClusterIssuer | |
--- | |
apiVersion: traefik.containo.us/v1alpha1 | |
kind: IngressRoute | |
metadata: | |
name: aria | |
annotations: | |
link.argocd.argoproj.io/external-link: https://ariang.home.arpa | |
spec: | |
entryPoints: | |
- websecure | |
routes: | |
- match: Host(`ariang.home.arpa`) && (Path(`/jsonrpc`) || Path(`/rpc`)) | |
kind: Rule | |
services: | |
- name: aria | |
port: 6800 | |
tls: | |
secretName: aria-certificate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM docker.io/library/debian:bookworm-slim | |
ARG UID=1000 | |
ARG GID=1066 | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
ca-certificates \ | |
wget \ | |
aria2 && \ | |
rm -rf /var/lib/apt/lists | |
RUN groupadd -g $GID aria && \ | |
useradd --create-home --home-dir /home/aria --shell /bin/bash -g $GID -u $UID aria && \ | |
touch /home/aria/sessions && \ | |
chmod 0700 /home/aria/sessions && \ | |
chown aria:aria /home/aria/sessions | |
COPY --chown=aria:aria aria.conf /home/aria/config/aria.conf | |
USER aria:aria | |
VOLUME /data | |
EXPOSE 6800/tcp | |
ENTRYPOINT [ "/usr/bin/aria2c" ] | |
CMD [ "--conf-path", "/home/aria/config/aria.conf" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM docker.io/library/debian:bookworm-slim | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
openresolv \ | |
iptables \ | |
iproute2 \ | |
wireguard-tools \ | |
sed && \ | |
rm -rf /var/lib/apt/lists | |
# https://github.com/jordanpotter/docker-wireguard | |
# The net.ipv4.conf.all.src_valid_mark sysctl is set when running the Docker container, so don't have WireGuard also set it | |
RUN sed -i "s:sysctl -q net.ipv4.conf.all.src_valid_mark=1:echo Skipping setting net.ipv4.conf.all.src_valid_mark:" /usr/bin/wg-quick | |
ENTRYPOINT [ "/usr/bin/wg-quick" ] | |
CMD [ "up", "wg0" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment