added basic generate methods in core

This commit is contained in:
bom 2022-02-09 11:06:40 +01:00
parent 3ec97d7d40
commit 8d46290e55

View file

@ -26,52 +26,42 @@
"jitsi/web-service.yaml" (rc/inline "jitsi/web-service.yaml") "jitsi/web-service.yaml" (rc/inline "jitsi/web-service.yaml")
(throw (js/Error. "Undefined Resource!"))))) (throw (js/Error. "Undefined Resource!")))))
(defn generate-secret [config] (defn generate-jicofo-deployment [config]
(let [{:keys [fqdn django-secret-key postgres-db-user postgres-db-password]} config]
(-> (->
(yaml/from-string (yaml/load-resource "jitsi/secret.yaml")) (yaml/from-string (yaml/load-resource "jitsi/jicofo-deployment.yaml"))))
; See comment in secret.yaml
;(assoc-in [:stringData :ALLOWED_HOSTS] fqdn)
(assoc-in [:stringData :DJANGO_SECRET_KEY] django-secret-key)
(assoc-in [:stringData :DB_USER] postgres-db-user)
(assoc-in [:stringData :DB_PASSWORD] postgres-db-password))))
(defn generate-certificate [config] (defn generate-jicofo-pvc []
(let [{:keys [fqdn issuer]} config (yaml/from-string (yaml/load-resource "jitsi/jicofo-pvc.yaml")))
letsencrypt-issuer (str "letsencrypt-" (name issuer) "-issuer")]
(defn generate-jvb-deployment [config]
(-> (->
(yaml/from-string (yaml/load-resource "jitsi/certificate.yaml")) (yaml/from-string (yaml/load-resource "jitsi/jvb-deployment.yaml"))))
(assoc-in [:spec :commonName] fqdn)
(assoc-in [:spec :dnsNames] [fqdn])
(assoc-in [:spec :issuerRef :name] letsencrypt-issuer))))
(defn generate-webserver-deployment [] (defn generate-jvb-pvc []
(let [jitsi-application "jitsi-webserver"] (yaml/from-string (yaml/load-resource "jitsi/jvb-pvc.yaml")))
(-> (yaml/from-string (yaml/load-resource "jitsi/deployments.yaml"))
(cm/replace-all-matching-values-by-new-value "jitsi-application" jitsi-application)
(update-in [:spec :template :spec :containers 0] dissoc :command))))
(defn generate-celeryworker-deployment [] (defn generate-jvb-service []
(let [jitsi-application "jitsi-celeryworker"] (yaml/from-string (yaml/load-resource "jitsi/jvb-service.yaml")))
(-> (yaml/from-string (yaml/load-resource "jitsi/deployments.yaml"))
(cm/replace-all-matching-values-by-new-value "jitsi-application" jitsi-application))))
(defn generate-ingress [config] (defn generate-networkpolicy []
(let [{:keys [fqdn issuer ingress-type] (yaml/from-string (yaml/load-resource "jitsi/networkpolicy.yaml")))
:or {issuer :staging ingress-type :default}} config
letsencrypt-issuer (str "letsencrypt-" (name issuer) "-issuer") (defn generate-prosody-deployment [config]
ingress-kind (if (= :default ingress-type) "" (name ingress-type))]
(-> (->
(yaml/from-string (yaml/load-resource "jitsi/ingress.yaml")) (yaml/from-string (yaml/load-resource "jitsi/prosody-deployment.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 [] (defn generate-prosody-pvc []
(yaml/from-string (yaml/load-resource "jitsi/statefulset.yaml"))) (yaml/from-string (yaml/load-resource "jitsi/prosody-pvc.yaml")))
(defn generate-service-redis [] (defn generate-prosody-service []
(yaml/from-string (yaml/load-resource "jitsi/service-redis.yaml"))) (yaml/from-string (yaml/load-resource "jitsi/prosody-service.yaml")))
(defn generate-service-webserver [] (defn generate-web-deployment [config]
(yaml/from-string (yaml/load-resource "jitsi/service-webserver.yaml"))) (->
(yaml/from-string (yaml/load-resource "jitsi/web-deployment.yaml"))))
(defn generate-web-pvc []
(yaml/from-string (yaml/load-resource "jitsi/web-pvc.yaml")))
(defn generate-web-service []
(yaml/from-string (yaml/load-resource "jitsi/web-service.yaml")))