Use common for ingress generation

This commit is contained in:
bom 2022-11-18 10:02:12 +01:00
parent 2eed9ae2df
commit b65e77aa01
6 changed files with 13 additions and 105 deletions

View file

@ -45,8 +45,7 @@
(website/generate-nginx-configmap (flatten-and-reduce-config config))
(website/generate-nginx-service (flatten-and-reduce-config config))
(website/generate-website-content-volume (flatten-and-reduce-config config))
(website/generate-website-http-ingress (flatten-and-reduce-config config))
(website/generate-website-https-ingress (flatten-and-reduce-config config))
(website/generate-website-ingress (flatten-and-reduce-config config))
(website/generate-website-certificate (flatten-and-reduce-config config))
(website/generate-website-build-cron (flatten-and-reduce-config config))
(website/generate-website-initial-build-job (flatten-and-reduce-config config))

View file

@ -10,9 +10,8 @@
[dda.c4k-common.common :as cm]
[dda.c4k-common.base64 :as b64]
[dda.c4k-common.predicate :as pred]
[dda.c4k-website.ingress-cert :as ing]
[clojure.string :as str]
[clojure.string :as st]))
[dda.c4k-common.ingress-cert :as ing]
[clojure.string :as str]))
(defn fqdn-list?
[input]
@ -49,13 +48,13 @@
[sha256sum-output string?]
(if (nil? sha256sum-output)
nil
(first (st/split sha256sum-output #"\ +"))))
(first (str/split sha256sum-output #"\ +"))))
(defn-spec get-file-name-from-sha256sum-output string?
[sha256sum-output string?]
(if (nil? sha256sum-output)
nil
(second (st/split (st/trim sha256sum-output) #"\ +"))))
(second (str/split (str/trim sha256sum-output) #"\ +"))))
(defn-spec replace-dots-by-minus string?
[fqdn pred/fqdn-string?]
@ -73,13 +72,9 @@
[unique-name pred/fqdn-string?]
(str (replace-dots-by-minus unique-name) "-cert"))
(defn-spec generate-http-ingress-name string?
(defn-spec generate-ingress-name string?
[unique-name pred/fqdn-string?]
(str (replace-dots-by-minus unique-name) "-http-ingress"))
(defn-spec generate-https-ingress-name string?
[unique-name pred/fqdn-string?]
(str (replace-dots-by-minus unique-name) "-https-ingress"))
(str (replace-dots-by-minus unique-name) "-ingress"))
; https://your.gitea.host/api/v1/repos/<owner>/<repo>/archive/main.zip
(defn-spec make-gitrepourl string?
@ -111,24 +106,14 @@
"website/website-content-volume.yaml" (rc/inline "website/website-content-volume.yaml")
(throw (js/Error. "Undefined Resource!")))))
(defn-spec generate-website-http-ingress pred/map-or-seq?
(defn-spec generate-website-ingress pred/map-or-seq?
[config flattened-and-reduced-config?]
(let [{:keys [unique-name fqdns]} config]
(ing/generate-http-ingress {:fqdns fqdns
:app-name (generate-app-name unique-name)
:ingress-name (generate-http-ingress-name unique-name)
:service-name (generate-service-name unique-name)
:service-port 80})))
(defn-spec generate-website-https-ingress pred/map-or-seq?
[config flattened-and-reduced-config?]
(let [{:keys [unique-name fqdns]} config]
(ing/generate-https-ingress {:fqdns fqdns
:cert-name (generate-cert-name unique-name)
:app-name (generate-app-name unique-name)
:ingress-name (generate-https-ingress-name unique-name)
:service-name (generate-service-name unique-name)
:service-port 80})))
(ing/generate-ingress {:fqdns fqdns
:app-name (generate-app-name unique-name)
:ingress-name (generate-ingress-name unique-name)
:service-name (generate-service-name unique-name)
:service-port 80})))
(defn-spec generate-website-certificate pred/map-or-seq?
[config flattened-and-reduced-config?]

View file

@ -1,18 +0,0 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: c4k-common-cert
labels:
app.kubernetes.part-of: c4k-common-app
namespace: default
spec:
secretName: c4k-common-cert
commonName: FQDN
duration: 2160h # 90d
renewBefore: 360h # 15d
dnsNames:
- FQDN
issuerRef:
name: staging
kind: ClusterIssuer

View file

@ -1,10 +0,0 @@
host: FQDN
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: SERVICE_NAME
port:
number: SERVICE_PORT

View file

@ -1,22 +0,0 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: c4k-common-http-ingress
namespace: default
labels:
app.kubernetes.part-of: c4k-common-app
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: web
traefik.ingress.kubernetes.io/router.middlewares: default-redirect-https@kubernetescrd
spec:
rules:
- host: FQDN
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: SERVICE_NAME
port:
number: 80

View file

@ -1,26 +0,0 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: c4k-common-https-ingress
namespace: default
labels:
app.kubernetes.part-of: c4k-common-app
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: websecure
traefik.ingress.kubernetes.io/router.tls: "true"
spec:
tls:
- hosts:
- FQDN
secretName: c4k-common-cert
rules:
- host: FQDN
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: SERVICE_NAME
port:
number: 80