From 3478add5380745251840f2fbb45e485a5f43a67f Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 4 Feb 2022 16:29:54 +0100 Subject: [PATCH] wip ingress-type --- src/main/cljc/dda/c4k_shynet/core.cljc | 9 ++++----- src/main/cljc/dda/c4k_shynet/shynet.cljc | 13 ++++++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/cljc/dda/c4k_shynet/core.cljc b/src/main/cljc/dda/c4k_shynet/core.cljc index d6258aa..d0d5a63 100644 --- a/src/main/cljc/dda/c4k_shynet/core.cljc +++ b/src/main/cljc/dda/c4k_shynet/core.cljc @@ -11,7 +11,7 @@ (def config-defaults {:issuer :staging}) (def config? (s/keys :req-un [::shynet/fqdn] - :opt-un [::shynet/issuer ::postgres/postgres-data-volume-path])) + :opt-un [::shynet/issuer ::shynet/ingress-type])) (def auth? (s/keys :req-un [::shynet/django-secret-key ::postgres/postgres-db-user ::postgres/postgres-db-password])) @@ -21,10 +21,9 @@ [] (concat [(yaml/to-string (postgres/generate-config {:postgres-size :2gb :db-name "shynet"})) - (yaml/to-string (postgres/generate-secret config))] - (when (contains? config :postgres-data-volume-path) - [(yaml/to-string (postgres/generate-persistent-volume config))]) - [(yaml/to-string (postgres/generate-pvc)) + (yaml/to-string (postgres/generate-secret config)) + (yaml/to-string (postgres/generate-persistent-volume {:postgres-data-volume-path "/var/postgres"})) + (yaml/to-string (postgres/generate-pvc)) (yaml/to-string (postgres/generate-deployment :postgres-image "postgres:14")) (yaml/to-string (postgres/generate-service))] [(yaml/to-string (shynet/generate-secret config)) diff --git a/src/main/cljc/dda/c4k_shynet/shynet.cljc b/src/main/cljc/dda/c4k_shynet/shynet.cljc index e3b9b3b..e5e708b 100644 --- a/src/main/cljc/dda/c4k_shynet/shynet.cljc +++ b/src/main/cljc/dda/c4k_shynet/shynet.cljc @@ -10,6 +10,11 @@ (s/def ::issuer pred/letsencrypt-issuer?) (s/def ::django-secret-key pred/bash-env-string?) +(defn ingress-type? + [input] + (contains? #{:traefik :default} input)) + +(s/def ::ingress-type ingress-type?) #?(:cljs (defmethod yaml/load-resource :shynet [resource-name] @@ -54,12 +59,14 @@ (cm/replace-all-matching-values-by-new-value "shynet-application" shynet-application)))) (defn generate-ingress [config] - (let [{:keys [fqdn issuer] - :or {issuer :staging}} config - letsencrypt-issuer (str "letsencrypt-" (name issuer) "-issuer")] + (let [{:keys [fqdn issuer ingress-type] + :or {issuer :staging ingress-type :default}} config + letsencrypt-issuer (str "letsencrypt-" (name issuer) "-issuer") + ingress-kind (if (= :default ingress-type) "" (name ingress-type))] (-> (yaml/from-string (yaml/load-resource "shynet/ingress.yaml")) (assoc-in [:metadata :annotations :cert-manager.io/cluster-issuer] letsencrypt-issuer) + (assoc-in [:metadata :annotations :kubernetes.io/ingress.class] ingress-kind) (cm/replace-all-matching-values-by-new-value "fqdn" fqdn)))) (defn generate-statefulset []