diff --git a/k8s/apps/ingresses/templates/static-files.yaml b/k8s/apps/ingresses/templates/static-files.yaml new file mode 100644 index 0000000..934827b --- /dev/null +++ b/k8s/apps/ingresses/templates/static-files.yaml @@ -0,0 +1,83 @@ +{{ range $staticFile := .Values.staticFiles.secondaryDomain }} + +{{ $prefix := printf "sec-domain-%s" $staticFile.path }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: "{{$prefix}}-static-files" +data: + index.html: {{ $staticFile.content }} + +--- +apiVersion: v1 +kind: Pod +metadata: + name: "{{$prefix}}-host" + labels: + app: "{{$prefix}}-host" +spec: + volumes: + - name: static-files + configMap: + name: "{{$prefix}}-static-files" + containers: + - name: api + image: caddy:2.7-alpine + command: + - caddy + - file-server + - --root + - /files + - --listen + - 80 + volumeMount: + - mountPath: /files + name: static-files + resources: + limits: + memory: 1Gi + ports: + - containerPort: 80 +--- +kind: Service +apiVersion: v1 +metadata: + name: "{{$prefix}}-static-files" + labels: + app: "{{$prefix}}-static-files" +spec: + selector: + app: "{{$prefix}}-host" + type: ClusterIP + ports: + - name: http + port: 80 + targetPort: 80 +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: "{{$prefix}}-static-files-{{$staticFile.path}}" + annotations: + homelab-ingress/managing-app-namespace: "apps-ingresses" + traefik.ingress.kubernetes.io/router.middlewares: {{ $staticFile.middleware | default "apps-ingresses-https-redirect"}}@kubernetescrd +spec: + rules: + - host: "{{ $.Values.global.secondaryDomain }}" + http: + paths: + - backend: + service: + name: "{{$prefix}}-static-files" + port: + number: 80 + path: "/{{$staticFile.path}}" + pathType: Prefix + {{ if $.Values.global.tls.enabled }} + tls: + - secretName: "tls-{{ $.Values.global.secondaryDomain }}" + hosts: + - "{{ $.Values.global.secondaryDomain }}" + {{ end }} +{{ end }} \ No newline at end of file diff --git a/k8s/apps/ingresses/values-dev.yaml b/k8s/apps/ingresses/values-dev.yaml index c5c25a8..ae63219 100644 --- a/k8s/apps/ingresses/values-dev.yaml +++ b/k8s/apps/ingresses/values-dev.yaml @@ -15,4 +15,10 @@ services: service: "dummy-app" namespace: "apps-ingresses" middleware: "apps-ingresses-forwardauth-authentik" - group: "Demo" \ No newline at end of file + group: "Demo" +staticFiles: + mainDomain: [] + secondaryDomain: + - path: "ads.txt" + content: | + google.com, pub-6915532978483380, DIRECT, f08c47fec0942fa0 \ No newline at end of file diff --git a/k8s/apps/ingresses/values-prod.yaml b/k8s/apps/ingresses/values-prod.yaml index 5b50030..09a593e 100644 --- a/k8s/apps/ingresses/values-prod.yaml +++ b/k8s/apps/ingresses/values-prod.yaml @@ -40,4 +40,11 @@ reverseProxy: group: "Cameras" cloudflare: - enabled: true \ No newline at end of file + enabled: true + +staticFiles: + mainDomain: [] + secondaryDomain: + - suffix: "/ads.txt" + content: | + google.com, pub-6915532978483380, DIRECT, f08c47fec0942fa0 \ No newline at end of file diff --git a/k8s/apps/ingresses/values.yaml b/k8s/apps/ingresses/values.yaml index 588344d..6c17765 100644 --- a/k8s/apps/ingresses/values.yaml +++ b/k8s/apps/ingresses/values.yaml @@ -24,4 +24,7 @@ cloudflare: - "" - ".core" - ".vh" - - ".wa" \ No newline at end of file + - ".wa" +staticFiles: + mainDomain: [] + secondaryDomain: []