commit a1cae99c4150f739b3b2a073133b3f7739b7c58c Author: ange Date: Wed May 1 11:24:20 2024 +0200 first commit diff --git a/.env b/.env new file mode 100644 index 0000000..da404c9 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +IMAGEAPP=docker.io/vectorim/element-web:v1.11.65 diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..84fd1f6 --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,18 @@ +on: push + +jobs: + build: + name: test + runs-on: debian + steps: + - uses: actions/checkout@v1 + - name: setup env + run: | + cat <> .env + BASE_URL="${{ gitea.ref_name }}.$(tr / '\n' <<< "${{ gitea.repository }}" | tac | tr '\n' .)k8s.gmoker.com" + EOF + cat .env + + - uses: actions/k8sdeploy@v1 + with: + kubeconfig: "${{ secrets.K8S }}" diff --git a/README.md b/README.md new file mode 100644 index 0000000..29cdfd9 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Element diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..6536a73 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,9 @@ +--- +services: + element: + image: "$IMAGEAPP" + restart: unless-stopped + ports: + - "8080:80" + volumes: + - ./config.json:/app/config.json:ro diff --git a/config.json b/config.json new file mode 100644 index 0000000..018a020 --- /dev/null +++ b/config.json @@ -0,0 +1,10 @@ +{ + "default_server_config": { + "m.homeserver": { + "base_url": "https://matrix.gmoker.com" + } + }, + "setting_defaults": { + "use_system_theme": true + } +} diff --git a/manifests/bin/deploy.sh b/manifests/bin/deploy.sh new file mode 100755 index 0000000..7ccf437 --- /dev/null +++ b/manifests/bin/deploy.sh @@ -0,0 +1,38 @@ +#!/bin/bash -e +set -o pipefail + +function kapply() { + for f in "$@"; do + kubectl apply -f \ + <(envsubst "$(env | xargs printf '$%s ')" < "manifests/$f") + done +} + +function kcreatesec() { + kubectl create secret generic --save-config --dry-run=client -oyaml "$@" | kubectl apply -f- +} + +function kcreatecm() { + kubectl create configmap --dry-run=client -oyaml "$@" | kubectl apply -f- +} + +function kgseckey() { + local sec="$1"; shift + local key="$1"; shift + + kubectl get secret "$sec" -o jsonpath="{.data.$key}" | base64 -d +} + +function kgcmkey() { + local cm="$1"; shift + local key="$1"; shift + + kubectl get configmap "$cm" -o jsonpath="{.data.$key}" +} + + +kcreatecm element-config --from-file=config.json + +kapply common/app.yaml + +kubectl rollout restart deployment app diff --git a/manifests/bin/devel.sh b/manifests/bin/devel.sh new file mode 100755 index 0000000..464c4d0 --- /dev/null +++ b/manifests/bin/devel.sh @@ -0,0 +1,5 @@ +#!/bin/bash -e + +export NB_REPLICAS=1 + +. ./manifests/bin/deploy.sh diff --git a/manifests/bin/prod.sh b/manifests/bin/prod.sh new file mode 100755 index 0000000..c97fc9e --- /dev/null +++ b/manifests/bin/prod.sh @@ -0,0 +1,5 @@ +#!/bin/bash -e + +export NB_REPLICAS=3 + +. ./manifests/bin/deploy.sh diff --git a/manifests/common/app.yaml b/manifests/common/app.yaml new file mode 100644 index 0000000..41a4703 --- /dev/null +++ b/manifests/common/app.yaml @@ -0,0 +1,72 @@ +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: app + annotations: + cert-manager.io/cluster-issuer: letsencrypt-prod +spec: + ingressClassName: nginx + tls: + - secretName: tls-app + hosts: + - "$BASE_URL" + rules: + - host: "$BASE_URL" + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: app + port: + name: http +--- +apiVersion: v1 +kind: Service +metadata: + name: app + labels: + app: app +spec: + selector: + app: app + ports: + - name: http + port: 80 + targetPort: http +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: app + labels: + app: app +spec: + replicas: $NB_REPLICAS + selector: + matchLabels: + app: app + template: + metadata: + labels: + app: app + spec: + imagePullSecrets: + - name: regcred + containers: + - name: app + image: "$IMAGEAPP" + ports: + - name: http + containerPort: 80 + volumeMounts: + - name: config + mountPath: /app/config.json + subPath: config.json + readOnly: true + volumes: + - name: config + configMap: + name: element-config diff --git a/manifests/devel/.gitkeep b/manifests/devel/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/manifests/prod/.gitkeep b/manifests/prod/.gitkeep new file mode 100644 index 0000000..e69de29