no more pv needed
This commit is contained in:
parent
f255f9ad75
commit
f124f7d23d
6 changed files with 31 additions and 56 deletions
|
@ -2,13 +2,21 @@
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
#?(:cljs [shadow.resource :as rc])
|
#?(:cljs [shadow.resource :as rc])
|
||||||
|
#?(:clj [orchestra.core :refer [defn-spec]]
|
||||||
|
:cljs [orchestra.core :refer-macros [defn-spec]])
|
||||||
[dda.c4k-common.yaml :as yaml]
|
[dda.c4k-common.yaml :as yaml]
|
||||||
|
[dda.c4k-common.predicate :as cp]
|
||||||
[dda.c4k-common.common :as cm]))
|
[dda.c4k-common.common :as cm]))
|
||||||
|
|
||||||
(s/def ::fqdn cm/fqdn-string?)
|
(s/def ::fqdn cp/fqdn-string?)
|
||||||
(s/def ::issuer cm/letsencrypt-issuer?)
|
(s/def ::issuer cp/letsencrypt-issuer?)
|
||||||
(s/def ::restic-repository string?)
|
(s/def ::restic-repository string?)
|
||||||
(s/def ::jira-data-volume-path string?)
|
(s/def ::pvc-storage-class-name cp/pvc-storage-class-name?)
|
||||||
|
(s/def ::pv-storage-size-gb pos?)
|
||||||
|
|
||||||
|
(def strong-config? (s/keys :req-un [::fqdn ::issuer ::pv-storage-size-gb
|
||||||
|
::pvc-storage-class-name]
|
||||||
|
:opt-un [::restic-repository]))
|
||||||
|
|
||||||
#?(:cljs
|
#?(:cljs
|
||||||
(defmethod yaml/load-resource :jira [resource-name]
|
(defmethod yaml/load-resource :jira [resource-name]
|
||||||
|
@ -16,7 +24,6 @@
|
||||||
"jira/certificate.yaml" (rc/inline "jira/certificate.yaml")
|
"jira/certificate.yaml" (rc/inline "jira/certificate.yaml")
|
||||||
"jira/deployment.yaml" (rc/inline "jira/deployment.yaml")
|
"jira/deployment.yaml" (rc/inline "jira/deployment.yaml")
|
||||||
"jira/ingress.yaml" (rc/inline "jira/ingress.yaml")
|
"jira/ingress.yaml" (rc/inline "jira/ingress.yaml")
|
||||||
"jira/persistent-volume.yaml" (rc/inline "jira/persistent-volume.yaml")
|
|
||||||
"jira/pvc.yaml" (rc/inline "jira/pvc.yaml")
|
"jira/pvc.yaml" (rc/inline "jira/pvc.yaml")
|
||||||
"jira/service.yaml" (rc/inline "jira/service.yaml")
|
"jira/service.yaml" (rc/inline "jira/service.yaml")
|
||||||
(throw (js/Error. "Undefined Resource!")))))
|
(throw (js/Error. "Undefined Resource!")))))
|
||||||
|
@ -44,14 +51,13 @@
|
||||||
(assoc-in [:metadata :annotations :cert-manager.io/cluster-issuer] letsencrypt-issuer)
|
(assoc-in [:metadata :annotations :cert-manager.io/cluster-issuer] letsencrypt-issuer)
|
||||||
(cm/replace-all-matching-values-by-new-value "fqdn" fqdn))))
|
(cm/replace-all-matching-values-by-new-value "fqdn" fqdn))))
|
||||||
|
|
||||||
(defn generate-persistent-volume [config]
|
(defn-spec generate-pvc cp/map-or-seq?
|
||||||
(let [{:keys [jira-data-volume-path]} config]
|
[config (s/keys :req-un [::pv-storage-size-gb ::pvc-storage-class-name])]
|
||||||
(->
|
(let [{:keys [pv-storage-size-gb pvc-storage-class-name]} config]
|
||||||
(yaml/from-string (yaml/load-resource "jira/persistent-volume.yaml"))
|
(->
|
||||||
(assoc-in [:spec :hostPath :path] jira-data-volume-path))))
|
(yaml/from-string (yaml/load-resource "jira/pvc.yaml"))
|
||||||
|
(assoc-in [:spec :resources :requests :storage] (str pv-storage-size-gb "Gi"))
|
||||||
(defn generate-pvc []
|
(assoc-in [:spec :storageClassName] (name pvc-storage-class-name)))))
|
||||||
(yaml/from-string (yaml/load-resource "jira/pvc.yaml")))
|
|
||||||
|
|
||||||
(defn generate-service []
|
(defn generate-service []
|
||||||
(yaml/from-string (yaml/load-resource "jira/service.yaml")))
|
(yaml/from-string (yaml/load-resource "jira/service.yaml")))
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
[clojure.tools.reader.edn :as edn]
|
[clojure.tools.reader.edn :as edn]
|
||||||
[dda.c4k-jira.core :as core]
|
[dda.c4k-jira.core :as core]
|
||||||
[dda.c4k-jira.jira :as jira]
|
[dda.c4k-jira.jira :as jira]
|
||||||
[dda.c4k-common.browser :as br]
|
[dda.c4k-common.browser :as br]))
|
||||||
[dda.c4k-common.postgres :as pgc]))
|
|
||||||
|
|
||||||
(defn generate-content
|
(defn generate-content
|
||||||
[]
|
[]
|
||||||
|
@ -51,8 +50,6 @@
|
||||||
|
|
||||||
(defn validate-all! []
|
(defn validate-all! []
|
||||||
(br/validate! "fqdn" ::jira/fqdn)
|
(br/validate! "fqdn" ::jira/fqdn)
|
||||||
(br/validate! "jira-data-volume-path" ::jira/jira-data-volume-path :optional true)
|
|
||||||
(br/validate! "postgres-data-volume-path" ::pgc/postgres-data-volume-path :optional true)
|
|
||||||
(br/validate! "restic-repository" ::jira/restic-repository :optional true)
|
(br/validate! "restic-repository" ::jira/restic-repository :optional true)
|
||||||
(br/validate! "issuer" ::jira/issuer :optional true :deserializer keyword)
|
(br/validate! "issuer" ::jira/issuer :optional true :deserializer keyword)
|
||||||
(br/validate! "auth" core/auth? :deserializer edn/read-string)
|
(br/validate! "auth" core/auth? :deserializer edn/read-string)
|
||||||
|
@ -74,8 +71,6 @@
|
||||||
(br/get-content-from-element "auth" :deserializer edn/read-string))
|
(br/get-content-from-element "auth" :deserializer edn/read-string))
|
||||||
(br/set-output!)))))
|
(br/set-output!)))))
|
||||||
(add-validate-listener "fqdn")
|
(add-validate-listener "fqdn")
|
||||||
(add-validate-listener "jira-data-volume-path")
|
|
||||||
(add-validate-listener "postgres-data-volume-path")
|
|
||||||
(add-validate-listener "restic-repository")
|
(add-validate-listener "restic-repository")
|
||||||
(add-validate-listener "issuer")
|
(add-validate-listener "issuer")
|
||||||
(add-validate-listener "auth"))
|
(add-validate-listener "auth"))
|
|
@ -1,14 +0,0 @@
|
||||||
kind: PersistentVolume
|
|
||||||
apiVersion: v1
|
|
||||||
metadata:
|
|
||||||
name: jira-pv-volume
|
|
||||||
labels:
|
|
||||||
type: local
|
|
||||||
spec:
|
|
||||||
storageClassName: manual
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteOnce
|
|
||||||
capacity:
|
|
||||||
storage: 30Gi
|
|
||||||
hostPath:
|
|
||||||
path: "/var/jira"
|
|
|
@ -5,9 +5,9 @@ metadata:
|
||||||
labels:
|
labels:
|
||||||
app: jira
|
app: jira
|
||||||
spec:
|
spec:
|
||||||
storageClassName: manual
|
storageClassName: REPLACEME
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
- ReadWriteOnce
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
storage: 30Gi
|
storage: REPLACEME
|
|
@ -5,17 +5,6 @@
|
||||||
[dda.c4k-jira.core :as cut]))
|
[dda.c4k-jira.core :as cut]))
|
||||||
|
|
||||||
(deftest should-k8s-objects
|
(deftest should-k8s-objects
|
||||||
(is (= 16
|
|
||||||
(count (cut/k8s-objects {:fqdn "jira-neu.prod.meissa-gmbh.de"
|
|
||||||
:postgres-db-user "jira"
|
|
||||||
:postgres-db-password "jira-db-password"
|
|
||||||
:issuer :prod
|
|
||||||
:jira-data-volume-path "/var/jira"
|
|
||||||
:postgres-data-volume-path "/var/postgres"
|
|
||||||
:aws-access-key-id "aws-id"
|
|
||||||
:aws-secret-access-key "aws-secret"
|
|
||||||
:restic-password "restic-pw"
|
|
||||||
:restic-repository "restic-repository"}))))
|
|
||||||
(is (= 14
|
(is (= 14
|
||||||
(count (cut/k8s-objects {:fqdn "jira-neu.prod.meissa-gmbh.de"
|
(count (cut/k8s-objects {:fqdn "jira-neu.prod.meissa-gmbh.de"
|
||||||
:postgres-db-user "jira"
|
:postgres-db-user "jira"
|
||||||
|
|
|
@ -16,6 +16,16 @@
|
||||||
{:name "letsencrypt-prod-issuer", :kind "ClusterIssuer"}}}
|
{:name "letsencrypt-prod-issuer", :kind "ClusterIssuer"}}}
|
||||||
(cut/generate-certificate {:fqdn "xx" :issuer :prod}))))
|
(cut/generate-certificate {:fqdn "xx" :issuer :prod}))))
|
||||||
|
|
||||||
|
(deftest should-generate-pvc
|
||||||
|
(is (= {:apiVersion "v1",
|
||||||
|
:kind "PersistentVolumeClaim",
|
||||||
|
:metadata {:name "jira-pvc", :labels {:app "jira"}},
|
||||||
|
:spec
|
||||||
|
{:storageClassName "manual",
|
||||||
|
:accessModes ["ReadWriteOnce"],
|
||||||
|
:resources {:requests {:storage "12Gi"}}}}
|
||||||
|
(cut/generate-pvc {:pv-storage-size-gb 12 :pvc-storage-class-name :manual}))))
|
||||||
|
|
||||||
(deftest should-generate-ingress
|
(deftest should-generate-ingress
|
||||||
(is (= {:apiVersion "networking.k8s.io/v1"
|
(is (= {:apiVersion "networking.k8s.io/v1"
|
||||||
:kind "Ingress"
|
:kind "Ingress"
|
||||||
|
@ -45,17 +55,6 @@
|
||||||
:port {:number 8080}}}}]}}]}}
|
:port {:number 8080}}}}]}}]}}
|
||||||
(cut/generate-ingress {:fqdn "xx"}))))
|
(cut/generate-ingress {:fqdn "xx"}))))
|
||||||
|
|
||||||
(deftest should-generate-persistent-volume
|
|
||||||
(is (= {:kind "PersistentVolume"
|
|
||||||
:apiVersion "v1"
|
|
||||||
:metadata {:name "jira-pv-volume", :labels {:type "local"}}
|
|
||||||
:spec
|
|
||||||
{:storageClassName "manual"
|
|
||||||
:accessModes ["ReadWriteOnce"]
|
|
||||||
:capacity {:storage "30Gi"}
|
|
||||||
:hostPath {:path "xx"}}}
|
|
||||||
(cut/generate-persistent-volume {:jira-data-volume-path "xx"}))))
|
|
||||||
|
|
||||||
(deftest should-generate-deployment
|
(deftest should-generate-deployment
|
||||||
(is (= {:containers
|
(is (= {:containers
|
||||||
[{:image "domaindrivenarchitecture/c4k-jira"
|
[{:image "domaindrivenarchitecture/c4k-jira"
|
||||||
|
|
Reference in a new issue