1
0
Fork 0

Compare commits

..

No commits in common. "10119fd5576f175707024f112db23d224d36a7b0" and "1b6e5156f42cf9c746174b765c57ed9f7b90abd3" have entirely different histories.

13 changed files with 25 additions and 340 deletions

View File

@ -7,7 +7,7 @@ ENVIRONMENT := production
REGION := sfo3
ROOT_DIR := $(shell pwd)
# TODO: automatically determine
TERRAFORM := $(ROOT_DIR)/out/tofu.linux-x86_64
TERRAFORM := $(ROOT_DIR)/out/terraform.linux-x86_64
SOPS := $(ROOT_DIR)/out/sops.linux-x86_64
KEYS := \
6B61ECD76088748C70590D55E90A401336C8AAA9 \
@ -15,13 +15,13 @@ KEYS := \
3D7C8D39E8C4DF771583D3F0A8A091FD346001CA \
F4BF5C81EC78A5DD341C91EEDC4B7D1F52E0BA4D
EXTRA_ARGS :=
.DEFAULT_GOAL :=
.PHONY: default
default: \
toolchain \
tools \
$(patsubst %,$(KEY_DIR)/%.asc,$(KEYS)) \
$(CACHE_DIR)/website/.well-known/openpgpkey \
apply
.PHONY:
@ -76,13 +76,6 @@ infra/backend/.terraform: \
$(SOPS) exec-env secrets/$(ENVIRONMENT).enc.env '\
env -C infra/backend $(TERRAFORM) init -upgrade \
'
$(SOPS) exec-env secrets/$(ENVIRONMENT).enc.env '\
env -C infra/backend $(TERRAFORM) refresh \
-var environment=$(ENVIRONMENT) \
-var namespace=$(ENVIRONMENT) \
-var region=$(REGION) \
-state $(ENVIRONMENT).tfstate \
'
infra/main/.terraform: | \
$(TERRAFORM) \
@ -92,13 +85,6 @@ infra/main/.terraform: | \
env -C infra/main $(TERRAFORM) init -upgrade \
-backend-config="../../config/$(ENVIRONMENT).tfbackend" \
'
$(SOPS) exec-env secrets/$(ENVIRONMENT).enc.env '\
env -C infra/main $(TERRAFORM) refresh \
-var environment=$(ENVIRONMENT) \
-var namespace=$(ENVIRONMENT) \
-var region=$(REGION) \
-state $(ENVIRONMENT).tfstate \
'
infra/backend/$(ENVIRONMENT).tfstate: \
$(TERRAFORM) \
@ -110,7 +96,7 @@ infra/backend/$(ENVIRONMENT).tfstate: \
-var environment=$(ENVIRONMENT) \
-var namespace=$(ENVIRONMENT) \
-var region=$(REGION) \
-state $@ \
-state ../../$@ \
'
config/$(ENVIRONMENT).tfbackend: | \
@ -121,17 +107,9 @@ config/$(ENVIRONMENT).tfbackend: | \
$(SOPS) exec-env secrets/$(ENVIRONMENT).enc.env '\
env -C infra/backend \
$(TERRAFORM) \
output -state $(ENVIRONMENT).tfstate \
output -state ../../$< \
> $@ \
'
$(SOPS) exec-env secrets/$(ENVIRONMENT).enc.env '\
env -C infra/backend \
$(TERRAFORM) refresh \
-var environment=$(ENVIRONMENT) \
-var namespace=$(ENVIRONMENT) \
-var region=$(REGION) \
-state $(ENVIRONMENT).tfstate \
'
.PHONY:
apply: \
@ -148,7 +126,7 @@ apply: \
-var environment=$(ENVIRONMENT) \
-var namespace=$(ENVIRONMENT) \
-var region=$(REGION) \
$(EXTRA_ARGS) '
'
$(call maybe_encrypt_secret,infra/main/talos/talosconfig,secrets/$(ENVIRONMENT).talosconfig)
$(call maybe_encrypt_secret,infra/main/talos/kubeconfig,secrets/$(ENVIRONMENT).kubeconfig)
$(call maybe_encrypt_secret,infra/main/talos/controlplane.yaml,secrets/$(ENVIRONMENT).controlplane.yaml)

View File

@ -22,7 +22,7 @@ SOPS_REF=b6d3c9700d88e0c9348f3ec7cd2f10ce4a4b3ee1
BUSYBOX_URL=https://busybox.net/downloads/busybox-1.36.1.tar.bz2
BUSYBOX_HASH=b8cc24c9574d809e7279c3be349795c5d5ceb6fdf19ca709f80cde50e47de314
TOFU_REPO=https://github.com/opentofu/opentofu
TOFU_REF=5d05dba18b6e276a6262a4722fe90c13350c5428
TOFU_REF=f9d8b3ca2c0926f66757241baf81af523be73726
KSOPS_REPO=https://github.com/viaduct-ai/kustomize-sops
KSOPS_REF=ac33c40e1b78d9847a8d0f58473e99419be5b170
KUSTOMIZE_REPO=https://github.com/kubernetes-sigs/kustomize

View File

@ -10,18 +10,21 @@ resource "random_id" "suffix" {
byte_length = 8
}
data "digitalocean_region" "provided" {
slug = var.region
}
resource "digitalocean_custom_image" "talos" {
name = "talos"
url = "https://github.com/siderolabs/talos/releases/download/v1.4.3/digital-ocean-amd64.raw.gz"
# this gets reset by DigitalOcean otherwise
distribution = "Unknown OS"
regions = [var.region]
regions = [data.digitalocean_region.provided.slug]
}
resource "digitalocean_vpc" "main" {
name = "talos"
region = var.region
region = data.digitalocean_region.provided.slug
# Note: This is VERY CAREFULLY chosen to avoid conflict with k8s and cilium
ip_range = "192.168.0.0/16"
}
@ -42,7 +45,7 @@ module "digitalocean_talos_cluster" {
size = "s-2vcpu-4gb",
}]
vpc_id = digitalocean_vpc.main.id
digitalocean_region = var.region
digitalocean_region = data.digitalocean_region.provided.slug
}
module "digitalocean_database_cluster" {
@ -63,28 +66,7 @@ module "digitalocean_database_cluster" {
}]
vpc_id = digitalocean_vpc.main.id
digitalocean_region = var.region
}
# Crater App requires MySQL currently, when it adds PG support we should migrate
#
module "digitalocean_mysql_database_cluster" {
source = "../../terraform_modules/digitalocean_database_cluster"
cluster_name = "distrust-mysql"
db_engine = "mysql"
dbcli_name = "mariadb"
db_version = "8"
size = "db-s-1vcpu-1gb"
node_count = 1
databases = [{
name = "crater",
create_default_superuser = true,
}]
vpc_id = digitalocean_vpc.main.id
digitalocean_region = var.region
digitalocean_region = data.digitalocean_region.provided.slug
}
locals {
@ -98,11 +80,10 @@ locals {
])
}
# `jq .database_users.value.forgejo | sops --encrypt`
output "database_users" {
value = {
for db_user in concat(module.digitalocean_database_cluster.database_users, module.digitalocean_mysql_database_cluster.database_users):
for db_user in module.digitalocean_database_cluster.database_users:
db_user.name => {
apiVersion = "v1",
kind = "Secret",
@ -130,11 +111,6 @@ output "database" {
sensitive = true
}
output "mysql_database" {
value = module.digitalocean_mysql_database_cluster.database_cluster
sensitive = true
}
output "vpc_id" {
value = digitalocean_vpc.main.id
}

View File

@ -2,13 +2,12 @@ terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "2.36.0"
version = "2.28.1"
}
}
backend "s3" {
skip_requesting_account_id = true
skip_credentials_validation = true
skip_region_validation = true
skip_get_ec2_platforms = true
skip_metadata_api_check = true
}

View File

@ -1,119 +0,0 @@
apiVersion: v1
kind: Secret
metadata:
name: env
stringData:
DB_PASSWORD: ENC[AES256_GCM,data:nHeFXLOI6bMb1hslXLu9xqbMNppGeGzI,iv:rakHQI3iFNgD9gtUX0HdeFG5afP9ln0a+wenqm692T0=,tag:en9KmjYlZ6xzeC0fs9wKzA==,type:str]
APP_KEY: ENC[AES256_GCM,data:pG99OkN9DpXEJ287ty/7e/86v5kEYeikNN6FnV++uNFE4j48aPiQENd+57RxAXFTUl+6,iv:IFXaK2gnXFm6T3O7ClTRk5HqLGmgFdvh7Dn2Jw+MQU0=,tag:0SPKkf5jfyyuwHNvvDVgCg==,type:str]
MAIL_PASSWORD: ENC[AES256_GCM,data:+pWcN1GYSA3pibo8WgvFsAHjnrvhDNsjuO+QXYR7bdZFBKWJbshf0sS8,iv:Kw6qiUEFnd5FRGBMWutOoxMNFZYMf8NyQkPBR9TvfXg=,tag:4IOU6qOXWQ02S6rc1RHiOQ==,type:str]
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age: []
lastmodified: "2024-03-31T09:43:12Z"
mac: ENC[AES256_GCM,data:I9rIuOh2cTJDrlPYs3kf6o6jPPtdElDmjWENc4Yk29ezpWwUj3+BsICpOU0kOrehvuyKtcM6BcxuvJG5Q92gZoVRvlHDoLypMyK3vDBxhGO0CAbcKnKmUSvROr6IWY5jKh9EWczxU3VkDTrm/BmCJAbjC2Ys51ej73InZez4t0g=,iv:gIaUNj8wKew4bH7dBHW+LV5S0a9allRQkWQ/3aWYJ4Q=,tag:mwwI+RDG0i45sPOSh+e1mg==,type:str]
pgp:
- created_at: "2024-01-11T20:56:10Z"
enc: |-
-----BEGIN PGP MESSAGE-----
wcFMA82rPM2mSf/aARAAvQd7qO44LNyywY03qCXI18cx6nj9mo36ehJyq6wuYhWa
n95jXEsmRbGt2l8cAJrH9sZB3uE5DCfeZMzEiZ9heaAyxzC34BxSGP+4PBdRqp6B
jv7Ej6F9lV70bQYvDDry5ihWRmADEVrnDrs2+pXsMQiui9dZSGB676d2PIdliV6y
StqbyudjWZS6fLv2xy25yxJBfzb27rLh1d2yo/9AEm873bFVn7bXQxwOoud8s8KU
MLsQxE05zDQrzm+RpDU0mYk3X4ByyL0/J0dyipjHErOLhOCk2MZ4xTVW8U+Jefuu
htLAzftc9NGwWHdSVXqfwSWUq/UklzurPdDcA1riEqE4XmE74cdgP0vqHYeGPykh
M67Xcr1WLDk7i/n4EISqnp5qwItfJIxWlEpKNANEMveYggHXUz3wTk7qHwjpIDwG
7mMfKlL221M1elk1lY60bx//tr2ZqIlN9IXCjOUZOlxlqvYcmie09YbR6tRZAbag
KZcq4s5y5HlVQ10ZUe7eY8qjXMlLVm7N+TJRnfgJrr2+7GTy/wCcx5nwsVBeYm8h
GrHT3PS0CVRA19ynlEqF1jXfqlRMjX0szPIUGb6/7HLiw514otq3KuZmHYAq2TZ2
HMKncOptoUyfpG252v6NJYQC7yF76tdd5YuykeD40ZOBUULtvUEOZyZVdsaAU9zS
UQHygqf8d16qbh2rWK69Kqmc8DbZHCH/f1IDwekPOsNltQhdgn3lOP7gNSEwI7yV
/qk+5kVHg+Yk0l1K34v5aiWEGrI1SKd1m+nvVW7VcEtufw==
=SjUY
-----END PGP MESSAGE-----
fp: 6B61ECD76088748C70590D55E90A401336C8AAA9
- created_at: "2024-01-11T20:56:10Z"
enc: |-
-----BEGIN PGP MESSAGE-----
wcFMAw95Vf08z8oUAQ/+OHoip407wu+pF9bWolOK+dViuRhA/X9JUVyQfJer9HM2
thZUChYerdnUBn674pVUkjS5szch19pdZLeK5/YqUXyWoW1qHUgYgzHHq6JvxXXf
PIC7Q+jCfsmDBGcSJefK9rA5u7S+7rULBZvbMbL7gpCG8cG0aXJBoNLzZ/vva16V
x/3Mn6taKjZX0ACeoQ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FwQMCZCHQeW4MhVM5XFE0d0ab
A5MSm8X7HmYgvg+WvXzawyEX3OyAnw1RZ+n+b6w2NN8YLP1kRLjirDS3PbsLybTS
UQHc1/GvEhu+7CSv118mKOyJwOQ6u1KAblmg2yzyhxN6ZvuwNJ9zvSnovSALJHWQ
HSwUH1xcOoL1xQTwJ/+Ha/n1q9i2MqD4uLSP29yYGgdq1A==
=cXXw
-----END PGP MESSAGE-----
fp: C92FE5A3FBD58DD3EC5AA26BB10116B8193F2DBD
encrypted_regex: ^(data|stringData)$
version: 3.8.1

View File

@ -1,23 +0,0 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: invoiceshelf
annotations:
cert-manager.io/cluster-issuer: letsencrypt
spec:
ingressClassName: nginx
rules:
- host: invoice.distrust.co
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: invoiceshelf
port:
name: http
tls:
- hosts:
- invoice.distrust.co
secretName: invoiceshelf-tls

View File

@ -1,47 +0,0 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
commonLabels:
app.kubernetes.io/part-of: invoiceshelf
resources:
- statefulset.yaml
- service.yaml
- ingress.yaml
configMapGenerator:
- name: env
literals:
- DB_CONNECTION=mysql
- DB_HOST=distrust-mysql-do-user-11788707-0.c.db.ondigitalocean.com
- DB_USERNAME=crater
- DB_DATABASE=crater
- DB_PORT=25060
- APP_ENV=production
- APP_DEBUG=false
- APP_LOG_LEVEL=debug
- APP_URL=https://billing.distrust.co
- ASSET_URL=https://billing.distrust.co
- BROADCAST_DRIVER=log
- CACHE_DRIVER=file
- QUEUE_DRIVER=sync
- SESSION_DRIVER=cookie
- SESSION_LIFETIME=1440
- REDIS_HOST=127.0.0.1
- REDIS_PORT=6379
- MAIL_DRIVER=smtp
- MAIL_HOST=smtp.migadu.com
- MAIL_PORT=465
- MAIL_USERNAME=billing@distrust.co
- MAIL_FROM_ADDRESS=billing@distrust.co
- MAIL_FROM_NAME="billing@distrust.co"
- MAIL_ENCRYPTION=ssl
- PUSHER_APP_ID=
- PUSHER_KEY=
- PUSHER_SECRET=
- SANCTUM_STATEFUL_DOMAINS=billing.distrust.co
- SESSION_DOMAIN=billing.distrust.co
- TRUSTED_PROXIES="*"
- CRON_JOB_AUTH_TOKEN=""
generators:
- secret-generator.yaml
images:
- name: invoiceshelf/invoiceshelf
newTag: 1.1.0@sha256:50787e404725ad4f47462eaf38832d97c627a5d139d51a84f31a9bd90caffb3f

View File

@ -1,6 +0,0 @@
apiVersion: viaduct.ai/v1
kind: ksops
metadata:
name: invoiceshelf
files:
- ./env.enc.yaml

View File

@ -1,15 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: invoiceshelf
labels:
app.kubernetes.io/name: invoiceshelf
app.kubernetes.io/part-of: invoiceshelf
spec:
selector:
app.kubernetes.io/name: invoiceshelf
app.kubernetes.io/component: server
ports:
- name: http
port: 80
targetPort: 80

View File

@ -1,42 +0,0 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: invoiceshelf
labels:
app.kubernetes.io/name: invoiceshelf
app.kubernetes.io/component: server
spec:
selector:
matchLabels:
app.kubernetes.io/name: invoiceshelf
app.kubernetes.io/component: server
template:
metadata:
labels:
app.kubernetes.io/name: invoiceshelf
app.kubernetes.io/component: server
spec:
containers:
- name: invoiceshelf
image: invoiceshelf/invoiceshelf
envFrom:
- secretRef:
name: env
- configMapRef:
name: env
ports:
- name: http
containerPort: 80
securityContext:
allowPrivilegeEscalation: false
volumeMounts:
- name: invoiceshelf-data
mountPath: /var/www/html/InvoiceShelf/storage
volumeClaimTemplates:
- metadata:
name: invoiceshelf-data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 10Gi

@ -1 +1 @@
Subproject commit a2315fdbc8cd0e4a654d1aa4623a53d5292b3574
Subproject commit 23fc267a9dfdda30ba4287f8234879961722bafb

View File

@ -39,34 +39,23 @@ resource "digitalocean_database_user" "default_users" {
name = each.key
provisioner "local-exec" {
command = var.dbcli_name == "psql" ? "GRANT ALL ON DATABASE ${each.key} TO ${each.key};" : "GRANT ALL PRIVILEGES ON ${each.key} TO '${each.key}'@'%';"
interpreter = var.dbcli_name == "psql" ? [
"${var.dbcli_name}",
command = "GRANT ALL ON DATABASE ${each.key} TO ${each.key};"
interpreter = [
"psql",
"-v", "ON_ERROR_STOP=1",
"${local.base_connection_string}/${each.key}",
"-c"
] : [
"${var.dbcli_name}",
"-u",
"${digitalocean_database_cluster.main.user}",
"-p",
"-h",
"${digitalocean_database_cluster.main.host}",
"-P",
"25060",
"-D",
"${each.key}",
"-e"
]
}
provisioner "local-exec" {
command = var.dbcli_name == "psql" ? "GRANT ALL ON SCHEMA public TO ${each.key}" : "true"
interpreter = var.dbcli_name == "psql" ? [
"${var.dbcli_name}",
command = "GRANT ALL ON SCHEMA public TO ${each.key}"
interpreter = [
"psql",
"-v", "ON_ERROR_STOP=1",
"${local.base_connection_string}/${each.key}",
"-c"
] : ["true"]
]
}
# Note: provisioners depend on databases existing

View File

@ -33,8 +33,3 @@ variable "vpc_id" {
type = string
nullable = true
}
variable "dbcli_name" {
type = string
default = "psql"
}