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")
(throw (js/Error. "Undefined Resource!")))))
(defn generate-secret [config]
(let [{:keys [fqdn django-secret-key postgres-db-user postgres-db-password]} config]
(defn generate-jicofo-deployment [config]
(->
(yaml/from-string (yaml/load-resource "jitsi/secret.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))))
(yaml/from-string (yaml/load-resource "jitsi/jicofo-deployment.yaml"))))
(defn generate-certificate [config]
(let [{:keys [fqdn issuer]} config
letsencrypt-issuer (str "letsencrypt-" (name issuer) "-issuer")]
(defn generate-jicofo-pvc []
(yaml/from-string (yaml/load-resource "jitsi/jicofo-pvc.yaml")))
(defn generate-jvb-deployment [config]
(->
(yaml/from-string (yaml/load-resource "jitsi/certificate.yaml"))
(assoc-in [:spec :commonName] fqdn)
(assoc-in [:spec :dnsNames] [fqdn])
(assoc-in [:spec :issuerRef :name] letsencrypt-issuer))))
(yaml/from-string (yaml/load-resource "jitsi/jvb-deployment.yaml"))))
(defn generate-webserver-deployment []
(let [jitsi-application "jitsi-webserver"]
(-> (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-jvb-pvc []
(yaml/from-string (yaml/load-resource "jitsi/jvb-pvc.yaml")))
(defn generate-celeryworker-deployment []
(let [jitsi-application "jitsi-celeryworker"]
(-> (yaml/from-string (yaml/load-resource "jitsi/deployments.yaml"))
(cm/replace-all-matching-values-by-new-value "jitsi-application" jitsi-application))))
(defn generate-jvb-service []
(yaml/from-string (yaml/load-resource "jitsi/jvb-service.yaml")))
(defn generate-ingress [config]
(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))]
(defn generate-networkpolicy []
(yaml/from-string (yaml/load-resource "jitsi/networkpolicy.yaml")))
(defn generate-prosody-deployment [config]
(->
(yaml/from-string (yaml/load-resource "jitsi/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))))
(yaml/from-string (yaml/load-resource "jitsi/prosody-deployment.yaml"))))
(defn generate-statefulset []
(yaml/from-string (yaml/load-resource "jitsi/statefulset.yaml")))
(defn generate-prosody-pvc []
(yaml/from-string (yaml/load-resource "jitsi/prosody-pvc.yaml")))
(defn generate-service-redis []
(yaml/from-string (yaml/load-resource "jitsi/service-redis.yaml")))
(defn generate-prosody-service []
(yaml/from-string (yaml/load-resource "jitsi/prosody-service.yaml")))
(defn generate-service-webserver []
(yaml/from-string (yaml/load-resource "jitsi/service-webserver.yaml")))
(defn generate-web-deployment [config]
(->
(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")))