diff --git a/src/main/cljc/dda/c4k_jitsi/core.cljc b/src/main/cljc/dda/c4k_jitsi/core.cljc index 5bcc234..535cb7b 100644 --- a/src/main/cljc/dda/c4k_jitsi/core.cljc +++ b/src/main/cljc/dda/c4k_jitsi/core.cljc @@ -5,6 +5,7 @@ :cljs [orchestra.core :refer-macros [defn-spec]]) [dda.c4k-common.common :as cm] [dda.c4k-common.predicate :as cp] + [dda.c4k-common.ingress :as ing] [dda.c4k-common.monitoring :as mon] [dda.c4k-common.yaml :as yaml] [dda.c4k-jitsi.jitsi :as jitsi] @@ -37,19 +38,29 @@ (jitsi/jitsi-config resolved-config) (jitsi/jicofo-config resolved-config) (jitsi/web-config resolved-config) + (jitsi/jvb-config resolved-config) (jitsi/jibri-config resolved-config) - ;; [(jitsi/generate-jvb-service config) - ;; (jitsi/generate-web-service config) - ;; (jitsi/generate-etherpad-service config) - ;; (jitsi/generate-excalidraw-backend-service config) - ;; (jitsi/generate-modelector-service config) - ;; (jitsi/generate-deployment config) - ;; (jitsi/generate-excalidraw-deployment config) - ;; (jitsi/generate-modelector-deployment config)] - ;; (jitsi/generate-ingress-web config) - ;; (jitsi/generate-ingress-etherpad config) - ;; (jitsi/generate-ingress-excalidraw-backend config) - ;; (jitsi/generate-ingress-modelector config) + (jitsi/etherpad resolved-config) + (ing/generate-ingress-and-cert (merge + {:service-name "jitsi-meet-web" + :service-port 80 + :fqdns [(:fqdn resolved-config)]} + resolved-config)) + (ing/generate-ingress-and-cert (merge + {:service-name "etherpad" + :service-port 9001 + :fqdns [(str "etherpad." (:fqdn resolved-config))]} + resolved-config)) + (ing/generate-ingress-and-cert (merge + {:service-name "excalidraw" + :service-port 3002 + :fqdns [(str "excalidraw." (:fqdn resolved-config))]} + resolved-config)) + (ing/generate-ingress-and-cert (merge + {:service-name "moderator-elector" + :service-port 80 + :fqdns [(str "moderator-elector." (:fqdn resolved-config))]} + resolved-config)) (when (:contains? resolved-config :mon-cfg) (mon/generate-config))))))) @@ -62,6 +73,5 @@ #(not (nil? %)) (cm/concat-vec (jitsi/prosody-auth config auth) - ;[(jitsi/generate-secret-jitsi config auth)] (when (:contains? config :mon-cfg) (mon/generate-auth (:mon-cfg config) (:mon-auth auth)))))))) diff --git a/src/main/cljc/dda/c4k_jitsi/jitsi.cljc b/src/main/cljc/dda/c4k_jitsi/jitsi.cljc index d1a9956..6d0e39b 100644 --- a/src/main/cljc/dda/c4k_jitsi/jitsi.cljc +++ b/src/main/cljc/dda/c4k_jitsi/jitsi.cljc @@ -5,7 +5,6 @@ :cljs [orchestra.core :refer-macros [defn-spec]]) [dda.c4k-common.yaml :as yaml] [dda.c4k-common.common :as cm] - [dda.c4k-common.ingress :as ing] [dda.c4k-common.base64 :as b64] [dda.c4k-common.predicate :as cp] #?(:cljs [dda.c4k-common.macros :refer-macros [inline-resources]]))) @@ -28,116 +27,6 @@ (defmethod yaml/load-resource :jitsi [resource-name] (get (inline-resources "jitsi") resource-name))) -(defn-spec generate-ingress-web cp/map-or-seq? - [config config?] - (ing/generate-ingress-and-cert - (merge - {:service-name "web" - :service-port 80 - :fqdns [(:fqdn config)]} - config))) - -(defn-spec generate-ingress-etherpad cp/map-or-seq? - [config config?] - (ing/generate-ingress-and-cert - (merge - {:service-name "etherpad" - :service-port 9001 - :fqdns [(str "etherpad." (:fqdn config))]} - config))) - -(defn-spec generate-ingress-excalidraw-backend cp/map-or-seq? - [config config?] - (ing/generate-ingress-and-cert - (merge - {:service-name "excalidraw-backend" - :service-port 3002 - :fqdns [(str "excalidraw-backend." (:fqdn config))]} - config))) - -(defn-spec generate-ingress-modelector cp/map-or-seq? - [config config?] - (ing/generate-ingress-and-cert - (merge - {:service-name "modelector" - :service-port 80 - :fqdns [(str "modelector." (:fqdn config))]} - config))) - -(defn-spec generate-secret-jitsi cp/map-or-seq? - [config config? - auth auth?] - (let [{:keys [namespace]} config - {:keys [jvb-auth-password jicofo-auth-password jicofo-component-secret]} auth] - (-> - (yaml/from-string (yaml/load-resource "jitsi/secret.yaml")) - (cm/replace-all-matching "NAMESPACE" namespace) - (cm/replace-key-value :JVB_AUTH_PASSWORD (b64/encode jvb-auth-password)) - (cm/replace-key-value :JICOFO_AUTH_PASSWORD (b64/encode jicofo-auth-password)) - (cm/replace-key-value :JICOFO_COMPONENT_SECRET (b64/encode jicofo-component-secret))))) - -(defn-spec generate-jvb-service cp/map-or-seq? - [config config?] - (let [{:keys [namespace]} config] - (-> - (yaml/from-string (yaml/load-resource "jitsi/jvb-service.yaml")) - (cm/replace-all-matching "NAMESPACE" namespace)))) - -(defn-spec generate-web-service cp/map-or-seq? - [config config?] - (let [{:keys [namespace]} config] - (-> - (yaml/load-as-edn "jitsi/web-service.yaml") - (cm/replace-all-matching "NAMESPACE" namespace)))) - -(defn-spec generate-etherpad-service cp/map-or-seq? - [config config?] - (let [{:keys [namespace]} config] - (-> - (yaml/load-as-edn "jitsi/etherpad-service.yaml") - (cm/replace-all-matching "NAMESPACE" namespace)))) - -(defn-spec generate-excalidraw-backend-service cp/map-or-seq? - [config config?] - (let [{:keys [namespace]} config] - (-> - (yaml/load-as-edn "jitsi/excalidraw-backend-service.yaml") - (cm/replace-all-matching "NAMESPACE" namespace)))) - -(defn-spec generate-modelector-service cp/map-or-seq? - [config config?] - (let [{:keys [namespace]} config] - (-> - (yaml/load-as-edn "jitsi/modelector-service.yaml") - (cm/replace-all-matching "NAMESPACE" namespace)))) - -(defn-spec generate-deployment cp/map-or-seq? - [config config?] - (let [{:keys [fqdn namespace]} config] - (-> - (yaml/load-as-edn "jitsi/deployment.yaml") - (cm/replace-all-matching "REPLACE_JITSI_FQDN" fqdn) - (cm/replace-all-matching "NAMESPACE" namespace) - (cm/replace-all-matching "REPLACE_ETHERPAD_URL" - (str "https://etherpad." fqdn "/p/")) - - (cm/replace-all-matching "REPLACE_EXCALIDRAW_BACKEND_URL" - (str "https://excalidraw-backend." fqdn))))) - -(defn-spec generate-excalidraw-deployment cp/map-or-seq? - [config config?] - (let [{:keys [fqdn namespace]} config] - (-> - (yaml/load-as-edn "jitsi/excalidraw-deployment.yaml") - (cm/replace-all-matching "NAMESPACE" namespace)))) - -(defn-spec generate-modelector-deployment cp/map-or-seq? - [config config?] - (let [{:keys [fqdn namespace]} config] - (-> - (yaml/load-as-edn "jitsi/modelector-deployment.yaml") - (cm/replace-all-matching "NAMESPACE" namespace)))) - (defn- load-and-adjust-namespace [file namespace] (-> @@ -196,11 +85,26 @@ (load-and-adjust-namespace "jitsi/web-config-init-cm.yaml" namespace) (-> (load-and-adjust-namespace "jitsi/web-config-envs-cm.yaml" namespace) - (cm/replace-key-value :XMPP_BOSH_URL_BASE (str "http://prosody." namespace ".svc.cluster.local:5280"))) + (cm/replace-key-value :XMPP_BOSH_URL_BASE (str "http://prosody." namespace ".svc.cluster.local:5280")) + (cm/replace-key-value :ETHERPAD_PUBLIC_URL (str "https://etherpad." fqdn "/p/")) + (cm/replace-key-value :WHITEBOARD_COLLAB_SERVER_PUBLIC_URL (str "https://excalidraw." fqdn)) + ) (load-and-adjust-namespace "jitsi/web-config-service.yaml" namespace) (load-and-adjust-namespace "jitsi/web-config-deployment.yaml" namespace) (load-and-adjust-namespace "jitsi/web-config-test-deployment.yaml" namespace)])) +(defn-spec jvb-config cp/map-or-seq? + [config config?] + (let [{:keys [fqdn namespace]} config] + [(-> + (load-and-adjust-namespace "jitsi/jvb-config-envs-cm.yaml" namespace) + (cm/replace-key-value :XMPP_SERVER (str "prosody." namespace ".svc.cluster.local"))) + (load-and-adjust-namespace "jitsi/jvb-config-service.yaml" namespace) + (-> + (load-and-adjust-namespace "jitsi/jvb-config-deployment.yaml" namespace) + (cm/replace-all-matching "REPLACE_JITSI_FQDN" fqdn) + )])) + (defn-spec jibri-config cp/map-or-seq? [config config?] (let [{:keys [fqdn namespace]} config] @@ -212,3 +116,37 @@ (load-and-adjust-namespace "jitsi/jibri-config-init-cm.yaml" namespace) (load-and-adjust-namespace "jitsi/jibri-config-service.yaml" namespace) (load-and-adjust-namespace "jitsi/jibri-config-deployment.yaml" namespace)])) + +(defn-spec etherpad-config cp/map-or-seq? + [config config?] + (let [{:keys [namespace]} config] + [(load-and-adjust-namespace "jitsi/etherpad-config-service.yaml" namespace) + (load-and-adjust-namespace "jitsi/etherpad-config-deployment.yaml" namespace)])) + +(defn-spec generate-excalidraw-backend-service cp/map-or-seq? + [config config?] + (let [{:keys [namespace]} config] + (-> + (yaml/load-as-edn "jitsi/excalidraw-backend-service.yaml") + (cm/replace-all-matching "NAMESPACE" namespace)))) + +(defn-spec generate-modelector-service cp/map-or-seq? + [config config?] + (let [{:keys [namespace]} config] + (-> + (yaml/load-as-edn "jitsi/modelector-service.yaml") + (cm/replace-all-matching "NAMESPACE" namespace)))) + +(defn-spec generate-excalidraw-deployment cp/map-or-seq? + [config config?] + (let [{:keys [fqdn namespace]} config] + (-> + (yaml/load-as-edn "jitsi/excalidraw-deployment.yaml") + (cm/replace-all-matching "NAMESPACE" namespace)))) + +(defn-spec generate-modelector-deployment cp/map-or-seq? + [config config?] + (let [{:keys [fqdn namespace]} config] + (-> + (yaml/load-as-edn "jitsi/modelector-deployment.yaml") + (cm/replace-all-matching "NAMESPACE" namespace)))) diff --git a/src/main/resources/jitsi/etherpad-config-deployment.yaml b/src/main/resources/jitsi/etherpad-config-deployment.yaml new file mode 100644 index 0000000..4b75072 --- /dev/null +++ b/src/main/resources/jitsi/etherpad-config-deployment.yaml @@ -0,0 +1,20 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: etherpad + namespace: NAMESPACE + labels: + app.kubernetes.io/name: etherpad +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: etherpad + template: + metadata: + labels: + app.kubernetes.io/name: etherpad + spec: + containers: + - name: etherpad + image: etherpad/etherpad:2 \ No newline at end of file diff --git a/src/main/resources/jitsi/etherpad-config-service.yaml b/src/main/resources/jitsi/etherpad-config-service.yaml new file mode 100644 index 0000000..827e064 --- /dev/null +++ b/src/main/resources/jitsi/etherpad-config-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: etherpad + namespace: NAMESPACE + labels: + app.kubernetes.io/name: etherpad +spec: + ports: + - name: etherpad + port: 9001 + targetPort: 9001 + selector: + app.kubernetes.io/name: etherpad \ No newline at end of file diff --git a/src/main/resources/jitsi/jvb-config-deployment.yaml b/src/main/resources/jitsi/jvb-config-deployment.yaml new file mode 100644 index 0000000..cc3954e --- /dev/null +++ b/src/main/resources/jitsi/jvb-config-deployment.yaml @@ -0,0 +1,62 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: NAMESPACE + name: jitsi-meet-jvb + labels: + app.kubernetes.io/name: jitsi-meet + app.kubernetes.io/component: jvb +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: jitsi-meet + app.kubernetes.io/component: jvb + template: + metadata: + labels: + app.kubernetes.io/name: jitsi-meet + app.kubernetes.io/component: jvb + spec: + serviceAccountName: jitsi-meet + securityContext: + {} + containers: + - name: jitsi-meet + securityContext: + {} + image: "jitsi/jvb:stable-9646" + imagePullPolicy: IfNotPresent + envFrom: + - secretRef: + name: prosody-jvb + - configMapRef: + name: prosody-common + - configMapRef: + name: jitsi-meet-jvb + env: + - name: DOCKER_HOST_ADDRESS + value: REPLACE_JITSI_FQDN + - name: JVB_ADVERTISE_IPS + value: REPLACE_JITSI_FQDN + - name: JVB_WS_SERVER_ID + valueFrom: + fieldRef: + fieldPath: status.podIP + ports: + - name: rtp-udp + containerPort: 10000 + protocol: UDP + - name: colibri-ws-tcp + containerPort: 9090 + protocol: TCP + livenessProbe: + httpGet: + path: /about/health + port: 8080 + readinessProbe: + httpGet: + path: /about/health + port: 8080 + resources: + {} diff --git a/src/main/resources/jitsi/jvb-config-envs-cm.yaml b/src/main/resources/jitsi/jvb-config-envs-cm.yaml new file mode 100644 index 0000000..17602ea --- /dev/null +++ b/src/main/resources/jitsi/jvb-config-envs-cm.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: NAMESPACE + name: jitsi-meet-jvb + labels: + app.kubernetes.io/name: jitsi-meet + app.kubernetes.io/component: jvb +data: + JVB_BREWERY_MUC: 'jvbbrewery' + JVB_PORT: '10000' + JVB_STUN_SERVERS: 'meet-jit-si-turnrelay.jitsi.net:443' + JVB_TCP_HARVESTER_DISABLED: '1' + XMPP_SERVER: REPLACE_ME + COLIBRI_REST_ENABLED: 'true' diff --git a/src/main/resources/jitsi/jvb-config-service.yaml b/src/main/resources/jitsi/jvb-config-service.yaml new file mode 100644 index 0000000..fb5f0f6 --- /dev/null +++ b/src/main/resources/jitsi/jvb-config-service.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Service +metadata: + namespace: NAMESPACE + name: jitsi-meet-jvb + labels: + app.kubernetes.io/name: jitsi-meet + app.kubernetes.io/component: jvb + annotations: + metallb.universe.tf/allow-shared-ip: "shared-ip-service-group" + metallb.universe.tf/address-pool: public +spec: + type: LoadBalancer + ports: + - port: 10000 + protocol: UDP + name: rtp-udp + externalTrafficPolicy: Cluster + selector: + app.kubernetes.io/name: jitsi-meet + app.kubernetes.io/component: jvb \ No newline at end of file diff --git a/src/main/resources/jitsi/web-config-deployment.yaml b/src/main/resources/jitsi/web-config-deployment.yaml index d6c9779..eef7f25 100644 --- a/src/main/resources/jitsi/web-config-deployment.yaml +++ b/src/main/resources/jitsi/web-config-deployment.yaml @@ -25,7 +25,7 @@ spec: - name: jitsi-meet securityContext: {} - image: "jitsi/web:stable-9646" + image: domaindrivenarchitecture/c4k-jitsi-web imagePullPolicy: IfNotPresent envFrom: - configMapRef: diff --git a/src/main/resources/jitsi/web-config-envs-cm.yaml b/src/main/resources/jitsi/web-config-envs-cm.yaml index 5b36ccf..aa380f0 100644 --- a/src/main/resources/jitsi/web-config-envs-cm.yaml +++ b/src/main/resources/jitsi/web-config-envs-cm.yaml @@ -10,4 +10,13 @@ data: DISABLE_HTTPS: "1" ENABLE_HTTP_REDIRECT: "0" JICOFO_AUTH_USER: focus - XMPP_BOSH_URL_BASE: 'http://prosody.NAMESPACE.svc.cluster.local:5280' \ No newline at end of file + XMPP_BOSH_URL_BASE: REPLACE_ME + DEFAULT_LANGUAGE: de + RESOLUTION: "480" + RESOLUTION_MIN: "240" + RESOLUTION_WIDTH: "853" + RESOLUTION_WIDTH_MIN: "427" + DISABLE_AUDIO_LEVELS: "true" + ETHERPAD_PUBLIC_URL: REPLACE_ME + WHITEBOARD_ENABLED: "true" + WHITEBOARD_COLLAB_SERVER_PUBLIC_URL: REPLACE_ME \ No newline at end of file diff --git a/src/main/resources/jitsi/web-config-test-deployment.yaml b/src/main/resources/jitsi/web-config-test-deployment.yaml index 6ea9c08..95a8f32 100644 --- a/src/main/resources/jitsi/web-config-test-deployment.yaml +++ b/src/main/resources/jitsi/web-config-test-deployment.yaml @@ -1,25 +1,25 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: "prosody-test-connection" + name: "jitsi-meet-web-test-connection" namespace: NAMESPACE labels: - app.kubernetes.io/name: "prosody-test-connection" - app.kubernetes.io/component: prosody + app.kubernetes.io/name: jitsi-meet + app.kubernetes.io/component: web spec: replicas: 0 strategy: type: Recreate selector: matchLabels: - app.kubernetes.io/name: "prosody-test-connection" + app.kubernetes.io/name: "jitsi-meet-web-test-connection" template: metadata: labels: - app.kubernetes.io/name: "prosody-test-connection" + app.kubernetes.io/name: "jitsi-meet-web-test-connection" spec: containers: - name: wget image: busybox command: ['wget'] - args: ['prosody:5280/http-bind'] \ No newline at end of file + args: ['jitsi-meet-web:80'] \ No newline at end of file diff --git a/src/test/cljc/dda/c4k_jitsi/jitsi_test.cljc b/src/test/cljc/dda/c4k_jitsi/jitsi_test.cljc index a2f8acd..074ea09 100644 --- a/src/test/cljc/dda/c4k_jitsi/jitsi_test.cljc +++ b/src/test/cljc/dda/c4k_jitsi/jitsi_test.cljc @@ -9,18 +9,9 @@ (st/instrument `cut/prosody-auth) (st/instrument `cut/jitsi-config) (st/instrument `cut/jibri-config) - -(deftest should-generate-etherpad-service - (is (= {:apiVersion "v1", - :kind "Service", - :metadata - {:labels {:service "etherpad"}, :name "etherpad", :namespace "jitsi"}, - :spec - {:ports [{:name "etherpad", :port 9001, :targetPort 9001}], - :selector {:app "jitsi"}}} - (cut/generate-etherpad-service - {:fqdn "xy.xy.xy" - :namespace "jitsi"})))) +(st/instrument `cut/web-config) +(st/instrument `cut/jvb-config) +(st/instrument `cut/etherpad-config) (deftest should-generate-excalidraw-backend-service (is (= {:apiVersion "v1", @@ -162,3 +153,15 @@ {:fqdn "xy.xy.xy" :namespace "jitsi"}))))) +(deftest should-generate-jvb + (is (= 3 + (count (cut/jvb-config + {:fqdn "xy.xy.xy" + :namespace "jitsi"}))))) + +(deftest should-generate-etherpad + (is (= 2 + (count (cut/etherpad-config + {:fqdn "xy.xy.xy" + :namespace "jitsi"}))))) +