Use common for ingress generation
This commit is contained in:
parent
2eed9ae2df
commit
b65e77aa01
6 changed files with 13 additions and 105 deletions
|
@ -45,8 +45,7 @@
|
||||||
(website/generate-nginx-configmap (flatten-and-reduce-config config))
|
(website/generate-nginx-configmap (flatten-and-reduce-config config))
|
||||||
(website/generate-nginx-service (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-content-volume (flatten-and-reduce-config config))
|
||||||
(website/generate-website-http-ingress (flatten-and-reduce-config config))
|
(website/generate-website-ingress (flatten-and-reduce-config config))
|
||||||
(website/generate-website-https-ingress (flatten-and-reduce-config config))
|
|
||||||
(website/generate-website-certificate (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-build-cron (flatten-and-reduce-config config))
|
||||||
(website/generate-website-initial-build-job (flatten-and-reduce-config config))
|
(website/generate-website-initial-build-job (flatten-and-reduce-config config))
|
||||||
|
|
|
@ -10,9 +10,8 @@
|
||||||
[dda.c4k-common.common :as cm]
|
[dda.c4k-common.common :as cm]
|
||||||
[dda.c4k-common.base64 :as b64]
|
[dda.c4k-common.base64 :as b64]
|
||||||
[dda.c4k-common.predicate :as pred]
|
[dda.c4k-common.predicate :as pred]
|
||||||
[dda.c4k-website.ingress-cert :as ing]
|
[dda.c4k-common.ingress-cert :as ing]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]))
|
||||||
[clojure.string :as st]))
|
|
||||||
|
|
||||||
(defn fqdn-list?
|
(defn fqdn-list?
|
||||||
[input]
|
[input]
|
||||||
|
@ -49,13 +48,13 @@
|
||||||
[sha256sum-output string?]
|
[sha256sum-output string?]
|
||||||
(if (nil? sha256sum-output)
|
(if (nil? sha256sum-output)
|
||||||
nil
|
nil
|
||||||
(first (st/split sha256sum-output #"\ +"))))
|
(first (str/split sha256sum-output #"\ +"))))
|
||||||
|
|
||||||
(defn-spec get-file-name-from-sha256sum-output string?
|
(defn-spec get-file-name-from-sha256sum-output string?
|
||||||
[sha256sum-output string?]
|
[sha256sum-output string?]
|
||||||
(if (nil? sha256sum-output)
|
(if (nil? sha256sum-output)
|
||||||
nil
|
nil
|
||||||
(second (st/split (st/trim sha256sum-output) #"\ +"))))
|
(second (str/split (str/trim sha256sum-output) #"\ +"))))
|
||||||
|
|
||||||
(defn-spec replace-dots-by-minus string?
|
(defn-spec replace-dots-by-minus string?
|
||||||
[fqdn pred/fqdn-string?]
|
[fqdn pred/fqdn-string?]
|
||||||
|
@ -73,13 +72,9 @@
|
||||||
[unique-name pred/fqdn-string?]
|
[unique-name pred/fqdn-string?]
|
||||||
(str (replace-dots-by-minus unique-name) "-cert"))
|
(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?]
|
[unique-name pred/fqdn-string?]
|
||||||
(str (replace-dots-by-minus unique-name) "-http-ingress"))
|
(str (replace-dots-by-minus unique-name) "-ingress"))
|
||||||
|
|
||||||
(defn-spec generate-https-ingress-name string?
|
|
||||||
[unique-name pred/fqdn-string?]
|
|
||||||
(str (replace-dots-by-minus unique-name) "-https-ingress"))
|
|
||||||
|
|
||||||
; https://your.gitea.host/api/v1/repos/<owner>/<repo>/archive/main.zip
|
; https://your.gitea.host/api/v1/repos/<owner>/<repo>/archive/main.zip
|
||||||
(defn-spec make-gitrepourl string?
|
(defn-spec make-gitrepourl string?
|
||||||
|
@ -111,24 +106,14 @@
|
||||||
"website/website-content-volume.yaml" (rc/inline "website/website-content-volume.yaml")
|
"website/website-content-volume.yaml" (rc/inline "website/website-content-volume.yaml")
|
||||||
(throw (js/Error. "Undefined Resource!")))))
|
(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?]
|
[config flattened-and-reduced-config?]
|
||||||
(let [{:keys [unique-name fqdns]} config]
|
(let [{:keys [unique-name fqdns]} config]
|
||||||
(ing/generate-http-ingress {:fqdns fqdns
|
(ing/generate-ingress {:fqdns fqdns
|
||||||
:app-name (generate-app-name unique-name)
|
:app-name (generate-app-name unique-name)
|
||||||
:ingress-name (generate-http-ingress-name unique-name)
|
:ingress-name (generate-ingress-name unique-name)
|
||||||
:service-name (generate-service-name unique-name)
|
:service-name (generate-service-name unique-name)
|
||||||
:service-port 80})))
|
: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})))
|
|
||||||
|
|
||||||
(defn-spec generate-website-certificate pred/map-or-seq?
|
(defn-spec generate-website-certificate pred/map-or-seq?
|
||||||
[config flattened-and-reduced-config?]
|
[config flattened-and-reduced-config?]
|
||||||
|
|
|
@ -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
|
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
host: FQDN
|
|
||||||
http:
|
|
||||||
paths:
|
|
||||||
- pathType: Prefix
|
|
||||||
path: "/"
|
|
||||||
backend:
|
|
||||||
service:
|
|
||||||
name: SERVICE_NAME
|
|
||||||
port:
|
|
||||||
number: SERVICE_PORT
|
|
|
@ -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
|
|
|
@ -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
|
|
Loading…
Reference in a new issue