This commit is contained in:
bom 2021-05-21 16:22:00 +02:00
parent 0d2061b37e
commit fabcd711c0
2 changed files with 21 additions and 3 deletions

View file

@ -20,6 +20,13 @@
(defn generate-deployment [] (defn generate-deployment []
(yaml/from-string (yaml/load-resource "deployment.yaml"))) (yaml/from-string (yaml/load-resource "deployment.yaml")))
(defn generate-certificate [config]
(let [{:keys [fqdn issuer]
:or {issuer :staging}} config
letsencrypt-issuer (str "letsencrypt-" (name issuer) "-issuer")]
(->
(yaml/from-string (yaml/load-resource "certificate.yaml"))))
(defn generate-ingress [config] (defn generate-ingress [config]
(let [{:keys [fqdn issuer] (let [{:keys [fqdn issuer]
:or {issuer :staging}} config :or {issuer :staging}} config

View file

@ -12,6 +12,17 @@
:credentials.edn "some-credentials-value\n"}} :credentials.edn "some-credentials-value\n"}}
(cut/generate-config "some-config-value\n" "some-credentials-value\n")))) (cut/generate-config "some-config-value\n" "some-credentials-value\n"))))
(deftest should-generate-certificate
(is (= {:apiVersion "cert-manager.io/v1alpha2"
:kind "Certificate"
:metadata {:name "keycloak-cert", :namespace "default"}
:spec
{:secretName "keycloak-secret"
:commonName "test.de"
:dnsNames ["test.de"]
:issuerRef {:name "letsencrypt-prod-issuer", :kind "ClusterIssuer"}}}
(cut/generate-certificate {:fqdn "test.de" :issuer :prod} ))))
(deftest should-generate-ingress-yaml-with-default-issuer (deftest should-generate-ingress-yaml-with-default-issuer
(is (= {:apiVersion "networking.k8s.io/v1beta1" (is (= {:apiVersion "networking.k8s.io/v1beta1"
:kind "Ingress" :kind "Ingress"
@ -27,8 +38,8 @@
:nginx.ingress.kubernetes.io/proxy-read-timeout "300"} :nginx.ingress.kubernetes.io/proxy-read-timeout "300"}
:namespace "default"} :namespace "default"}
:spec :spec
{:tls '({:hosts ["test.de"] :secretName "keycloak-secret"}) {:tls [{:hosts ["test.de"] :secretName "keycloak-secret"}]
:rules '({:host "test.de", :http {:paths '({:backend {:serviceName "keycloak", :servicePort 8080}})}})}} :rules [{:host "test.de", :http {:paths [{:backend {:serviceName "keycloak", :servicePort 8080}}]}}]}}
(cut/generate-ingress {:fqdn "test.de"})))) (cut/generate-ingress {:fqdn "test.de"}))))
(deftest should-generate-ingress-yaml-with-prod-issuer (deftest should-generate-ingress-yaml-with-prod-issuer
@ -47,6 +58,6 @@
:namespace "default"} :namespace "default"}
:spec :spec
{:tls [{:hosts ["test.de"], :secretName "keycloak-secret"}] {:tls [{:hosts ["test.de"], :secretName "keycloak-secret"}]
:rules '({:host "test.de", :http {:paths '({:backend {:serviceName "keycloak", :servicePort 8080}})}})}} :rules '({:host "test.de", :http {:paths [{:backend {:serviceName "keycloak", :servicePort 8080}}]}})}}
(cut/generate-ingress {:fqdn "test.de" (cut/generate-ingress {:fqdn "test.de"
:issuer :prod})))) :issuer :prod}))))