From 5067df0901cecedd1355de74aa0b1dd5ea30c861 Mon Sep 17 00:00:00 2001 From: James Andariese Date: Thu, 27 Apr 2023 18:53:09 -0500 Subject: [PATCH] add ytmd --- ytmd/deployment.yaml | 24 ++++++++++++++++++++ ytmd/docker-compose.yaml | 49 ++++++++++++++++++++++++++++++++++++++++ ytmd/ingress.yaml | 24 ++++++++++++++++++++ ytmd/ns.yaml | 4 ++++ ytmd/svc.yaml | 17 ++++++++++++++ 5 files changed, 118 insertions(+) create mode 100644 ytmd/deployment.yaml create mode 100644 ytmd/docker-compose.yaml create mode 100644 ytmd/ingress.yaml create mode 100644 ytmd/ns.yaml create mode 100644 ytmd/svc.yaml diff --git a/ytmd/deployment.yaml b/ytmd/deployment.yaml new file mode 100644 index 0000000..2a4e91d --- /dev/null +++ b/ytmd/deployment.yaml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: ytmd + name: ytmd +spec: + replicas: 1 + selector: + matchLabels: + app: ytmd + strategy: + type: Recreate + template: + metadata: + labels: + app: ytmd + spec: + containers: + - env: + - name: HOST + value: 0.0.0.0 + image: ghcr.io/jamesandariese/ytmd-api:main + name: ytmd + restartPolicy: Always diff --git a/ytmd/docker-compose.yaml b/ytmd/docker-compose.yaml new file mode 100644 index 0000000..133b359 --- /dev/null +++ b/ytmd/docker-compose.yaml @@ -0,0 +1,49 @@ +# cloudflared tunnel create ytmd +# cloudflared tunnel route dns ytmd ytmd.strudelline.net +# cp ~/.cloudflared/*.json /Volumes/webdav.strudelline.net/docker-compose-mounts/cloudflared +# +# grab the tunnel-id that's output from the first two commands and open this file again +# add the tunnel-id to TUNNELID below + + +version: '3' + +volumes: + config: {} + +services: + main: + image: ghcr.io/jamesandariese/ytmd-api:main + restart: always + environment: + - "HOST=127.0.0.1" + cloudflared-configurator: + image: debian:11 + environment: + - TUNNELID=4f3aba1c-c226-4e14-800f-ad4b8d30dc60 + - HOST=ytmd.strudelline.net + - SVCPORT=8000 + command: + - bash + - -c + - | + cat /cloudflared/$${TUNNELID}.json > /config/tunnel.json + cat << EOF > /config/cloudflared.yaml + tunnel: $${TUNNELID} + credentials-file: /config/tunnel.json + ingress: + - hostname: ytmd.strudelline.net + service: http://localhost:$${SVCPORT} + - service: http_status:404 + EOF + volumes: + - /volume1/docker-compose-mounts/cloudflared:/cloudflared + - config:/config + cloudflared: + image: cloudflare/cloudflared:latest + restart: always + depends_on: {"cloudflared-configurator": {"condition": "service_completed_successfully"}} + volumes: + - config:/config + command: tunnel --config /config/cloudflared.yaml run + network_mode: service:main diff --git a/ytmd/ingress.yaml b/ytmd/ingress.yaml new file mode 100644 index 0000000..799a6e9 --- /dev/null +++ b/ytmd/ingress.yaml @@ -0,0 +1,24 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ytmd + namespace: ytmd + annotations: + haproxy-ingress.github.io/ssl-redirect: "true" +spec: + ingressClassName: haproxy + rules: + - host: ytmd.strudelline.net + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: ytmd + port: + number: 8000 + tls: + - hosts: + - ytmd.strudelline.net + secretName: wildcard-tls diff --git a/ytmd/ns.yaml b/ytmd/ns.yaml new file mode 100644 index 0000000..376a457 --- /dev/null +++ b/ytmd/ns.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: ytmd diff --git a/ytmd/svc.yaml b/ytmd/svc.yaml new file mode 100644 index 0000000..006a9b9 --- /dev/null +++ b/ytmd/svc.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: ytmd + name: ytmd + namespace: ytmd +spec: + selector: + app: ytmd + ports: + - name: http + port: 8000 + protocol: TCP + targetPort: 8000 + clusterIP: None + type: ClusterIP