added yaml alteration for local tests

This commit is contained in:
bom 2021-11-26 10:35:22 +01:00
parent 4df204abb6
commit 316c802212
7 changed files with 29 additions and 7 deletions

2
.gitignore vendored
View file

@ -25,8 +25,6 @@ logs/
# config files # config files
my-auth.edn my-auth.edn
my-config.edn my-config.edn
auth-local.edn
config-local.edn
auth.edn auth.edn
config.edn config.edn

7
auth-local.edn Normal file
View file

@ -0,0 +1,7 @@
{:postgres-db-user "nextcloud"
:postgres-db-password "dbpass"
:nextcloud-admin-user "cloudadmin"
:nextcloud-admin-password "cloudpassword"
:aws-access-key-id ""
:aws-secret-access-key ""
:restic-password "test-password"}

6
config-local.edn Normal file
View file

@ -0,0 +1,6 @@
{:fqdn "cloudhost"
:issuer :staging
:nextcloud-data-volume-path "/var/cloud"
:postgres-data-volume-path "/var/postgres"
:restic-repository "s3://k3stesthost/mybucket"
:local-integration-test true}

View file

@ -29,8 +29,11 @@
(defn generate-cron [] (defn generate-cron []
(yaml/from-string (yaml/load-resource "backup/cron.yaml"))) (yaml/from-string (yaml/load-resource "backup/cron.yaml")))
(defn generate-backup-restore-deployment [] (defn generate-backup-restore-deployment [my-conf]
(yaml/from-string (yaml/load-resource "backup/backup-restore-deployment.yaml"))) (let [backup-restore-yaml (yaml/from-string (yaml/load-resource "backup/backup-restore-deployment.yaml"))]
(if (and (contains? my-conf :local-integration-test) (= true (:local-integration-test my-conf)))
(cm/replace-named-value backup-restore-yaml "CERTIFICATE_FILE" "/var/run/secrets/localstack-secrets/ca.crt")
backup-restore-yaml)))
(defn generate-secret [my-auth] (defn generate-secret [my-auth]
(let [{:keys [aws-access-key-id aws-secret-access-key restic-password]} my-auth] (let [{:keys [aws-access-key-id aws-secret-access-key restic-password]} my-auth]

View file

@ -43,7 +43,7 @@
[(yaml/to-string (backup/generate-config config)) [(yaml/to-string (backup/generate-config config))
(yaml/to-string (backup/generate-secret config)) (yaml/to-string (backup/generate-secret config))
(yaml/to-string (backup/generate-cron)) (yaml/to-string (backup/generate-cron))
(yaml/to-string (backup/generate-backup-restore-deployment))])))) (yaml/to-string (backup/generate-backup-restore-deployment config))]))))
(defn-spec generate any? (defn-spec generate any?
[my-config config? [my-config config?

View file

@ -56,6 +56,8 @@ spec:
key: restic-repository key: restic-repository
- name: RESTIC_PASSWORD_FILE - name: RESTIC_PASSWORD_FILE
value: /var/run/secrets/backup-secrets/restic-password value: /var/run/secrets/backup-secrets/restic-password
- name: CERTIFICATE_FILE
value: ""
volumeMounts: volumeMounts:
- name: cloud-data-volume - name: cloud-data-volume
mountPath: /var/backups mountPath: /var/backups
@ -65,6 +67,9 @@ spec:
- name: cloud-secret-volume - name: cloud-secret-volume
mountPath: /var/run/secrets/cloud-secrets mountPath: /var/run/secrets/cloud-secrets
readOnly: true readOnly: true
- name: localstack-secret-volume
mountPath: /var/run/secrets/localstack-secrets
readOnly: true
volumes: volumes:
- name: cloud-data-volume - name: cloud-data-volume
persistentVolumeClaim: persistentVolumeClaim:
@ -74,4 +79,7 @@ spec:
secretName: cloud-secret secretName: cloud-secret
- name: backup-secret-volume - name: backup-secret-volume
secret: secret:
secretName: backup-secret secretName: backup-secret
- name: localstack-secret-volume
secret:
secretName: localstack-secret

View file

@ -22,7 +22,7 @@ function main()
echo echo
export ENDPOINT=$(kubectl get ingress -o jsonpath="{$.items[*].status.loadBalancer.ingress[*].ip}") export ENDPOINT=$(kubectl get ingress -o jsonpath="{$.items[*].status.loadBalancer.ingress[*].ip}")
sudo bash -c "echo \"$ENDPOINT k3stesthost cloudhost\" >> /etc/hosts" sudo bash -c "echo \"$ENDPOINT k3stesthost cloudhost\" >> /etc/hosts" # Remove this, works for testing, but fills your /etc/hosts
echo echo
until curl --silent --fail k3stesthost:80 k3stesthost/health | grep -o '"s3": "available"' until curl --silent --fail k3stesthost:80 k3stesthost/health | grep -o '"s3": "available"'