diff --git a/Makefile b/Makefile index 70c2c31..ca4b8ed 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ chisel: clean: kind delete cluster - dotenvx run -f .env.$(ENV) -- node ./packages/infra/vultr-delete-orphaned-resources.js + node ./packages/infra/vultr-delete-orphaned-resources.js deps: echo "Some of the install methods for these dependencies are not cross-platform compatible. Some of the install methods are not tested. Expect this to fail. Please consult the Makefile for URLs to project sources." @@ -57,8 +57,9 @@ deps: sudo systemctl start docker usermod -aG docker cj newgrp docker + npm i -g pnpm + pnpm install -g @dotenvx/dotenvx curl -OL 'https://github.com/vmware-tanzu/velero/releases/download/v1.13.2/velero-v1.13.2-linux-amd64.tar.gz' - npm install -g @dotenvx/dotenvx OS=$(go env GOOS); ARCH=$(go env GOARCH); curl -fsSL -o cmctl https://github.com/cert-manager/cmctl/releases/latest/download/cmctl_${OS}_${ARCH} chmod +x cmctl sudo mv cmctl /usr/local/bin diff --git a/Tiltfile b/Tiltfile index ee57cfa..3214b66 100644 --- a/Tiltfile +++ b/Tiltfile @@ -414,6 +414,8 @@ k8s_resource( # ] # ) +## redis is only here for uppy's usage. +## If we can engineer a way to delete redis, let's do it helm_remote( 'redis', repo_name='redis', diff --git a/flux/apps/base/bitnami/kustomization.yaml b/flux/apps/base/bitnami/kustomization.yaml new file mode 100644 index 0000000..2bac203 --- /dev/null +++ b/flux/apps/base/bitnami/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: futureporn +resources: + - repository.yaml diff --git a/flux/apps/base/postgresql/repository.yaml b/flux/apps/base/bitnami/repository.yaml similarity index 100% rename from flux/apps/base/postgresql/repository.yaml rename to flux/apps/base/bitnami/repository.yaml diff --git a/flux/apps/base/postgresql/kustomization.yaml b/flux/apps/base/postgresql/kustomization.yaml index 70cb764..7d4eed5 100644 --- a/flux/apps/base/postgresql/kustomization.yaml +++ b/flux/apps/base/postgresql/kustomization.yaml @@ -3,4 +3,3 @@ kind: Kustomization namespace: futureporn resources: - release.yaml - - repository.yaml diff --git a/flux/apps/base/redis/kustomization.yaml b/flux/apps/base/redis/kustomization.yaml new file mode 100644 index 0000000..7d4eed5 --- /dev/null +++ b/flux/apps/base/redis/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: futureporn +resources: + - release.yaml diff --git a/flux/apps/base/redis/release.yaml b/flux/apps/base/redis/release.yaml new file mode 100644 index 0000000..d9de3fa --- /dev/null +++ b/flux/apps/base/redis/release.yaml @@ -0,0 +1,27 @@ +apiVersion: helm.toolkit.fluxcd.io/v2 +kind: HelmRelease +metadata: + namespace: futureporn + name: redis +spec: + releaseName: redis + chart: + spec: + version: "19.6.2" + chart: redis + sourceRef: + kind: HelmRepository + name: bitnami + interval: 5m + install: + remediation: + retries: -1 + ## see https://artifacthub.io/packages/helm/bitnami/redis?modal=values + values: + auth: + existingSecret: redis + existingSecretPasswordKey: password + replica: + persistence: + enabled: false + architecture: standalone \ No newline at end of file diff --git a/flux/apps/production/kustomization.yaml b/flux/apps/production/kustomization.yaml index 7a4f8db..3e1cd55 100644 --- a/flux/apps/production/kustomization.yaml +++ b/flux/apps/production/kustomization.yaml @@ -3,6 +3,8 @@ kind: Kustomization namespace: futureporn resources: - ../base/temporal + - ../base/bitnami + - ../base/redis - ../base/postgresql - ../base/fp patches: diff --git a/flux/apps/staging/kustomization.yaml b/flux/apps/staging/kustomization.yaml index 17f64f4..f0433fe 100644 --- a/flux/apps/staging/kustomization.yaml +++ b/flux/apps/staging/kustomization.yaml @@ -2,6 +2,8 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization namespace: futureporn resources: + - ../base/bitnami + - ../base/redis - ../base/podinfo - ../base/temporal - ../base/postgresql diff --git a/scripts/k8s-secrets.sh b/scripts/k8s-secrets.sh index 414a0d6..a84fc51 100755 --- a/scripts/k8s-secrets.sh +++ b/scripts/k8s-secrets.sh @@ -139,7 +139,7 @@ kubectl --namespace futureporn create secret generic strapi \ --from-literal=adminJwtSecret=${STRAPI_ADMIN_JWT_SECRET} \ --from-literal=apiTokenSalt=${STRAPI_API_TOKEN_SALT} \ --from-literal=appKeys=${STRAPI_APP_KEYS} \ ---from-literal=databaseUrl=postgresql-primary.futureporn.svc.cluster.local://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB} \ +--from-literal=databaseUrl=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB} \ --from-literal=jwtSecret=${STRAPI_JWT_SECRET} \ --from-literal=muxPlaybackRestrictionId=${MUX_PLAYBACK_RESTRICTION_ID} \ --from-literal=muxSigningKeyPrivateKey=${MUX_SIGNING_KEY_PRIVATE_KEY} \ diff --git a/scripts/postgres-create.sh b/scripts/postgres-create.sh index a175490..fbec34f 100755 --- a/scripts/postgres-create.sh +++ b/scripts/postgres-create.sh @@ -4,13 +4,13 @@ # source "${bindir}/../.env" -if [ -z $POSTGRES_REALTIME_PASSWORD ]; then - echo "POSTGRES_REALTIME_PASSWORD was missing in env" +if [ -z $POSTGRES_PASSWORD ]; then + echo "POSTGRES_PASSWORD was missing in env" exit 5 fi ## Create the temporal databases -kubectl -n futureporn exec postgres -- psql -U postgres --command "\ +kubectl -n futureporn exec postgresql-primary-0 -- env PGPASSWORD=${POSTGRES_PASSWORD} psql -U postgres --command "\ CREATE DATABASE temporal_visibility \ WITH \ OWNER = postgres \ @@ -20,7 +20,7 @@ kubectl -n futureporn exec postgres -- psql -U postgres --command "\ IS_TEMPLATE = False;" -kubectl -n futureporn exec postgres -- psql -U postgres --command "\ +kubectl -n futureporn exec postgresql-primary-0 -- env PGPASSWORD=${POSTGRES_PASSWORD} psql -U postgres --command "\ CREATE DATABASE temporal \ WITH \ OWNER = postgres \ @@ -29,7 +29,7 @@ kubectl -n futureporn exec postgres -- psql -U postgres --command "\ CONNECTION LIMIT = -1 \ IS_TEMPLATE = False;" -# kubectl -n futureporn exec postgres -- psql -U postgres --command "\ +# kubectl -n futureporn exec postgresql-primary-0 -- psql -U postgres --command "\ # CREATE DATABASE trigger \ # WITH \ # OWNER = postgres \ @@ -51,7 +51,7 @@ kubectl -n futureporn exec postgres -- psql -U postgres --command "\ ## Create the futureporn Strapi database -kubectl -n futureporn exec postgres -- psql -U postgres --command "\ +kubectl -n futureporn exec postgresql-primary-0 -- env PGPASSWORD=${POSTGRES_PASSWORD} psql -U postgres --command "\ CREATE DATABASE futureporn_db \ WITH \ OWNER = postgres \ @@ -62,7 +62,7 @@ kubectl -n futureporn exec postgres -- psql -U postgres --command "\ ## Create the trigger database (for backend tasks) -kubectl -n futureporn exec postgres -- psql -U postgres --command "\ +kubectl -n futureporn exec postgresql-primary-0 -- env PGPASSWORD=${POSTGRES_PASSWORD} psql -U postgres --command "\ CREATE DATABASE trigger \ WITH \ OWNER = postgres \ @@ -73,7 +73,7 @@ kubectl -n futureporn exec postgres -- psql -U postgres --command "\ ## create futureporn user -kubectl -n futureporn exec postgres -- psql -U postgres --command "\ +kubectl -n futureporn exec postgresql-primary-0 -- env PGPASSWORD=${POSTGRES_PASSWORD} psql -U postgres --command "\ CREATE ROLE futureporn \ WITH \ LOGIN \ @@ -88,13 +88,13 @@ kubectl -n futureporn exec postgres -- psql -U postgres --command "\ ## grant futureporn user all privs -kubectl -n futureporn exec postgres -- psql -U postgres --command "\ +kubectl -n futureporn exec postgresql-primary-0 -- env PGPASSWORD=${POSTGRES_PASSWORD} psql -U postgres --command "\ GRANT ALL PRIVILEGES ON DATABASE trigger TO futureporn;" ## import schema ## I have a file, schema.psql that I want to import. How do I do that? -# kubectl -n futureporn exec postgres -- psql -U postgres --command "\ ;" -# kubectl -n futureporn exec postgres -- psql -U postgres -f - < "${bindir}/postgres-2024-05-09-futureporn_db-schema-only.psql" +# kubectl -n futureporn exec postgresql-primary-0 -- psql -U postgres --command "\ ;" +# kubectl -n futureporn exec postgresql-primary-0 -- psql -U postgres -f - < "${bindir}/postgres-2024-05-09-futureporn_db-schema-only.psql" diff --git a/scripts/postgres-restore.sh b/scripts/postgres-restore.sh index a42e336..a9a65a9 100755 --- a/scripts/postgres-restore.sh +++ b/scripts/postgres-restore.sh @@ -3,11 +3,11 @@ dbname=20240704T204659Z_development.psql ## drop futureporn_db -kubectl -n futureporn exec postgres -- psql -U postgres --command "DROP DATABASE futureporn_db;" +kubectl -n futureporn exec postgresql-primary-0 -- env PGPASSWORD=${POSTGRES_PASSWORD} psql -U postgres --command "DROP DATABASE futureporn_db;" ## create futureporn_db -kubectl -n futureporn exec postgres -- psql -U postgres --command "\ +kubectl -n futureporn exec postgresql-primary-0 -- env PGPASSWORD=${POSTGRES_PASSWORD} psql -U postgres --command "\ CREATE DATABASE futureporn_db \ WITH \ OWNER = postgres \ @@ -27,6 +27,6 @@ kubectl -n futureporn exec postgres -- psql -U postgres --command "\ # kubectl exec -i POD_NAME -- pg_restore -U USERNAME -C -d DATABASE < dump.sql -kubectl -n futureporn cp /home/cj/Documents/futureporn-meta/backups/$dbname postgres:/tmp/db.psql -kubectl -n futureporn exec -i postgres -- pg_restore -U postgres -d futureporn_db /tmp/db.psql +kubectl -n futureporn cp /home/cj/Documents/futureporn-meta/backups/$dbname postgresql-primary-0:/tmp/db.psql +kubectl -n futureporn exec -i postgresql-primary-0 -- env PGPASSWORD=${POSTGRES_PASSWORD} pg_restore -U postgres -d futureporn_db /tmp/db.psql # kubectl -n futureporn exec -ti db-postgresql-0 -- rm /tmp/db.psql