Merge branch 'master' of gitlab.com:domaindrivenarchitecture/c4k-common

This commit is contained in:
bom 2021-09-14 14:35:26 +02:00
commit 6f718e786b
10 changed files with 72 additions and 8 deletions

View file

@ -22,6 +22,15 @@ Our convention 4 kubernetes c4k-* tools combine the advantages of both approache
## Usage ## Usage
## Refactoring & Module Overview
| Module | Version | common postgres | frontend script | provider adapter |
|------------------|---------|:---------------:|:---------------:|:----------------:|
| c4k-mastodon-bot | 0.1 | - | | |
| c4k-keycloak | 0.2 | | | |
| c4k-jira | 1.0 | x | x | |
| c4k-nextcloud | 0.1 | | | |
## License ## License
Copyright © 2021 meissa GmbH Copyright © 2021 meissa GmbH

View file

@ -1,7 +1,7 @@
# stable release (should be done from master) # stable release (should be done from master)
``` ```
#adjust [version] #adjust [version] and remove the -SNAPSHOT
vi project-cljs.clj vi project-cljs.clj
lein release lein release

View file

@ -1,4 +1,4 @@
(defproject org.domaindrivenarchitecture/c4k-common-cljs "0.2.11-SNAPSHOT" (defproject org.domaindrivenarchitecture/c4k-common-cljs "0.3.1-SNAPSHOT"
:description "Contains predicates and tools for c4k" :description "Contains predicates and tools for c4k"
:url "https://domaindrivenarchitecture.org" :url "https://domaindrivenarchitecture.org"
:license {:name "Apache License, Version 2.0" :license {:name "Apache License, Version 2.0"

View file

@ -1,4 +1,8 @@
<<<<<<< HEAD
(defproject org.domaindrivenarchitecture/c4k-common-clj "0.2.11" (defproject org.domaindrivenarchitecture/c4k-common-clj "0.2.11"
=======
(defproject org.domaindrivenarchitecture/c4k-common-clj "0.3.1-SNAPSHOT"
>>>>>>> 8b5c33183cbe8e324b69ee5150f5cc40add9a2b4
:description "Contains predicates and tools for c4k" :description "Contains predicates and tools for c4k"
:url "https://domaindrivenarchitecture.org" :url "https://domaindrivenarchitecture.org"
:license {:name "Apache License, Version 2.0" :license {:name "Apache License, Version 2.0"
@ -20,7 +24,6 @@
:dependencies [[dda/data-test "0.1.1"]]} :dependencies [[dda/data-test "0.1.1"]]}
:dev {:plugins [[lein-shell "0.5.0"]]}} :dev {:plugins [[lein-shell "0.5.0"]]}}
:release-tasks [["test"] :release-tasks [["test"]
["vcs" "assert-committed"]
["change" "version" "leiningen.release/bump-version" "release"] ["change" "version" "leiningen.release/bump-version" "release"]
["vcs" "commit"] ["vcs" "commit"]
["vcs" "tag"] ["vcs" "tag"]

View file

@ -4,16 +4,24 @@
#?(:cljs [shadow.resource :as rc]) #?(:cljs [shadow.resource :as rc])
[dda.c4k-common.yaml :as yaml] [dda.c4k-common.yaml :as yaml]
[dda.c4k-common.base64 :as b64] [dda.c4k-common.base64 :as b64]
[dda.c4k-common.common :as cm])) [dda.c4k-common.prefixes :as cm]))
(defn postgres-size?
[input]
(contains? #{:2gb :4gb :8gb :16gb} input))
(s/def ::postgres-db-user cm/bash-env-string?) (s/def ::postgres-db-user cm/bash-env-string?)
(s/def ::postgres-db-password cm/bash-env-string?) (s/def ::postgres-db-password cm/bash-env-string?)
(s/def ::postgres-data-volume-path string?) (s/def ::postgres-data-volume-path string?)
(s/def ::postgres-size postgres-size?)
#?(:cljs #?(:cljs
(defmethod yaml/load-resource :postgres [resource-name] (defmethod yaml/load-resource :postgres [resource-name]
(case resource-name (case resource-name
"postgres/config.yaml" (rc/inline "postgres/config.yaml") "postgres/config-2gb.yaml" (rc/inline "postgres/config-2gb.yaml")
"postgres/config-4gb.yaml" (rc/inline "postgres/config-4gb.yaml")
"postgres/config-8gb.yaml" (rc/inline "postgres/config-8gb.yaml")
"postgres/config-16gb.yaml" (rc/inline "postgres/config-16gb.yaml")
"postgres/deployment.yaml" (rc/inline "postgres/deployment.yaml") "postgres/deployment.yaml" (rc/inline "postgres/deployment.yaml")
"postgres/persistent-volume.yaml" (rc/inline "postgres/persistent-volume.yaml") "postgres/persistent-volume.yaml" (rc/inline "postgres/persistent-volume.yaml")
"postgres/pvc.yaml" (rc/inline "postgres/pvc.yaml") "postgres/pvc.yaml" (rc/inline "postgres/pvc.yaml")
@ -21,8 +29,10 @@
"postgres/service.yaml" (rc/inline "postgres/service.yaml") "postgres/service.yaml" (rc/inline "postgres/service.yaml")
(throw (js/Error. "Undefined Resource!"))))) (throw (js/Error. "Undefined Resource!")))))
(defn generate-config [] (defn generate-config [& args]
(yaml/from-string (yaml/load-resource "postgres/config.yaml"))) (let [{:keys [postgres-size]
:or {postgres-size :2gb}} args]
(yaml/from-string (yaml/load-resource (str "postgres/config-" (name postgres-size) ".yaml")))))
(defn generate-deployment [] (defn generate-deployment []
(yaml/from-string (yaml/load-resource "postgres/deployment.yaml"))) (yaml/from-string (yaml/load-resource "postgres/deployment.yaml")))

View file

@ -5,7 +5,7 @@ metadata:
labels: labels:
app: postgres app: postgres
data: data:
postgres-db: jira
postgresql.conf: | postgresql.conf: |
max_connections = 1000 max_connections = 1000
work_mem = 4MB
shared_buffers = 512MB shared_buffers = 512MB

View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-config
labels:
app: postgres
data:
postgresql.conf: |
max_connections = 100
work_mem = 4MB
shared_buffers = 128MB

View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-config
labels:
app: postgres
data:
postgresql.conf: |
max_connections = 500
work_mem = 2MB
shared_buffers = 256MB

View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-config
labels:
app: postgres
data:
postgresql.conf: |
max_connections = 700
work_mem = 3MB
shared_buffers = 512MB

View file

@ -4,6 +4,15 @@
:cljs [cljs.test :refer-macros [deftest is are testing run-tests]]) :cljs [cljs.test :refer-macros [deftest is are testing run-tests]])
[dda.c4k-common.postgres :as cut])) [dda.c4k-common.postgres :as cut]))
(deftest should-generate-config
(is (= {:postgresql.conf
"max_connections = 100\nwork_mem = 4MB\nshared_buffers = 128MB\n"}
(:data (cut/generate-config))))
(is (= {:postgresql.conf
"max_connections = 700\nwork_mem = 3MB\nshared_buffers = 512MB\n"}
(:data (cut/generate-config :postgres-size :8gb))))
)
(deftest should-generate-persistent-volume (deftest should-generate-persistent-volume
(is (= {:kind "PersistentVolume" (is (= {:kind "PersistentVolume"
:apiVersion "v1" :apiVersion "v1"