first working version

This commit is contained in:
leo 2021-08-10 14:34:17 +02:00
parent 23619a7a61
commit 655a84a5fc
28 changed files with 44 additions and 157 deletions

View file

@ -47,7 +47,7 @@ test-schema:
stage: build_and_test stage: build_and_test
script: script:
- lein uberjar - lein uberjar
- java -jar target/uberjar/c4k-cloud-standalone.jar valid-config.edn valid-auth.edn | kubeconform --kubernetes-version 1.19.0 --strict --skip Certificate - - java -jar target/uberjar/c4k-nextcloud-standalone.jar valid-config.edn valid-auth.edn | kubeconform --kubernetes-version 1.19.0 --strict --skip Certificate -
artifacts: artifacts:
paths: paths:
- target/uberjar - target/uberjar
@ -68,9 +68,9 @@ test-schema:
script: script:
- mkdir -p target/frontend-build - mkdir -p target/frontend-build
- shadow-cljs release frontend - shadow-cljs release frontend
- cp public/js/main.js target/frontend-build/c4k-cloud.js - cp public/js/main.js target/frontend-build/c4k-nextcloud.js
- sha256sum target/frontend-build/c4k-cloud.js > target/frontend-build/c4k-cloud.js.sha256 - sha256sum target/frontend-build/c4k-nextcloud.js > target/frontend-build/c4k-nextcloud.js.sha256
- sha512sum target/frontend-build/c4k-cloud.js > target/frontend-build/c4k-cloud.js.sha512 - sha512sum target/frontend-build/c4k-nextcloud.js > target/frontend-build/c4k-nextcloud.js.sha512
artifacts: artifacts:
paths: paths:
- target/frontend-build - target/frontend-build
@ -79,8 +79,8 @@ package-uberjar:
<<: *clj <<: *clj
stage: package stage: package
script: script:
- sha256sum target/uberjar/c4k-cloud-standalone.jar > target/uberjar/c4k-cloud-standalone.jar.sha256 - sha256sum target/uberjar/c4k-nextcloud-standalone.jar > target/uberjar/c4k-nextcloud-standalone.jar.sha256
- sha512sum target/uberjar/c4k-cloud-standalone.jar > target/uberjar/c4k-cloud-standalone.jar.sha512 - sha512sum target/uberjar/c4k-nextcloud-standalone.jar > target/uberjar/c4k-nextcloud-standalone.jar.sha512
artifacts: artifacts:
paths: paths:
- target/uberjar - target/uberjar
@ -117,20 +117,20 @@ release:
- apk --no-cache add curl - apk --no-cache add curl
- | - |
release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \ release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \
--assets-link "{\"name\":\"c4k-cloud-standalone.jar\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-nextcloud/-/jobs/${CI_JOB_ID}/artifacts/file/target/uberjar/c4k-cloud-standalone.jar\"}" \ --assets-link "{\"name\":\"c4k-nextcloud-standalone.jar\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-nextcloud/-/jobs/${CI_JOB_ID}/artifacts/file/target/uberjar/c4k-nextcloud-standalone.jar\"}" \
--assets-link "{\"name\":\"c4k-cloud-standalone.jar.sha256\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-nextcloud/-/jobs/${CI_JOB_ID}/artifacts/file/target/uberjar/c4k-cloud-standalone.jar.sha256\"}" \ --assets-link "{\"name\":\"c4k-nextcloud-standalone.jar.sha256\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-nextcloud/-/jobs/${CI_JOB_ID}/artifacts/file/target/uberjar/c4k-nextcloud-standalone.jar.sha256\"}" \
--assets-link "{\"name\":\"c4k-cloud-standalone.jar.sha512\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-nextcloud/-/jobs/${CI_JOB_ID}/artifacts/file/target/uberjar/c4k-cloud-standalone.jar.sha512\"}" \ --assets-link "{\"name\":\"c4k-nextcloud-standalone.jar.sha512\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-nextcloud/-/jobs/${CI_JOB_ID}/artifacts/file/target/uberjar/c4k-nextcloud-standalone.jar.sha512\"}" \
--assets-link "{\"name\":\"c4k-cloud.js\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-nextcloud/-/jobs/${CI_JOB_ID}/artifacts/file/target/frontend-build/c4k-cloud.js\"}" \ --assets-link "{\"name\":\"c4k-nextcloud.js\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-nextcloud/-/jobs/${CI_JOB_ID}/artifacts/file/target/frontend-build/c4k-nextcloud.js\"}" \
--assets-link "{\"name\":\"c4k-cloud.js.sha256\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-nextcloud/-/jobs/${CI_JOB_ID}/artifacts/file/target/frontend-build/c4k-cloud.js.sha256\"}" \ --assets-link "{\"name\":\"c4k-nextcloud.js.sha256\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-nextcloud/-/jobs/${CI_JOB_ID}/artifacts/file/target/frontend-build/c4k-nextcloud.js.sha256\"}" \
--assets-link "{\"name\":\"c4k-cloud.js.sha512\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-nextcloud/-/jobs/${CI_JOB_ID}/artifacts/file/target/frontend-build/c4k-cloud.js.sha512\"}" \ --assets-link "{\"name\":\"c4k-nextcloud.js.sha512\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-nextcloud/-/jobs/${CI_JOB_ID}/artifacts/file/target/frontend-build/c4k-nextcloud.js.sha512\"}" \
cloud-image-test-publish: nextcloud-image-test-publish:
image: domaindrivenarchitecture/devops-build:latest image: domaindrivenarchitecture/devops-build:latest
stage: image stage: image
rules: rules:
- if: '$CI_COMMIT_TAG != null' - if: '$CI_COMMIT_TAG != null'
script: script:
- cd infrastructure/docker-cloud && pyb image test publish - cd infrastructure/docker-nextcloud && pyb image test publish
backup-image-test-publish: backup-image-test-publish:
image: domaindrivenarchitecture/devops-build:latest image: domaindrivenarchitecture/devops-build:latest

View file

@ -1,18 +1,18 @@
{ {
"name": "c4k-cloud", "name": "c4k-nextcloud",
"description": "Generate c4k yaml for a nextcloud deployment.", "description": "Generate c4k yaml for a nextcloud deployment.",
"author": "meissa GmbH", "author": "meissa GmbH",
"version": "0.1.3-SNAPSHOT", "version": "0.1.3-SNAPSHOT",
"homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-nextcloud#readme", "homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-nextcloud#readme",
"repository": "https://www.npmjs.com/package/c4k-nextcloud", "repository": "https://www.npmjs.com/package/c4k-nextcloud",
"license": "APACHE2", "license": "APACHE2",
"main": "c4k-cloud.js", "main": "c4k-nextcloud.js",
"bin": { "bin": {
"c4k-cloud": "./c4k-cloud.js" "c4k-nextcloud": "./c4k-nextcloud.js"
}, },
"keywords": [ "keywords": [
"cljs", "cljs",
"cloud", "nextcloud",
"k8s", "k8s",
"c4k", "c4k",
"deployment", "deployment",

View file

@ -1,4 +1,4 @@
(defproject meissa/meissa-cloud "1.0.2-SNAPSHOT" (defproject org.domaindrivenarchitecture/c4k-nextcloud "1.0.2-SNAPSHOT"
:description "nextcloud c4k-installation package" :description "nextcloud c4k-installation package"
:url "https://domaindrivenarchitecture.org" :url "https://domaindrivenarchitecture.org"
:license {:name "Apache License, Version 2.0" :license {:name "Apache License, Version 2.0"
@ -35,7 +35,7 @@
"native-image" "native-image"
"--report-unsupported-elements-at-runtime" "--report-unsupported-elements-at-runtime"
"--initialize-at-build-time" "--initialize-at-build-time"
"-jar" "target/uberjar/c4k-jira-standalone.jar" "-jar" "target/uberjar/c4k-nextcloud-standalone.jar"
"-H:ResourceConfigurationFiles=graalvm-resource-config.json" "-H:ResourceConfigurationFiles=graalvm-resource-config.json"
"-H:Log=registerResource" "-H:Log=registerResource"
"-H:Name=target/graalvm/${:name}"]}) "-H:Name=target/graalvm/${:name}"]})

View file

@ -14,24 +14,24 @@
<div class="container jumbotron"> <div class="container jumbotron">
<form class="needs-validation" id="form"> <form class="needs-validation" id="form">
<label for="fqdn" class="form-label">Your fqdn:</label> <label for="fqdn" class="form-label">Your fqdn:</label>
<input class="form-control" type="text" name="fqdn" id="fqdn" value="cloud-neu.prod.meissa-gmbh.de"> <input class="form-control" type="text" name="fqdn" id="fqdn" value="jira-neu.prod.meissa-gmbh.de">
<div class="invalid-feedback"> <div class="invalid-feedback">
<pre id="fqdn-validation"></pre> <pre id="fqdn-validation"></pre>
</div> </div>
<label for="cloud-data-volume-path" class="form-label">(Optional) Your cloud-data-volume-path:</label> <label for="jira-data-volume-path" class="form-label">(Optional) Your jira-data-volume-path:</label>
<input class="form-control" type="text" name="cloud-data-volume-path" id="cloud-data-volume-path" value="/var/cloud"> <input class="form-control" type="text" name="jira-data-volume-path" id="jira-data-volume-path" value="/var/jira">
<div class="invalid-feedback"> <div class="invalid-feedback">
<pre id="cloud-data-volume-path-validation"></pre> <pre id="jira-data-volume-path-validation"></pre>
</div> </div>
<label for="postgres-data-volume-path" class="form-label">(Optional) Your postgres-data-volume-path:</label> <label for="postgres-data-volume-path" class="form-label">(Optional) Your postgres-data-volume-path:</label>
<input class="form-control" type="text" name="postgres-data-volume-path" id="postgres-data-volume-path" value="/var/postgres"> <input class="form-control" type="text" name="postgres-data-volume-path" id="postgres-data-volume-path" value="/var/postgres">
<div class="invalid-feedback"> <div class="invalid-feedback">
<pre id="postgres-data-volume-path"></pre> <pre id="postgres-data-volume-path-validation"></pre>
</div> </div>
<label for="restic-repository" class="form-label">(Optional) Your restic-repository:</label> <label for="restic-repository" class="form-label">(Optional) Your restic-repository:</label>
<input class="form-control" type="text" name="restic-repository" id="restic-repository" value="restic-repository"> <input class="form-control" type="text" name="restic-repository" id="restic-repository" value="restic-repository">
<div class="invalid-feedback"> <div class="invalid-feedback">
<pre id="restic-repository"></pre> <pre id="restic-repository-validation"></pre>
</div> </div>
<br> <br>
<label for="issuer" class="form-label">(Optional) Your issuer prod/staging:</label> <label for="issuer" class="form-label">(Optional) Your issuer prod/staging:</label>
@ -42,8 +42,8 @@
<br><br> <br><br>
<label for="auth" class="form-label">Your auth.edn:</label> <label for="auth" class="form-label">Your auth.edn:</label>
<textarea name="auth" id="auth" class="form-control" rows="5"> <textarea name="auth" id="auth" class="form-control" rows="5">
{:postgres-db-user "cloud" {:postgres-db-user "jira"
:postgres-db-password "cloud-db-password" :postgres-db-password "jira-db-password"
:aws-access-key-id "aws-id" :aws-access-key-id "aws-id"
:aws-secret-access-key "aws-secret" :aws-secret-access-key "aws-secret"
:restic-password "restic-password"} :restic-password "restic-password"}

View file

@ -6,7 +6,7 @@
"src/test/resources"] "src/test/resources"]
:dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "0.2.8"]] :dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "0.2.8"]]
:builds {:frontend {:target :browser :builds {:frontend {:target :browser
:modules {:main {:init-fn dda.c4k-cloud.browser/init}} :modules {:main {:init-fn dda.c4k-nextcloud.browser/init}}
:release {} :release {}
:compiler-options {:optimizations :advanced}} :compiler-options {:optimizations :advanced}}
:test {:target :node-test :test {:target :node-test

View file

@ -13,7 +13,8 @@
(def config? (s/keys :req-un [::nextcloud/fqdn] (def config? (s/keys :req-un [::nextcloud/fqdn]
:opt-un [::nextcloud/issuer ::nextcloud/nextcloud-data-volume-path :opt-un [::nextcloud/issuer ::nextcloud/nextcloud-data-volume-path
::postgres/postgres-data-volume-path ::restic-repository])) ::postgres/postgres-data-volume-path ::restic-repository
::nextcloud/storage-size]))
(def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password (def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password
::aws-access-key-id ::aws-secret-access-key ::aws-access-key-id ::aws-secret-access-key

View file

@ -33,7 +33,7 @@
(defn generate-deployment [config] (defn generate-deployment [config]
(let [{:keys [fqdn]} config] (let [{:keys [fqdn]} config]
(-> (yaml/from-string (yaml/load-resource "nextcloud/deployment.yaml")) (-> (yaml/from-string (yaml/load-resource "nextcloud/deployment.yaml"))
(cm/replace-named-value "FQDN" fqdn)))) (cm/replace-all-matching-values-by-new-value "fqdn" fqdn))))
(defn generate-ingress [config] (defn generate-ingress [config]
(let [{:keys [fqdn issuer] (let [{:keys [fqdn issuer]
@ -45,10 +45,11 @@
(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 generate-persistent-volume [config]
(let [{:keys [nextcloud-data-volume-path]} config] (let [{:keys [nextcloud-data-volume-path storage-size]} config]
(-> (->
(yaml/from-string (yaml/load-resource "nextcloud/persistent-volume.yaml")) (yaml/from-string (yaml/load-resource "nextcloud/persistent-volume.yaml"))
(assoc-in [:spec :hostPath :path] nextcloud-data-volume-path)))) (assoc-in [:spec :hostPath :path] nextcloud-data-volume-path)
(assoc-in [:spec :capacity :storage] (str storage-size "Gi")))))
(defn generate-pvc [] (defn generate-pvc []
(yaml/from-string (yaml/load-resource "nextcloud/pvc.yaml"))) (yaml/from-string (yaml/load-resource "nextcloud/pvc.yaml")))

View file

@ -25,7 +25,7 @@ spec:
- name: NEXTCLOUD_ADMIN_PASSWORD_FILE - name: NEXTCLOUD_ADMIN_PASSWORD_FILE
value: /var/run/secrets/cloud-secrets/nextcloud-admin-password value: /var/run/secrets/cloud-secrets/nextcloud-admin-password
- name: NEXTCLOUD_TRUSTED_DOMAINS - name: NEXTCLOUD_TRUSTED_DOMAINS
value: "{{fqdn}}" value: fqdn
- name: POSTGRES_USER_FILE - name: POSTGRES_USER_FILE
value: /var/run/secrets/cloud-secrets/postgres-user value: /var/run/secrets/cloud-secrets/postgres-user
- name: POSTGRES_PASSWORD_FILE - name: POSTGRES_PASSWORD_FILE

View file

@ -10,6 +10,6 @@ spec:
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce
capacity: capacity:
storage: {{storage-size}}Gi #??? 30Gi? storage: 200Gi
hostPath: hostPath:
path: "/var/cloud" path: "/var/cloud"

View file

@ -10,7 +10,7 @@ spec:
- ReadWriteOnce - ReadWriteOnce
resources: resources:
requests: requests:
storage: {{storage-size}}Gi #??? 30Gi? storage: 200Gi
selector: selector:
matchLabels: matchLabels:
app: cloud app: cloud

View file

@ -4,6 +4,6 @@ metadata:
name: cloud-service name: cloud-service
spec: spec:
selector: selector:
app.kubernetes.io/name: cloud #??? app.kubernetes.io/name: cloud
ports: ports:
- port: 80 - port: 80

View file

@ -1,4 +0,0 @@
#!/bin/bash
mkdir -p /var/postgres
install -d -m 0777 -o {{user}} -g {{user}} /var/postgres

View file

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

View file

@ -1,49 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgresql
spec:
selector:
matchLabels:
app: postgresql
strategy:
type: Recreate
template:
metadata:
labels:
app: postgresql
spec:
containers:
- image: postgres
name: postgresql
env:
- name: POSTGRES_USER_FILE
value: /var/run/secrets/postgres-secrets/postgres-user
- name: POSTGRES_DB_FILE
value: /var/run/secrets/postgres-secrets/postgres-db
- name: POSTGRES_PASSWORD_FILE
value: /var/run/secrets/postgres-secrets/postgres-password
ports:
- containerPort: 5432
name: postgresql
cmd:
volumeMounts:
- name: postgresql
mountPath: /var/lib/postgresql/data
- name: postgres-secret-volume
mountPath: /var/run/secrets/postgres-secrets
readOnly: true
- name: postgres-config-volume
mountPath: /etc/postgresql/postgresql.conf
subPath: postgresql.conf
readOnly: true
volumes:
- name: postgresql
persistentVolumeClaim:
claimName: postgres-claim
- name: postgres-secret-volume
secret:
secretName: postgres-secret
- name: postgres-config-volume
configMap:
name: postgres-config

View file

@ -1,15 +0,0 @@
kind: PersistentVolume
apiVersion: v1
metadata:
name: postgres-pv-volume
labels:
type: local
app: postgresql
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
capacity:
storage: 10Gi
hostPath:
path: "/var/postgres"

View file

@ -1,16 +0,0 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-claim
labels:
app: postgresql
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
selector:
matchLabels:
app: postgresql

View file

@ -1,9 +0,0 @@
apiVersion: v1
kind: Secret
metadata:
name: postgres-secret
type: Opaque
stringData:
postgres-db: cloud
postgres-user: {{db-user-name}}
postgres-password: {{db-user-password}}

View file

@ -1,10 +0,0 @@
---
apiVersion: v1
kind: Service
metadata:
name: postgresql-service
spec:
selector:
app: postgresql
ports:
- port: 5432

View file

@ -1,3 +0,0 @@
{:existing [{:node-name "cloud"
:node-ip "168.119.190.126"}]
:provisioning-user {:login "root"}}

View file

@ -1,5 +1,5 @@
{:postgres-db-user "cloud" {:postgres-db-user "nextcloud"
:postgres-db-password "cloud-db-password" :postgres-db-password "nextcloud-db-password"
:aws-access-key-id "aws-id" :aws-access-key-id "aws-id"
:aws-secret-access-key "aws-secret" :aws-secret-access-key "aws-secret"
:restic-password "restic-password"} :restic-password "restic-password"}

View file

@ -1,4 +1,5 @@
{:fqdn "cloud-neu.prod.meissa-gmbh.de" {:fqdn "cloud-neu.prod.meissa-gmbh.de"
:cloud-data-volume-path "/var/cloud" :nextcloud-data-volume-path "/var/nextcloud"
:postgres-data-volume-path "/var/postgres" :postgres-data-volume-path "/var/postgres"
:storage-size 300
:restic-repository "restic-repository"} :restic-repository "restic-repository"}