20 Commits
Author SHA1 Message Date
pi-ux-ce 06a8d9e680 add cronjob backup DB mysql not workign yet 2026-03-02 09:27:03 +00:00
pi-ux-ce f933d5b659 format 2026-02-11 21:45:05 +00:00
pi-ux-ce 7c333b323a doing some cleanup 2026-02-11 21:43:36 +00:00
pi-ux-ce 4564ccd601 adding some import from configmap and secret from bitwarden 2026-02-11 21:36:46 +00:00
pi-ux-ce 8939736cdc working on terraform with bitwarden with success 2026-02-10 10:11:38 +00:00
pi-ux-ce aff67f5008 alot of deprecated modules 2026-02-06 10:40:20 +00:00
pi-ux-ce 56c957139c adding bitwarden and successfull migration 2026-02-05 11:28:48 +00:00
pi-ux-ce 2fc3e0d543 adding celery for django 2025-12-02 15:09:23 +00:00
pi-ux-ce 3a616a024b adding required files 2025-11-25 23:03:19 +00:00
pi-ux-ce 3b933c8fe1 change naming of svc to make them unique and quite some work on bitwarden 2025-11-25 23:02:26 +00:00
pi-ux-ce 594d0af218 adding bitwarden 2025-11-24 21:01:38 +00:00
pi-ux-ce b778662fa5 avoid duplicated PVC value: only one pvc of the same namespace/name will be created but multiple can be reused 2025-11-24 21:01:23 +00:00
pi-ux-ce ad69271f01 add files before tuching bitwarden 2025-11-24 19:28:18 +00:00
pi-ux-ce 652710a98a add these files 2025-08-12 10:23:59 +01:00
pi-ux-ce dca67792f6 upload files 2025-07-31 19:30:06 +01:00
pi-ux-ce ae83c9a258 adding oauthn and keycloak 2025-07-08 00:15:31 +01:00
pi-ux-ce a5e0e9a5c0 adding the command support 2025-07-08 00:15:14 +01:00
pi-ux-ce 6e07a68e90 enable django 2025-06-22 17:10:32 +01:00
pi-ux-ce 6ee3494165 try matching version of existing helm 2025-06-05 11:40:34 +01:00
pi-ux-ce 84e9172eac enable immich , still some work to do but close to the end 2025-06-03 23:04:25 +01:00
24 changed files with 42796 additions and 689 deletions
+1
View File
@@ -0,0 +1 @@
9fdbb94c-0fd5-4ce2-919f-1fbb596cd318
+1
View File
@@ -0,0 +1 @@
2.pYoQjnuN9ZB+IqEypWrFPw==|/nlBG5qPy/zIFwYjjNXMuNWLU8pSt3TLR1/q4L3AEzi5Semc2261DyelXIfVpOn21JOGOV7jiIV6P3CSuASCjvCH+lCZSbjHfcj/MIOl3IBZJWF3vnTBVl3yjYD+Jmf0/zaYXbUW881oiO3Pu5Obc2jiBKNlX2bx5H11Iyi/fOmvR+EgsdequGgRm0FiSkjkbyG8d9bR55XR9NtS5x9a8EOhKWu0yXFGAKkDGV/m+j45z20mVTlAuuNDtIOX/rDKdKJpzg6SF8EuRTGC5RWAHJ+V8BACe3xxHi43YFit5RjpQ83F6rUGc+hc7TTcKyLA0Go7vUnKQ2wljSihM+HgJbGI6Sgnc9/Ys9AyDI0Bfz4EntfUqSeMBoaatvGpe3LYZdGysUMtDUoQWAvEfKbnnTKQRJb6zTD0RjhJ1ZowrrUFXyU9s1kNu3Sx29Q6h926lIiZ7kNejLcBEIJm0NjifAT9E0dwWTC6/bM2NrQpAotQBQGKGOGGRPIQW8vM7EJ6pl3ZSM/RzRnvQEdmWLNTbLd5eUd0efTviQr4BTxhwj7m3UGBUI/ZQhd3UNTU2ZVpt93nY2QPW3EpNpPBdYMnAgqbc3iz9mGZKtUwYpCwEpHj2G0CxCjgoj8il3Ys+vpPbYqpx+/FbibQLsELAbvLtK/TnDT5tq2gCYIHNUYL+iO+rdm8uGVWcFeMUBvyC/sdHEJgnQ3Rf6Up8lhgP3NQu6QgWT5gkGRrJ4RoYYET9919FOas43imUfWLEAaL/iU+NliGj3B0gCnwi1Ljm4+k5MOVHJqgcBdh0LHhNgIQcBurV0Qk8ZkoVnkTBjTMduOGogn9+Ny7B5D28nk8VW4fHL9MsgvYTZXZmI0QKgS2YzTmkle916qGLWgo5hcp5V4MG1EBpchzu0JJUUdPrb06txBr+cCCYvGi1B2epw6nJAJ7OGB4vzcJM/kVQYRVQmV/kfWXxtROCkx3CAKG5oyKMiiPcUiiqIIYuhRUEZYPC9+w67nMANPG8VcyqylcEba/FMSn4ECj7ce2iHCnyAnk9wb78P/YZdNMGbgviJq1nZm+OaGmpMxEoZHpyOe3EmuEKNpuSgqXGygR6ltAqzFRNJJlHm1PLHWxp4n4n5E1VhbaFiN2urTn/Pt2hqh0YEHyRVYYDSJv5QL8Dqq7WVYD2V3waLwi5Q5o6jc2XkaGN3hLg0fH7yO9KMa+MGUIcx5TZX+QGwiB4n/rZijV2h9d7th/tn0+/Gxtz+JcZ9J+4j4/1MR89vGe1EFOl9ZpUYxQVTVNuLoPaql5dXJZf3LeLL3fq05yNyW38NzcT5fFjevSRyRyoTHTrePCr5Tk5D0BaNQDhgDvBtC1kdo72HKR0+y1x31TxzLmc3OMBj2iqMxt0V7snwUfuVYu43LY48YML3wxRe/EVDmP6h8H89JWkw1aCJsLInN7hDSpUJtGBIn30c5r2kSw/87iVskVnQAUsQFMPOzUmDm6E07fnysbPwuAECuha93aMljzQNF4mwd6Pey24Pkfl+K7wypOL94iK1GcM4FqsCpNfD/X1M3Z+AVQahXAtUt82wmaXfQUtQ6Dvt6mfwFnknmWpyI9Pbj3r8lh4M5rffMFucJac32eoq+KY9xdhyPyep0becLQxNog2LiWliSQlfKBoB3X9FSyDalwEasWagUvNdENqkL+GWCxlCZK7g+ibvO5keA0Baqt1ohRcBoigNfmcTsZUPRhq+dy2cvaiPaGRDgX2DKlJdC8LnPDb/qTvk+uP5yZaKSItjdFkYo7c+fbOXH+I93Kd9IK+LJVM+9cWnx6yKBW/TaaEuZCBholtxME8ZQDcnXIelp67IamsfuVb5QNouZuimzb9rP9vEDVTdyE3e5rYzl2AaljMdTIjB1ut5ZqGA8=|hem/6+QHhqSdcTgKycZLP9EDBT3JA8fLIUqETgTITNk=
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Secret
metadata:
name: bitwarden-identity-cert-password
namespace: bitwarden
type: Opaque
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: bitwarden-mssql-nodeport
namespace: bitwarden
spec:
ports:
- name: 1433bitwarden-m
nodePort: 31433
port: 1433
protocol: TCP
targetPort: 1433
selector:
app: bitwarden-mssql
type: NodePort
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,11 @@
apiVersion: v1
data:
APP_URL: https://bookstack.tryton.geeraert.eu
LOCAL_GID: "1000"
LOCAL_UID: "1000"
TZ: Europe/London
kind: ConfigMap
metadata:
name: config
namespace: bitwarden
@@ -0,0 +1,20 @@
apiVersion: v1
data:
ACCEPT_EULA: "Y"
ASPNETCORE_ENVIRONMENT: Production
globalSettings__baseServiceUri__vault: http://localhost
globalSettings__pushRelayBaseUri: https://push.bitwarden.com
globalSettings__selfHosted: "true"
globalSettings__baseServiceUri__internalNotifications: "http://bitwarden-notifications-svc:5000"
globalSettings__baseServiceUri__internalAdmin: "http://bitwarden-admin-svc:5000"
globalSettings__baseServiceUri__internalIdentity: "http://bitwarden-identity-svc:5000"
globalSettings__baseServiceUri__internalApi: "http://bitwarden-api-svc:5000"
globalSettings__baseServiceUri__internalVault: "http://bitwarden-web-svc:5000"
globalSettings__baseServiceUri__internalSso: "http://bitwarden-sso-svc:5000"
globalSettings__baseServiceUri__internalScim: "http://bitwarden-self-host-scim:5000"
kind: ConfigMap
metadata:
name: global.env
namespace: bitwarden
@@ -0,0 +1,28 @@
apiVersion: v1
data:
ACCEPT_EULA: "Y"
adminSettings__admins: pierre@geeraert.eu
globalSettings__baseServiceUri__vault: http://bitwarden.tryton.geeraert.eu
globalSettings__disableUserRegistration: "false"
globalSettings__duo__aKey: p9jCHtnG4NZNZu4SThpVlCuOF1oePGhu53Wa4RJwuyeqRAWQ0aJN7GsKYrGbYIYO
globalSettings__hibpApiKey: REPLACE
globalSettings__identityServer__certificatePassword: test
globalSettings__installation__id: c36aded0-b0f1-4252-920b-ac4c008fc920
globalSettings__installation__key: CtQE5U1tMJE4Dzk7N9DU
globalSettings__internalIdentityKey: I5TMbqmEjhw9uBNmFZ9rU6s1KN5xqAKXh7RSPfgyj2XQ4sjlP22SCupFn4IVhYX7
globalSettings__mail__replyToEmail: no-reply@bitwarden.tryton.geeraert.eu
globalSettings__mail__smtp__host: smtp.gmail.com
globalSettings__mail__smtp__password: vmxkiidikqwirpuh
globalSettings__mail__smtp__port: "587"
globalSettings__mail__smtp__ssl: "false"
globalSettings__mail__smtp__username: p3jh6qa2@gmail.com
globalSettings__oidcIdentityClientKey: w47pWOkPa6mrTkiPuKizitsiRTR6NH8ufI01u77zbZt3LUcKWJ4wchMn6ouiwN7V
globalSettings__sqlServer__connectionString: Data Source=tcp:bitwarden-mssql-svc,1433;Initial
Catalog=bitwarden_vault;Persist Security Info=False;User ID=sa;Password=ChQKWDIW73eSHzX1UyvGDAv4pFw6DVKM;MultipleActiveResultSets=False;Connect
Timeout=30;Encrypt=True;TrustServerCertificate=True
globalSettings__yubico__clientId: REPLACE
globalSettings__yubico__key: REPLACE
kind: ConfigMap
metadata:
name: global.override.env
namespace: bitwarden
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
labels:
deployment_method: manually
name: identity
namespace: bitwarden
spec:
ports:
- name: 5000bitwarden-i
port: 5000
protocol: TCP
targetPort: 5000
selector:
app: bitwarden-identity
type: ClusterIP
@@ -0,0 +1,9 @@
apiVersion: v1
data:
ACCEPT_EULA: "Y"
MSSQL_PID: Express
SA_PASSWORD: SECRET
kind: ConfigMap
metadata:
name: mssql.env
namespace: bitwarden
@@ -0,0 +1,7 @@
apiVersion: v1
data:
SA_PASSWORD: ChQKWDIW73eSHzX1UyvGDAv4pFw6DVKM
kind: ConfigMap
metadata:
name: mssql.override.env
namespace: bitwarden
@@ -0,0 +1,8 @@
apiVersion: v1
data:
LOCAL_GID: "1001"
LOCAL_UID: "1001"
kind: ConfigMap
metadata:
name: uid.env
namespace: bitwarden
@@ -0,0 +1,11 @@
apiVersion: v1
data:
DB_DATABASE_NAME: ZGphbmdv
DB_HOST: ZGphbmdvLWRiLXN2Yw==
DB_PASSWORD: U3VmZnJhZ2UtTW9uZXliYWdzLUlsbHVzaW9uNw==
DB_USERNAME: ZGphbmdvX3VzZXJuYW1l
kind: Secret
metadata:
creationTimestamp: null
name: django-db-credentials
namespace: django
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
apiVersion: v1
data:
DB_DATABASE_NAME: aW1taWNo
DB_HOST: aW1taWNodC1kYi1zdmM=
DB_PASSWORD: U3Bvb24tQm9yb3VnaC1CYXNpczg=
DB_USERNAME: aW1taWNoX3VzZXJuYW1l
kind: Secret
metadata:
creationTimestamp: null
name: immich-db-credentials
namespace: immicht
+6 -4
View File
@@ -35,8 +35,8 @@ PROXY_HTTP="http://gluetun-svc.gluetun.svc:8888"
#BASE_URL="https://www.pornpics.com/pornstars/eiby-shine/" #BASE_URL="https://www.pornpics.com/pornstars/eiby-shine/"
#pornstars="eiby-shine" #pornstars="eiby-shine"
BASE_URL="https://www.pornpics.com/?q=shy+imp" #BASE_URL="https://www.pornpics.com/pornstars/chloe-camilla/"
pornstars="shy-imp" #pornstars="chloe-camilla"
#BASE_URL="https://www.pornpics.com/pornstars/becky-summer" #BASE_URL="https://www.pornpics.com/pornstars/becky-summer"
#pornstars="becky-summer" #pornstars="becky-summer"
@@ -44,6 +44,9 @@ pornstars="shy-imp"
#clear files beforehand #clear files beforehand
echo "Pornstar: "$pornstars
echo "URL: "$BASE_URL
mkdir -p $DESTINATION_FOLDER/$pornstars mkdir -p $DESTINATION_FOLDER/$pornstars
@@ -63,7 +66,7 @@ echo "" > $DESTINATION_FOLDER/$pornstars-image_to_download.txt
for f in $(cat $DESTINATION_FOLDER/$pornstars-urls_of_galleries.txt ); do for f in $(cat $DESTINATION_FOLDER/$pornstars-urls_of_galleries.txt ); do
$curl_command $f | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | grep "https://cdni.pornpics.com/1280" >> $DESTINATION_FOLDER/$pornstars-image_to_download.txt $curl_command $f | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | grep "https://cdni.pornpics.com/" >> $DESTINATION_FOLDER/$pornstars-image_to_download.txt
echo $f echo $f
done done
@@ -73,4 +76,3 @@ for g in $(cat $DESTINATION_FOLDER/$pornstars-image_to_download.txt ); do
# wget -e use_proxy=yes -e http_proxy=$PROXY_HTTP $g -P $DESTINATION_FOLDER/$pornstars # wget -e use_proxy=yes -e http_proxy=$PROXY_HTTP $g -P $DESTINATION_FOLDER/$pornstars
echo $g echo $g
done done
exit 0
@@ -6,25 +6,24 @@ data:
\"$v\"=\"$2\"\n shift\n fi\n shift\ndone\n\n#check if we will use \"$v\"=\"$2\"\n shift\n fi\n shift\ndone\n\n#check if we will use
a HTTP proxy or not\n\nif [[ -z $http_proxy ]]; then\n echo \"not using a HTTP proxy or not\n\nif [[ -z $http_proxy ]]; then\n echo \"not using
proxy\"\n curl_command=\"curl\"\nelse\n echo \"using proxy\"\n curl_command=\"curl proxy\"\n curl_command=\"curl\"\nelse\n echo \"using proxy\"\n curl_command=\"curl
-x $http_proxy\"\n\nfi\n\n\n#dowload from https://www.pornpics.com/pornstars/eiby-shine/\nDESTINATION_FOLDER=\"/data\"\nPROXY_HTTP=\"http://gluetun-svc.gluetun.svc:8888\"\n\n#BASE_URL=\"https://www.pornpics.com/pornstars/eiby-shine/\"\n#pornstars=\"eiby-shine\"\n\nBASE_URL=\"https://www.pornpics.com/?q=shy+imp\"\npornstars=\"shy-imp\"\n\n#BASE_URL=\"https://www.pornpics.com/pornstars/becky-summer\"\n#pornstars=\"becky-summer\"\n\n\n#clear -x $http_proxy\"\n\nfi\n\n\n#dowload from https://www.pornpics.com/pornstars/eiby-shine/\nDESTINATION_FOLDER=\"/data\"\nPROXY_HTTP=\"http://gluetun-svc.gluetun.svc:8888\"\n\n#BASE_URL=\"https://www.pornpics.com/pornstars/eiby-shine/\"\n#pornstars=\"eiby-shine\"\n\n#BASE_URL=\"https://www.pornpics.com/pornstars/chloe-camilla/\"\n#pornstars=\"chloe-camilla\"\n\n#BASE_URL=\"https://www.pornpics.com/pornstars/becky-summer\"\n#pornstars=\"becky-summer\"\n\n\n#clear
files beforehand\n\n\nmkdir -p $DESTINATION_FOLDER/$pornstars\n\nif [[ $skip_searching_gallery files beforehand\n\necho \"Pornstar: \"$pornstars\necho \"URL: \"$BASE_URL\n\n\nmkdir
== true ]]; then\n echo \"not looping through galleries\"\n\t\techo \"using -p $DESTINATION_FOLDER/$pornstars\n\nif [[ $skip_searching_gallery == true ]];
existing file instead\"\n\t\t#because we need to keep the file $DESTINATION_FOLDER/$pornstars-urls_of_galleries.txt then\n echo \"not looping through galleries\"\n\t\techo \"using existing
with the existing URL , in this condition, \n\t\t#no deletion of this file\necho file instead\"\n\t\t#because we need to keep the file $DESTINATION_FOLDER/$pornstars-urls_of_galleries.txt
\"https://www.pornpics.com/galleries/onlyfans-shy-imp-starring-shy-imp-naked-porn-pics-90263490/\nhttps://www.pornpics.com/galleries/onlyfans-shy-imp-featuring-shy-imp-xxx-porn-pics-15741579/\nhttps://www.pornpics.com/galleries/onlyfans-shy-imp-starring-shy-imp-naked-photos-68925414/\nhttps://www.pornpics.com/galleries/onlyfans-shy-imp-shy-imp-20862921/\nhttps://www.pornpics.com/galleries/skinny-girl-with-pink-hair-shy-imp-shows-her-small-tits-during-a-solo-show-50988369/\nhttps://www.pornpics.com/galleries/onlyfans-shy-imp-featuring-shy-imp-hot-gallery-86312934/\" with the existing URL , in this condition, \n\t\t#no deletion of this file\nelse\n
>> $DESTINATION_FOLDER/$pornstars-urls_of_galleries.txt\n\nelse\n echo \ echo \"looping through galleries\"\n\t\t#because we will re-generate this
\"looping through galleries\"\n\t\t#because we will re-generate this file, can file, can be emptied\n\t\techo \"\" > $DESTINATION_FOLDER/$pornstars-urls_of_galleries.txt\n
be emptied\n\t\techo \"\" > $DESTINATION_FOLDER/$pornstars-urls_of_galleries.txt\n
\ $curl_command -s $BASE_URL | grep -Eo \"(http|https)://[a-zA-Z0-9./?=_%:-]*\" \ $curl_command -s $BASE_URL | grep -Eo \"(http|https)://[a-zA-Z0-9./?=_%:-]*\"
| grep \"https://www.pornpics.com/galleries/\" |sort -u >> $DESTINATION_FOLDER/$pornstars-urls_of_galleries.txt\nfi\n\necho | grep \"https://www.pornpics.com/galleries/\" |sort -u >> $DESTINATION_FOLDER/$pornstars-urls_of_galleries.txt\nfi\n\necho
\"\" > $DESTINATION_FOLDER/$pornstars-image_to_download.txt\n\n\nfor f in $(cat \"\" > $DESTINATION_FOLDER/$pornstars-image_to_download.txt\n\n\nfor f in $(cat
$DESTINATION_FOLDER/$pornstars-urls_of_galleries.txt ); do\n\t$curl_command $f $DESTINATION_FOLDER/$pornstars-urls_of_galleries.txt ); do\n\t$curl_command $f
| grep -Eo \"(http|https)://[a-zA-Z0-9./?=_%:-]*\" | grep \"https://cdni.pornpics.com/1280\" | grep -Eo \"(http|https)://[a-zA-Z0-9./?=_%:-]*\" | grep \"https://cdni.pornpics.com/\"
>> $DESTINATION_FOLDER/$pornstars-image_to_download.txt\n\techo $f\ndone\n\n\nfor >> $DESTINATION_FOLDER/$pornstars-image_to_download.txt\n\techo $f\ndone\n\n\nfor
g in $(cat $DESTINATION_FOLDER/$pornstars-image_to_download.txt ); do \n\t$curl_command g in $(cat $DESTINATION_FOLDER/$pornstars-image_to_download.txt ); do \n\t$curl_command
-O --output-dir $DESTINATION_FOLDER/$pornstars $g\n# wget -e use_proxy=yes -O --output-dir $DESTINATION_FOLDER/$pornstars $g\n# wget -e use_proxy=yes
-e http_proxy=$PROXY_HTTP $g -P $DESTINATION_FOLDER/$pornstars\n echo $g -e http_proxy=$PROXY_HTTP $g -P $DESTINATION_FOLDER/$pornstars\n echo $g
\ndone\nexit 0\n" \ndone\n"
kind: ConfigMap kind: ConfigMap
metadata: metadata:
creationTimestamp: null creationTimestamp: null
@@ -17,13 +17,17 @@ spec:
mountPropagation: None mountPropagation: None
name: data-pvc name: data-pvc
command: command:
# - /bin/bash
# - -c
# - sleep 3600
- bash - bash
- -c
- sleep 3600
# - bash
- /config/download.sh - /config/download.sh
- --http_proxy - --http_proxy
- "http://gluetun-svc.gluetun.svc:8888" - "http://gluetun-svc.gluetun.svc:8888"
- --BASE_URL
- "https://www.pornpics.com/?q=bretona"
- --pornstars
- "bretona"
restartPolicy: Never restartPolicy: Never
volumes: volumes:
- configMap: - configMap:
+315 -58
View File
@@ -1,58 +1,24 @@
terraform { terraform {
required_version = "> 0.8.0" required_version = "> 0.8.0"
required_providers { required_providers {
bitwarden = { bitwarden-secrets = {
source = "maxlaverse/bitwarden" source = "bitwarden/bitwarden-secrets"
version = ">= 0.13.6" version = "0.5.4-pre"
} }
} }
} }
provider "kubernetes" { provider "kubernetes" {
config_path = "~/.kube/config" config_path = "~/.kube/config"
} }
provider "bitwarden" {
email = "pierre@geeraert.eu"
master_password = ""
server = "https://bitwarden.tryton.geeraert.eu"
experimental {
embedded_client = true
}
}
#https://stackoverflow.com/questions/66670949/how-to-tell-terraform-to-skip-the-secret-manager-resource-if-it-exists
#for the secret not overwritten (not tested)
data "bitwarden_item_login" "example" {
search = "bookstack.zeus.geeraert.eu"
}
data "bitwarden_item_secure_note" "vpn_preshared_key" { provider "bitwarden-secrets" {
search = "terraform testing" api_url = "https://bitwarden.tryton.geeraert.eu/api"
} identity_url = "https://bitwarden.tryton.geeraert.eu/identity"
output "pgpin" { access_token = "0.dd9b243a-b5f5-4b26-aaba-b3f70170088c.fjoaQEShPaEEZa7GmkTJXQYEmF5wVp:5B4jhLp5gRymNcwktMDyOg=="
value = nonsensitive(coalesce(data.bitwarden_item_secure_note.vpn_preshared_key.field.1.hidden,1234))
sensitive = true
}
resource "random_password" "password" {
length = 16
special = true
override_special = "!#$%&*()-_=+[]{}<>:?"
}
resource "bitwarden_item_secure_note" "terraform_upload_testing" {
name = "terraform upload testing"
# notes = <<EOT
#[global]
#secret = "<something sensitive>"
#EOT
organization_id = "a6361589-badd-4bde-9cb4-af8901161c0d" organization_id = "a6361589-badd-4bde-9cb4-af8901161c0d"
collection_ids = ["3fa902cd-8244-46bc-a4ea-af8901262d94"]
field {
name = "category"
hidden = random_password.password.result
}
} }
variable "kubernetes" { variable "kubernetes" {
@@ -63,10 +29,14 @@ variable "kubernetes" {
name = string name = string
pvc = optional(bool, false) pvc = optional(bool, false)
config_map = optional(bool, false) config_map = optional(bool, false)
secret = optional(bool, false)
host_path = optional(string) host_path = optional(string)
pvc_size = optional(string) pvc_size = optional(string)
storage_class_name = optional(string, "nfs-storage-intelligent") storage_class_name = optional(string, "nfs-storage-intelligent")
annotations_fileType = optional(string)
existing_pvc = optional(bool, false)
mount_path = string mount_path = string
sub_path = optional(string)
}))) })))
environment = optional(map(object({ environment = optional(map(object({
name = optional(string) name = optional(string)
@@ -81,11 +51,11 @@ variable "kubernetes" {
replicas = optional(number, 1) replicas = optional(number, 1)
namespace = optional(string) namespace = optional(string)
connected_namespace = optional(string, "") connected_namespace = optional(string, "")
# namespace = optional(string,coalesce(connected_namespace,"")) command = optional(list(string))
#block_namespace_creation = optional(bool, false)
service_port = optional(list(number)) service_port = optional(list(number))
service_type = optional(string, "ClusterIP") service_type = optional(string, "ClusterIP")
service_name = optional(string) service_name = optional(string)
domain_name = optional(string)
liveness_tcp_socket = optional(number) liveness_tcp_socket = optional(number)
liveness_http_get = optional(string) liveness_http_get = optional(string)
liveness_http_get_path = optional(string) liveness_http_get_path = optional(string)
@@ -94,6 +64,8 @@ variable "kubernetes" {
enabled = optional(bool, true) enabled = optional(bool, true)
secret_ref = optional(list(string)) secret_ref = optional(list(string))
config_map_ref = optional(list(string)) config_map_ref = optional(list(string))
config_map_import = optional(list(string))
secret_import = optional(list(string))
extra_manifest = optional(list(string)) extra_manifest = optional(list(string))
requirements = optional(map(string)) requirements = optional(map(string))
# requirements = optional(map(string), { # requirements = optional(map(string), {
@@ -103,25 +75,62 @@ variable "kubernetes" {
# requests-memory = "200Mi" # requests-memory = "200Mi"
# }) # })
dns_nameservers = optional(string) dns_nameservers = optional(string)
service_account_name = optional(string)
environment_variables = optional(map(string), { name = "value" }) environment_variables = optional(map(string), { name = "value" })
security_context = optional(bool, false) security_context = optional(bool, false)
})) }))
} }
variable "database_backup_info" {
type = map(object({
image = optional(string)
command = optional(string)
}))
description = "based on DB engine, give the docker image and the command used to backup"
default = {
postgres = {
image = "alpine/psql"
command = "pg_dump |gzip -9 > /backup/$(DB_DATABASE_NAME)-DB-$(date +%Y%m%d).sql.gz"
}
mysql = {
image = "mysql"
command = "mysqldump |gzip -9 > /backup/$(DB_DATABASE_NAME)-DB-$(date +%Y%m%d).sql.gz"
}
}
}
locals { locals {
pvc_details = flatten([ pvc_list = flatten([
for key, value in var.kubernetes : [ for key, value in var.kubernetes : [
for index, pvc in value.pvc : { for index, pvc in value.pvc : {
key = "${coalesce(value.namespace, value.connected_namespace, key)}/${pvc.name}"
index = index index = index
pvc = pvc.pvc pvc = pvc.pvc
name = pvc.name name = pvc.name
pvc_size = pvc.pvc_size pvc_size = pvc.pvc_size
mount_path = pvc.mount_path mount_path = pvc.mount_path
storage_class_name = pvc.storage_class_name storage_class_name = pvc.storage_class_name
annotations_fileType = pvc.annotations_fileType
existing_pvc = pvc.existing_pvc
sub_path = pvc.sub_path
namespace = coalesce(value.namespace, value.connected_namespace, key) namespace = coalesce(value.namespace, value.connected_namespace, key)
}] if value.enabled == true && value.pvc != null }] if value.enabled == true && value.pvc != null
]) ])
# group duplicates instead of throwing an error
pvc_map_grouped = {
for p in local.pvc_list :
p.key => p...
}
# keep only one PVC per key (take the first)
pvc_map = {
for k, list in local.pvc_map_grouped :
k => list[0]
}
pvc_details = values(local.pvc_map)
} }
locals { locals {
@@ -137,7 +146,7 @@ locals {
data "kubernetes_all_namespaces" "allns" {} data "kubernetes_all_namespaces" "allns" {}
resource "kubernetes_namespace" "automatic" { resource "kubernetes_namespace_v1" "automatic" {
for_each = { for key, value in var.kubernetes : key => value if value.enabled == true && value.connected_namespace == "" } for_each = { for key, value in var.kubernetes : key => value if value.enabled == true && value.connected_namespace == "" }
metadata { metadata {
annotations = { annotations = {
@@ -175,15 +184,20 @@ resource "kubernetes_manifest" "manifest" {
resource "kubernetes_persistent_volume_claim" "automatic-pvc" { resource "kubernetes_persistent_volume_claim_v1" "automatic-pvc" {
for_each = { for key, value in local.pvc_details : "${value.index}" => merge(value, { mew_key = value.index }) if value.pvc } for_each = { for key, value in local.pvc_details : "${value.index}" => merge(value, { mew_key = value.index }) if value.pvc && value.existing_pvc != true }
metadata { metadata {
namespace = coalesce(each.value.namespace, each.key) namespace = coalesce(each.value.namespace, each.key)
name = "${each.value.name}-pvc" name = "${each.value.name}-pvc"
labels = { labels = {
deployment_method = "Terraform" deployment_method = "Terraform"
} }
annotations = {
fileType = try(each.value.annotations_fileType, "file")
} }
}
spec { spec {
access_modes = ["ReadWriteMany"] access_modes = ["ReadWriteMany"]
storage_class_name = each.value.storage_class_name storage_class_name = each.value.storage_class_name
@@ -194,7 +208,7 @@ resource "kubernetes_persistent_volume_claim" "automatic-pvc" {
} }
} }
} }
resource "kubernetes_persistent_volume_claim" "automatic-pvc-database" { resource "kubernetes_persistent_volume_claim_v1" "automatic-pvc-database" {
for_each = { for key, value in var.kubernetes : key => value if value.database != null && value.enabled == true } for_each = { for key, value in var.kubernetes : key => value if value.database != null && value.enabled == true }
metadata { metadata {
namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key) namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key)
@@ -214,7 +228,29 @@ resource "kubernetes_persistent_volume_claim" "automatic-pvc-database" {
} }
} }
resource "kubernetes_persistent_volume_claim" "automatic-pvc-redis" { resource "kubernetes_persistent_volume_claim_v1" "backup-pvc-database" {
for_each = { for key, value in var.kubernetes : key => value if value.database != null && value.enabled == true }
metadata {
namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key)
name = "${each.key}-db-backup"
labels = {
deployment_method = "Terraform"
}
annotations = {
fileType = "Backup" }
}
spec {
access_modes = ["ReadWriteMany"]
storage_class_name = "nfs-storage-fastaccess"
resources {
requests = {
storage = "1Gi"
}
}
}
}
resource "kubernetes_persistent_volume_claim_v1" "automatic-pvc-redis" {
for_each = { for key, value in var.kubernetes : key => value if value.redis != null && value.enabled == true } for_each = { for key, value in var.kubernetes : key => value if value.redis != null && value.enabled == true }
metadata { metadata {
namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key) namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key)
@@ -234,7 +270,7 @@ resource "kubernetes_persistent_volume_claim" "automatic-pvc-redis" {
} }
} }
resource "kubernetes_service" "automatic_service" { resource "kubernetes_service_v1" "automatic_service" {
for_each = { for key, value in var.kubernetes : key => value if value.service_port != null && value.enabled == true } for_each = { for key, value in var.kubernetes : key => value if value.service_port != null && value.enabled == true }
metadata { metadata {
name = "${each.key}-svc" name = "${each.key}-svc"
@@ -258,7 +294,7 @@ resource "kubernetes_service" "automatic_service" {
content { content {
port = port.value port = port.value
target_port = port.value target_port = port.value
name = replace("${each.key}${port.value}", "/(.{0,15})(.*)/", "$1") name = replace("${port.value}${each.key}", "/(.{0,15})(.*)/", "$1")
} }
} }
@@ -275,13 +311,14 @@ resource "kubernetes_service" "automatic_service" {
} }
resource "kubernetes_service" "automatic_service_database" { resource "kubernetes_service_v1" "automatic_service_database" {
for_each = { for key, value in var.kubernetes : key => value if value.database != null && value.enabled == true } for_each = { for key, value in var.kubernetes : key => value if value.database != null && value.enabled == true }
metadata { metadata {
name = "${each.key}-db-svc" name = "${each.key}-db-svc"
namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key) namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key)
labels = { labels = {
deployment_method = "Terraform" deployment_method = "Terraform"
#username = "${resource.bitwarden-secrets_secret.automatic_bitwarden_secret_password[each.key].key}"
} }
} }
spec { spec {
@@ -300,7 +337,7 @@ resource "kubernetes_service" "automatic_service_database" {
resource "kubernetes_service" "automatic_service_redis" { resource "kubernetes_service_v1" "automatic_service_redis" {
for_each = { for key, value in var.kubernetes : key => value if value.redis != null && value.enabled == true } for_each = { for key, value in var.kubernetes : key => value if value.redis != null && value.enabled == true }
metadata { metadata {
name = "${each.key}-redis-svc" name = "${each.key}-redis-svc"
@@ -360,7 +397,7 @@ resource "kubernetes_deployment_v1" "automatic" {
content { content {
container_port = port.value container_port = port.value
# name = "${each.key}-${port.value}" # name = "${each.key}-${port.value}"
name = replace("${each.key}${port.value}", "/(.{0,15})(.*)/", "$1") name = replace("${port.value}${each.key}", "/(.{0,15})(.*)/", "$1")
} }
} }
@@ -370,6 +407,7 @@ resource "kubernetes_deployment_v1" "automatic" {
content { content {
mount_path = volume_mount.value.mount_path mount_path = volume_mount.value.mount_path
name = "${volume_mount.value.name}-pvc" name = "${volume_mount.value.name}-pvc"
sub_path = volume_mount.value.sub_path != null ? volume_mount.value.sub_path : ""
} }
} }
@@ -397,6 +435,20 @@ resource "kubernetes_deployment_v1" "automatic" {
} }
} }
# dynamic "command" {
# for_each = each.value.command != null ? [1] : []
# content {
# [each.value.command]
# }
# }
# command = each.value.command != null ? {
# [each.value.command]
# } : {}
command = each.value.command != null ? each.value.command : []
dynamic "env" { dynamic "env" {
for_each = each.value.environment != null ? each.value.environment : {} for_each = each.value.environment != null ? each.value.environment : {}
@@ -484,6 +536,7 @@ resource "kubernetes_deployment_v1" "automatic" {
} }
} }
service_account_name = each.value.service_account_name != null ? each.value.service_account_name : null
dynamic "volume" { dynamic "volume" {
for_each = each.value.pvc != null ? each.value.pvc : {} for_each = each.value.pvc != null ? each.value.pvc : {}
@@ -511,6 +564,12 @@ resource "kubernetes_deployment_v1" "automatic" {
} }
} }
dynamic "secret" {
for_each = volume.value.secret ? [1] : []
content {
secret_name = volume.value.name
}
}
} }
} }
@@ -570,9 +629,8 @@ resource "kubernetes_deployment_v1" "database-automatic" {
name = "${each.key}-db-pvc" name = "${each.key}-db-pvc"
} }
command = try([each.value.database.command], [])
#command = [try(each.value.database.command,"")]
dynamic "env" { dynamic "env" {
for_each = each.value.environment != null ? each.value.environment : {} for_each = each.value.environment != null ? each.value.environment : {}
@@ -647,6 +705,62 @@ resource "kubernetes_deployment_v1" "database-automatic" {
} }
resource "kubernetes_cron_job_v1" "database-backup" {
for_each = { for key, value in var.kubernetes : key => value if value.database != null && value.enabled == true }
metadata {
name = "${coalesce(each.value.namespace, each.key)}-db-backup"
namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key)
labels = {
app = each.key
deployment_method = "Terraform"
database = "true"
#image = try(var.database_backup_info[each.value.database.engine].image, var.database_backup_info.postgres.image)
}
}
spec {
failed_jobs_history_limit = 5
schedule = "1 0 * * *"
timezone = "Etc/UTC"
successful_jobs_history_limit = 5
job_template {
metadata {}
spec {
backoff_limit = 4
ttl_seconds_after_finished = 100
template {
metadata {}
spec {
container {
name = "${coalesce(each.value.namespace, each.key)}-db-backup"
#image = "alpine/psql"
image = try(var.database_backup_info[each.value.database.engine].image, var.database_backup_info.postgres.image)
command = ["/bin/sh", "-c"]
#args = ["pg_dump |gzip -9 > /backup/$(DB_DATABASE_NAME)-DB-$(date +%Y%m%d).sql.gz"]
args = [try(var.database_backup_info[each.value.database.engine].command, var.database_backup_info.postgres.command)]
env_from {
secret_ref {
name = "${each.key}-db-terraform"
}
}
volume_mount {
mount_path = "/backup"
name = "${each.key}-db-backup"
}
}
volume {
name = "${each.key}-db-backup"
persistent_volume_claim {
claim_name = "${each.key}-db-backup"
}
}
}
}
}
}
}
}
resource "kubernetes_deployment_v1" "redis-automatic" { resource "kubernetes_deployment_v1" "redis-automatic" {
for_each = { for key, value in var.kubernetes : key => value if value.redis != null && value.enabled == true } for_each = { for key, value in var.kubernetes : key => value if value.redis != null && value.enabled == true }
@@ -770,3 +884,146 @@ resource "kubernetes_deployment_v1" "redis-automatic" {
} }
} }
} }
resource "kubernetes_config_map_v1" "automatic-configmap" {
metadata {
name = "extra-sites-terraform"
namespace = "reverse-proxy"
annotations = {
"reloader.stakater.com/match" : "true",
}
}
data = {
for key, value in var.kubernetes :
"${value.domain_name}.conf" => templatefile("nginx_config.tftpl", {
name_site = value.domain_name
name_service = "${key}-svc.${coalesce(value.namespace, value.connected_namespace, key)}.svc:${value.service_port.0}"
}) if value.domain_name != null && value.enabled == true
}
}
data "bitwarden-secrets_secret" "configmap_import" {
for_each = {
for pair in flatten([
for k, v in var.kubernetes : [
for id in v.config_map_import : {
map_key = k
secret_id = id
}
] if v.config_map_import != null && v.enabled == true
]) : "${pair.map_key}-${pair.secret_id}" => pair.secret_id
}
id = each.value
}
resource "kubernetes_config_map_v1" "configmap_import" {
for_each = { for key, value in data.bitwarden-secrets_secret.configmap_import : key => value }
metadata {
name = each.value.note
namespace = split("__", each.value.key)[0]
}
data = yamldecode(each.value.value)
}
data "bitwarden-secrets_secret" "secret_import" {
for_each = {
for pair in flatten([
for k, v in var.kubernetes : [
for id in v.secret_import : {
map_key = k
secret_id = id
}
] if v.secret_import != null && v.enabled == true
]) : "${pair.map_key}-${pair.secret_id}" => pair.secret_id
}
id = each.value
}
resource "kubernetes_secret_v1" "secret_import" {
for_each = { for key, value in data.bitwarden-secrets_secret.secret_import : key => value }
metadata {
name = each.value.note
namespace = split("__", each.value.key)[0]
}
data = yamldecode(each.value.value)
}
resource "kubernetes_secret_v1" "automatic-database-secret" {
for_each = { for key, value in var.kubernetes : key => value if value.database != null && value.enabled == true }
metadata {
name = "${each.key}-db-terraform"
namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key)
}
data = {
DB_DATABASE_NAME = "${resource.bitwarden-secrets_secret.automatic_bitwarden_secret_db_name[each.key].value}"
POSTGRES_DB = "${resource.bitwarden-secrets_secret.automatic_bitwarden_secret_db_name[each.key].value}"
MYSQL_DATABASE = "${resource.bitwarden-secrets_secret.automatic_bitwarden_secret_db_name[each.key].value}"
PGDATABASE = "${resource.bitwarden-secrets_secret.automatic_bitwarden_secret_db_name[each.key].value}"
DB_HOST = "${resource.bitwarden-secrets_secret.automatic_bitwarden_secret_db_host[each.key].value}"
PGHOST = "${resource.bitwarden-secrets_secret.automatic_bitwarden_secret_db_host[each.key].value}"
DB_PASSWORD = "${resource.bitwarden-secrets_secret.automatic_bitwarden_secret_db_password[each.key].value}"
MYSQL_PASSWORD = "${resource.bitwarden-secrets_secret.automatic_bitwarden_secret_db_password[each.key].value}"
MYSQL_ROOT_PASSWORD = "${resource.bitwarden-secrets_secret.automatic_bitwarden_secret_db_password[each.key].value}"
POSTGRES_PASSWORD = "${resource.bitwarden-secrets_secret.automatic_bitwarden_secret_db_password[each.key].value}"
PGPASSWORD = "${resource.bitwarden-secrets_secret.automatic_bitwarden_secret_db_password[each.key].value}"
DB_USERNAME = "${resource.bitwarden-secrets_secret.automatic_bitwarden_secret_db_username[each.key].value}"
POSTGRES_USER = "${resource.bitwarden-secrets_secret.automatic_bitwarden_secret_db_username[each.key].value}"
MYSQL_USER = "${resource.bitwarden-secrets_secret.automatic_bitwarden_secret_db_username[each.key].value}"
PGUSER = "${resource.bitwarden-secrets_secret.automatic_bitwarden_secret_db_username[each.key].value}"
}
}
resource "bitwarden-secrets_secret" "automatic_bitwarden_secret_db_username" {
for_each = { for key, value in var.kubernetes : key => value if value.database != null && value.enabled == true }
key = "${each.key}__db__username"
value = try(each.value.database.username, each.key)
project_id = "b5fc4c48-e951-442f-97ca-b3e800c143cd"
}
resource "bitwarden-secrets_secret" "automatic_bitwarden_secret_db_password" {
for_each = { for key, value in var.kubernetes : key => value if value.database != null && value.enabled == true }
key = "${each.key}__db__password"
project_id = "b5fc4c48-e951-442f-97ca-b3e800c143cd"
length = 32
special = true
min_special = 5
avoid_ambiguous = true
}
resource "bitwarden-secrets_secret" "automatic_bitwarden_secret_db_host" {
for_each = { for key, value in var.kubernetes : key => value if value.database != null && value.enabled == true }
key = "${each.key}__db__host"
project_id = "b5fc4c48-e951-442f-97ca-b3e800c143cd"
value = "${each.key}-db-svc.${coalesce(each.value.namespace, each.value.connected_namespace, each.key)}.svc"
}
resource "bitwarden-secrets_secret" "automatic_bitwarden_secret_db_port" {
for_each = { for key, value in var.kubernetes : key => value if value.database != null && value.enabled == true }
key = "${each.key}__db__port"
project_id = "b5fc4c48-e951-442f-97ca-b3e800c143cd"
value = try(each.value.database.port, 5432)
}
resource "bitwarden-secrets_secret" "automatic_bitwarden_secret_db_name" {
for_each = { for key, value in var.kubernetes : key => value if value.database != null && value.enabled == true }
key = "${each.key}__db__name"
project_id = "b5fc4c48-e951-442f-97ca-b3e800c143cd"
value = try(each.value.database.name, each.key)
}
output "fromressource" {
value = {
key = resource.kubernetes_service_v1.automatic_service_database
}
sensitive = true
}
+45
View File
@@ -0,0 +1,45 @@
############################################
# config file for ${name_site}
############################################
upstream ${name_site}_backend {
server ${name_service};
server 1.1.1.1 backup;
}
server {
server_name ${name_site}.tryton.geeraert.eu www.${name_site}.tryton.geeraert.eu;
location / {
proxy_pass http://${name_site}_backend;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
}
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
access_log /var/log/nginx/access.log my_custom_format;
access_log /var/log/nginx/ip_audit.log ip_audit;
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/live/tryton.geeraert.eu/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/live/tryton.geeraert.eu/privkey.pem;
}
server {
if ($host = www.${name_site}.tryton.geeraert.eu) {
return 301 https://$host$request_uri;
}
if ($host = ${name_site}.tryton.geeraert.eu) {
return 301 https://$host$request_uri;
}
server_name www.${name_site}.tryton.geeraert.eu ${name_site}.tryton.geeraert.eu;
listen 80;
return 404;
}
+18573 -253
View File
File diff suppressed because one or more lines are too long
+18694 -276
View File
File diff suppressed because one or more lines are too long
+1360 -54
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff