From 9958d86f5fdf312eac0420934cdb0d923ccad215 Mon Sep 17 00:00:00 2001 From: Joseph Hanson Date: Sun, 14 Jan 2024 22:34:59 -0600 Subject: [PATCH] Adding internal nginx. --- .../external-dns/app/hsn-dev/helmrelease.yaml | 2 +- .../ingress-nginx/internal/certificate.yaml | 16 +++ .../ingress-nginx/internal/helmrelease.yaml | 108 ++++++++++++++++++ .../ingress-nginx/internal/kustomization.yaml | 7 ++ kubernetes/apps/network/ingress-nginx/ks.yaml | 34 +++--- 5 files changed, 149 insertions(+), 18 deletions(-) create mode 100644 kubernetes/apps/network/ingress-nginx/internal/certificate.yaml create mode 100644 kubernetes/apps/network/ingress-nginx/internal/helmrelease.yaml create mode 100644 kubernetes/apps/network/ingress-nginx/internal/kustomization.yaml diff --git a/kubernetes/apps/network/external-dns/app/hsn-dev/helmrelease.yaml b/kubernetes/apps/network/external-dns/app/hsn-dev/helmrelease.yaml index f9a78050..998934da 100644 --- a/kubernetes/apps/network/external-dns/app/hsn-dev/helmrelease.yaml +++ b/kubernetes/apps/network/external-dns/app/hsn-dev/helmrelease.yaml @@ -47,7 +47,7 @@ spec: - --cloudflare-proxied - --crd-source-apiversion=externaldns.k8s.io/v1alpha1 - --crd-source-kind=DNSEndpoint - - --ingress-class=external + - --ingress-class=external-nginx - --txt-owner-id=default serviceMonitor: diff --git a/kubernetes/apps/network/ingress-nginx/internal/certificate.yaml b/kubernetes/apps/network/ingress-nginx/internal/certificate.yaml new file mode 100644 index 00000000..c874b592 --- /dev/null +++ b/kubernetes/apps/network/ingress-nginx/internal/certificate.yaml @@ -0,0 +1,16 @@ +--- +# yaml-language-server: $schema=https://ks.hsn.dev/cert-manager.io/certificate_v1.json +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: "jahanson-tech" + namespace: network +spec: + secretName: "jahanson-tech-tls" + issuerRef: + name: letsencrypt-cloudflare-production + kind: ClusterIssuer + commonName: "jahanson.tech" + dnsNames: + - "jahanson.tech" + - "*.jahanson.tech" diff --git a/kubernetes/apps/network/ingress-nginx/internal/helmrelease.yaml b/kubernetes/apps/network/ingress-nginx/internal/helmrelease.yaml new file mode 100644 index 00000000..0cc88d9b --- /dev/null +++ b/kubernetes/apps/network/ingress-nginx/internal/helmrelease.yaml @@ -0,0 +1,108 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/helmrelease-helm-v2beta2.json +apiVersion: helm.toolkit.fluxcd.io/v2beta2 +kind: HelmRelease +metadata: + name: nginx-internal +spec: + interval: 30m + chart: + spec: + chart: ingress-nginx + version: 4.9.0 + sourceRef: + kind: HelmRepository + name: ingress-nginx + namespace: flux-system + interval: 30m + values: + fullnameOverride: nginx-internal + + controller: + replicaCount: 3 + + updateStrategy: + type: RollingUpdate + + allowSnippetAnnotations: true + enableAnnotationValidations: true + + service: + enabled: true + type: LoadBalancer + annotations: + external-dns.alpha.kubernetes.io/hostname: "internal.jahanson.tech" + io.cilium/lb-ipam-ips: "10.45.0.3" + externalTrafficPolicy: Cluster + + publishService: + enabled: true + + ingressClassResource: + name: internal-nginx + default: true + controllerValue: k8s.io/ingress-nginx-internal + + admissionWebhooks: + objectSelector: + matchExpressions: + - key: ingress-class + operator: In + values: + - internal-nginx + + config: + block-user-agents: "GPTBot,~*GPTBot*,ChatGPT-User,~*ChatGPT-User*,Google-Extended,~*Google-Extended*,CCBot,~*CCBot*,Omgilibot,~*Omgilibot*,FacebookBot,~*FacebookBot*" # taken from https://github.com/superseriousbusiness/gotosocial/blob/main/internal/web/robots.go + client-header-timeout: 120 + client-body-buffer-size: "100M" + client-body-timeout: 120 + enable-brotli: "true" + enable-ocsp: "true" + enable-real-ip: "true" + hide-headers: Server,X-Powered-By + hsts-max-age: "31449600" + keep-alive: 120 + keep-alive-requests: 10000 + log-format-escape-json: "true" + log-format-upstream: > + {"time": "$time_iso8601", "remote_addr": "$proxy_protocol_addr", + "x_forwarded_for": "$proxy_add_x_forwarded_for", "request_id": "$req_id", + "remote_user": "$remote_user", "bytes_sent": $bytes_sent, "request_time": $request_time, + "status": $status, "vhost": "$host", "request_proto": "$server_protocol", + "path": "$uri", "request_query": "$args", "request_length": $request_length, + "duration": $request_time,"method": "$request_method", "http_referrer": "$http_referer", + "http_user_agent": "$http_user_agent"} + proxy-body-size: 0 + proxy-buffer-size: "16k" + ssl-protocols: "TLSv1.3 TLSv1.2" + use-forwarded-headers: "true" + + metrics: + enabled: true + serviceMonitor: + enabled: true + namespace: network + namespaceSelector: + any: true + + extraArgs: + default-ssl-certificate: "network/jahanson-tech-tls" + + topologySpreadConstraints: + - maxSkew: 2 + topologyKey: kubernetes.io/hostname + whenUnsatisfiable: DoNotSchedule + labelSelector: + matchLabels: + app.kubernetes.io/instance: nginx-internal + app.kubernetes.io/component: controller + + resources: + requests: + cpu: 99m + memory: 768Mi + limits: + memory: 768Mi + + defaultBackend: + enabled: false diff --git a/kubernetes/apps/network/ingress-nginx/internal/kustomization.yaml b/kubernetes/apps/network/ingress-nginx/internal/kustomization.yaml new file mode 100644 index 00000000..0a36dcc3 --- /dev/null +++ b/kubernetes/apps/network/ingress-nginx/internal/kustomization.yaml @@ -0,0 +1,7 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/kustomization.json +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./certificate.yaml + - ./helmrelease.yaml diff --git a/kubernetes/apps/network/ingress-nginx/ks.yaml b/kubernetes/apps/network/ingress-nginx/ks.yaml index 7ef0b614..cc1fe108 100644 --- a/kubernetes/apps/network/ingress-nginx/ks.yaml +++ b/kubernetes/apps/network/ingress-nginx/ks.yaml @@ -19,20 +19,20 @@ spec: - name: cluster-apps-cert-manager-issuers --- # yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/kustomization-kustomize-v1.json -# apiVersion: kustomize.toolkit.fluxcd.io/v1 -# kind: Kustomization -# metadata: -# name: cluster-apps-ingress-nginx-peertube -# namespace: flux-system -# labels: -# substitution.flux.home.arpa/enabled: "true" -# spec: -# interval: 10m -# path: "./kubernetes/apps/network/ingress-nginx/peertube" -# prune: true -# sourceRef: -# kind: GitRepository -# name: homelab -# wait: true -# dependsOn: -# - name: cluster-apps-cert-manager-issuers +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: cluster-apps-ingress-nginx-internal + namespace: flux-system + labels: + substitution.flux.home.arpa/enabled: "true" +spec: + interval: 10m + path: "./kubernetes/apps/network/ingress-nginx/internal" + prune: true + sourceRef: + kind: GitRepository + name: homelab + wait: true + dependsOn: + - name: cluster-apps-cert-manager-issuers