wip ingress-type

This commit is contained in:
bom 2022-02-04 16:29:54 +01:00
parent f7032aae8b
commit 3478add538
2 changed files with 14 additions and 8 deletions

View file

@ -11,7 +11,7 @@
(def config-defaults {:issuer :staging}) (def config-defaults {:issuer :staging})
(def config? (s/keys :req-un [::shynet/fqdn] (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 (def auth? (s/keys :req-un [::shynet/django-secret-key
::postgres/postgres-db-user ::postgres/postgres-db-password])) ::postgres/postgres-db-user ::postgres/postgres-db-password]))
@ -21,10 +21,9 @@
[] []
(concat (concat
[(yaml/to-string (postgres/generate-config {:postgres-size :2gb :db-name "shynet"})) [(yaml/to-string (postgres/generate-config {:postgres-size :2gb :db-name "shynet"}))
(yaml/to-string (postgres/generate-secret config))] (yaml/to-string (postgres/generate-secret config))
(when (contains? config :postgres-data-volume-path) (yaml/to-string (postgres/generate-persistent-volume {:postgres-data-volume-path "/var/postgres"}))
[(yaml/to-string (postgres/generate-persistent-volume config))]) (yaml/to-string (postgres/generate-pvc))
[(yaml/to-string (postgres/generate-pvc))
(yaml/to-string (postgres/generate-deployment :postgres-image "postgres:14")) (yaml/to-string (postgres/generate-deployment :postgres-image "postgres:14"))
(yaml/to-string (postgres/generate-service))] (yaml/to-string (postgres/generate-service))]
[(yaml/to-string (shynet/generate-secret config)) [(yaml/to-string (shynet/generate-secret config))

View file

@ -10,6 +10,11 @@
(s/def ::issuer pred/letsencrypt-issuer?) (s/def ::issuer pred/letsencrypt-issuer?)
(s/def ::django-secret-key pred/bash-env-string?) (s/def ::django-secret-key pred/bash-env-string?)
(defn ingress-type?
[input]
(contains? #{:traefik :default} input))
(s/def ::ingress-type ingress-type?)
#?(:cljs #?(:cljs
(defmethod yaml/load-resource :shynet [resource-name] (defmethod yaml/load-resource :shynet [resource-name]
@ -54,12 +59,14 @@
(cm/replace-all-matching-values-by-new-value "shynet-application" shynet-application)))) (cm/replace-all-matching-values-by-new-value "shynet-application" shynet-application))))
(defn generate-ingress [config] (defn generate-ingress [config]
(let [{:keys [fqdn issuer] (let [{:keys [fqdn issuer ingress-type]
:or {issuer :staging}} config :or {issuer :staging ingress-type :default}} config
letsencrypt-issuer (str "letsencrypt-" (name issuer) "-issuer")] 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")) (yaml/from-string (yaml/load-resource "shynet/ingress.yaml"))
(assoc-in [:metadata :annotations :cert-manager.io/cluster-issuer] letsencrypt-issuer) (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)))) (cm/replace-all-matching-values-by-new-value "fqdn" fqdn))))
(defn generate-statefulset [] (defn generate-statefulset []