Compare commits
27
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa5826f6a4 | ||
|
|
48cc59e735 | ||
|
|
1ba0438b38 | ||
|
|
ba746c9c41 | ||
|
|
13c8ebe109 | ||
|
|
0327588463 | ||
|
|
b094e78620 | ||
|
|
fcdcb0102d | ||
|
|
2b168e5e34 | ||
|
|
edea22d4d1 | ||
|
|
6f7ae0e523 | ||
|
|
e742931489 | ||
|
|
6d3a57eaa1 | ||
|
|
6fb53dace3 | ||
|
|
a5fd5006df | ||
|
|
84550b64dc | ||
|
|
6dc1f5427d | ||
|
|
8a13ca3967 | ||
|
|
0ba77fa09a | ||
|
|
6af77be624 | ||
|
|
a8be503624 | ||
|
|
d40ddb48c5 | ||
|
|
c9a3dfd85c | ||
|
|
3e92d3bf76 | ||
|
|
1b7720d910 | ||
|
|
a945f5e141 | ||
|
|
e01f8c8462 |
@@ -35,3 +35,7 @@ override.tf.json
|
|||||||
# Ignore CLI configuration files
|
# Ignore CLI configuration files
|
||||||
.terraformrc
|
.terraformrc
|
||||||
terraform.rc
|
terraform.rc
|
||||||
|
|
||||||
|
module.tf.save*
|
||||||
|
terraform.tfstate*
|
||||||
|
.terraform.lock.hcl
|
||||||
|
|||||||
@@ -14,10 +14,11 @@ Define the image tag
|
|||||||
### pvc =
|
### pvc =
|
||||||
***optional***
|
***optional***
|
||||||
specifiy the pvc details
|
specifiy the pvc details
|
||||||
#### name = string
|
## name = string
|
||||||
Name of the PVC
|
Name of the PVC
|
||||||
|
|
||||||
#### pvc = optional(bool, false)
|
|
||||||
|
## pvc = optional(bool, false)
|
||||||
***PVC - Hostpath - Configmap shouldn't be specifiy at the same time***
|
***PVC - Hostpath - Configmap shouldn't be specifiy at the same time***
|
||||||
Boolean to specify if it is a PVC
|
Boolean to specify if it is a PVC
|
||||||
[Example](https://gitea.tryton.geeraert.eu/pi-ux-ce/Terraform_kube#volume-as-pvc)
|
[Example](https://gitea.tryton.geeraert.eu/pi-ux-ce/Terraform_kube#volume-as-pvc)
|
||||||
@@ -29,6 +30,8 @@ Boolean to specify if it is a hostpath
|
|||||||
[Example](https://gitea.tryton.geeraert.eu/pi-ux-ce/Terraform_kube#volume-as-hostpath)
|
[Example](https://gitea.tryton.geeraert.eu/pi-ux-ce/Terraform_kube#volume-as-hostpath)
|
||||||
#### pvc_size = optional(string)
|
#### pvc_size = optional(string)
|
||||||
#### mount_path = string
|
#### mount_path = string
|
||||||
|
#### storage_class_name = optional(string, "nfs-storage-intelligent")
|
||||||
|
This is the storage class, by default it will use nfs-storage-intelligent but it can be changed to something more suitable
|
||||||
### environment = optional(map(object({
|
### environment = optional(map(object({
|
||||||
### name = optional(string)
|
### name = optional(string)
|
||||||
### value = optional(string)
|
### value = optional(string)
|
||||||
@@ -63,7 +66,140 @@ Not required , the object name will be used if not specified
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
## example
|
## examples
|
||||||
|
|
||||||
|
### enabled
|
||||||
|
|
||||||
|
Disable the whole object , including PVC , secrets , deployments and services
|
||||||
|
If you just want to remove the pod , you should consider set the replica option to 0
|
||||||
|
|
||||||
|
```
|
||||||
|
enabled = false
|
||||||
|
```
|
||||||
|
|
||||||
|
### replicas
|
||||||
|
|
||||||
|
Set the number of replicas , can be used tyo keep the ressources and only remove the pods
|
||||||
|
|
||||||
|
```
|
||||||
|
replicas = 0
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### namespace
|
||||||
|
|
||||||
|
Specify a different namespace , by default it will take the name of the object otherwise
|
||||||
|
|
||||||
|
```
|
||||||
|
namespace = "testnginx"
|
||||||
|
```
|
||||||
|
|
||||||
|
### image
|
||||||
|
|
||||||
|
Specify the image to use , mandatory
|
||||||
|
|
||||||
|
```
|
||||||
|
image = "nginx:latest"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Database
|
||||||
|
|
||||||
|
Specifying the object (even empty) will automatically create all the objects related to the database (service,deployment,...)
|
||||||
|
|
||||||
|
```
|
||||||
|
database = {}
|
||||||
|
```
|
||||||
|
#### Custom images version
|
||||||
|
|
||||||
|
You can select a custom image, by default it will use postgresql , if you do change the image , check if teh port is the same , otgherwise it will use postgresql defaut port
|
||||||
|
|
||||||
|
```
|
||||||
|
database = {
|
||||||
|
"image" = "lscr.io/linuxserver/mariadb"
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Custom database port
|
||||||
|
|
||||||
|
You can select a custom database port , by default it will use postgresql , remember to update the secret for that
|
||||||
|
The database service will be automatically updated to reflect this port as well
|
||||||
|
|
||||||
|
```
|
||||||
|
database = {
|
||||||
|
"image" = "lscr.io/linuxserver/mariadb"
|
||||||
|
"port" = 3306
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Custom mountpath
|
||||||
|
|
||||||
|
You can select a custom mount path, by default it will use postgresql data folder (/var/lib/postgresql/data)
|
||||||
|
|
||||||
|
```
|
||||||
|
database = {
|
||||||
|
"mountPath" = "/config"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
### redis
|
||||||
|
|
||||||
|
Specifying the object (even empty) will automatically create all the objects related to Redis (service,deployment,...)
|
||||||
|
|
||||||
|
```
|
||||||
|
redis = {}
|
||||||
|
```
|
||||||
|
#### Custom images version
|
||||||
|
|
||||||
|
You can select a custom image, by default it will use redis version 7 (docker.io/library/redis:7)
|
||||||
|
|
||||||
|
```
|
||||||
|
redis = {
|
||||||
|
image = "docker.io/library/redis:7"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Extra manifest
|
||||||
|
|
||||||
|
You can add some extra manifest using this command
|
||||||
|
```
|
||||||
|
extra_manifest = ["/opt/kubernetes/Bookstack_kube/Bookstack.configmap.yaml","/opt/kubernetes/Bookstack_kube/Bookstack.secret.yaml"]
|
||||||
|
```
|
||||||
|
|
||||||
|
### environment
|
||||||
|
|
||||||
|
#### Simple environment variables
|
||||||
|
|
||||||
|
You can specifiy a variable through the environment object
|
||||||
|
```
|
||||||
|
environment = {
|
||||||
|
PORT = {
|
||||||
|
value = "80"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
#### environment_variables from a secret
|
||||||
|
|
||||||
|
```
|
||||||
|
environment = {
|
||||||
|
MYSQL_ROOT_PASSWORD = {
|
||||||
|
value_from = {
|
||||||
|
secret_key_ref = {
|
||||||
|
name = "bookstack-credentials"
|
||||||
|
key = "DB_PASS"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Secret reference
|
||||||
|
|
||||||
|
You can have your secret fully mounted instead of specifiying all the variables
|
||||||
|
secret_ref = ["secret1"]
|
||||||
|
|
||||||
### Volumes
|
### Volumes
|
||||||
#### Volume as PVC
|
#### Volume as PVC
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
POSTGRES_DB: cGFwZXJsZXNz
|
||||||
|
POSTGRES_USER: cGFwZXJsZXNz
|
||||||
|
POSTGRES_PASSWORD: cGFwZXJsZXNz
|
||||||
|
PAPERLESS_ADMIN_USER: YWRtaW4=
|
||||||
|
PAPERLESS_ADMIN_PASSWORD: YWRtaW4=
|
||||||
|
POSTGRES_HOST: cGFwZXItZGItc3Zj
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: paperless-credentials
|
||||||
|
namespace: paper
|
||||||
|
type: Opaque
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
VPN_DNS_IP: MTAuMi4wLjE=
|
||||||
|
VPN_ENDPOINT_IP: MjEyLjguMjUzLjEzNw==
|
||||||
|
VPN_ENDPOINT_PORT: NTE4MjA=
|
||||||
|
WIREGUARD_PRIVATE_KEY: Y0grY0hLd3FMeXV3UlVlZy8wRjFYWVlDQVM4bkQwWGsxNmVOQlVLc2tYbz0=
|
||||||
|
WIREGUARD_PUBLIC_KEY: VVJwZVp4dHlVWEFVVUEwTVdjRmRDU2E3RitNdmNoSjRlTlNKVWV0S0VHaz0=
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
name: gluetun-secret-netherland
|
||||||
|
namespace: tservarr
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
prowlarr_add_bulk_indexer.sh: |
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# install package with apk
|
||||||
|
apk add curl jq
|
||||||
|
# Base URL and API key
|
||||||
|
BASE_URL="https://tprowlarr.tryton.geeraert.eu"
|
||||||
|
API_KEY="c5655e0b915d46dbb68d80f40a2daae4"
|
||||||
|
|
||||||
|
APP_PROFILE_ID=1 # Set this to a valid App Profile Id
|
||||||
|
|
||||||
|
# Get the list of all available indexers
|
||||||
|
available_indexers=$(curl -s -X GET "$BASE_URL/api/v1/indexer/schema" \
|
||||||
|
-H "accept: application/json" \
|
||||||
|
-H "X-Api-Key: $API_KEY")
|
||||||
|
|
||||||
|
# Loop through each indexer and add it to Prowlarr
|
||||||
|
echo "$available_indexers" | jq -c '.[]' | while read -r indexer; do
|
||||||
|
indexer_name=$(echo "$indexer" | jq -r '.name')
|
||||||
|
indexer_settings=$(echo "$indexer" | jq -c '.')
|
||||||
|
|
||||||
|
# Add the AppProfileId to the indexer settings
|
||||||
|
indexer_settings=$(echo "$indexer_settings" | jq --argjson appProfileId "$APP_PROFILE_ID" '. + {AppProfileId: $appProfileId}')
|
||||||
|
|
||||||
|
echo "Adding indexer: $indexer_name"
|
||||||
|
|
||||||
|
curl -s -X POST "$BASE_URL/api/v1/indexer" \
|
||||||
|
-H "accept: application/json" \
|
||||||
|
-H "X-Api-Key: $API_KEY" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$indexer_settings"
|
||||||
|
|
||||||
|
echo "Indexer $indexer_name added."
|
||||||
|
done
|
||||||
|
return 0
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
kubectl.kubernetes.io/last-applied-configuration: |
|
||||||
|
{"apiVersion":"v1","data":{"prowlarr_add_bulk_indexer.sh":"#!/bin/bash\n\n# Base URL and API key\nBASE_URL=\"https://prowlarr.tryton.geeraert.eu\"\nAPI_KEY=\"0cb77d794ab74f158daaae044ab850ee\"\n\nAPP_PROFILE_ID=1 # Set this to a valid App Profile Id\n\n# Get the list of all available indexers\navailable_indexers=$(curl -s -X GET \"$BASE_URL/api/v1/indexer/schema\" \\\n -H \"accept: application/json\" \\\n -H \"X-Api-Key: $API_KEY\")\n\n# Loop through each indexer and add it to Prowlarr\necho \"$available_indexers\" | jq -c '.[]' | while read -r indexer; do\n indexer_name=$(echo \"$indexer\" | jq -r '.name')\n indexer_settings=$(echo \"$indexer\" | jq -c '.')\n\n # Add the AppProfileId to the indexer settings\n indexer_settings=$(echo \"$indexer_settings\" | jq --argjson appProfileId \"$APP_PROFILE_ID\" '. + {AppProfileId: $appProfileId}')\n\n echo \"Adding indexer: $indexer_name\"\n\n curl -s -X POST \"$BASE_URL/api/v1/indexer\" \\\n -H \"accept: application/json\" \\\n -H \"X-Api-Key: $API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d \"$indexer_settings\"\n\n echo \"Indexer $indexer_name added.\"\ndone\n"},"kind":"ConfigMap","metadata":{"annotations":{},"creationTimestamp":null,"name":"prowlarr-add-bulk-indexer","namespace":"servarr"}}
|
||||||
|
creationTimestamp: "2025-02-24T14:53:38Z"
|
||||||
|
name: prowlarr-add-bulk-indexer
|
||||||
|
namespace: tservarr
|
||||||
|
resourceVersion: "101531049"
|
||||||
|
uid: daa8c869-779c-49f2-a2ca-bad2d6d77035
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: prowlarr-bulk-add-indexers
|
||||||
|
namespace: tservarr
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: prowlarr-bulk-add-indexers
|
||||||
|
image: alpine
|
||||||
|
imagePullPolicy: Always
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /config
|
||||||
|
name: scripts
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- /config/prowlarr_add_bulk_indexer.sh
|
||||||
|
# command: ["chmod","+x","/config/prowlarr_add_bulk_indexer.sh",";","./config/prowlarr_add_bulk_indexer.sh"]
|
||||||
|
restartPolicy: Never
|
||||||
|
volumes:
|
||||||
|
- configMap:
|
||||||
|
defaultMode: 365
|
||||||
|
name: prowlarr-add-bulk-indexer
|
||||||
|
name: scripts
|
||||||
|
backoffLimit: 4
|
||||||
|
|
||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Check if username is provided
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Usage: $0 <reddit_username> <destination_folder>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
USER="$1"
|
||||||
|
DEST_FOLDER="${2:-./${USER}_images}"
|
||||||
|
USER_AGENT="Mozilla/5.0 (compatible; RedditImageDownloader/1.0)"
|
||||||
|
|
||||||
|
mkdir -p "$DEST_FOLDER"
|
||||||
|
|
||||||
|
AFTER=""
|
||||||
|
BASE_URL="https://www.reddit.com/user/$USER/submitted/.json"
|
||||||
|
|
||||||
|
echo "Fetching all image posts from user $USER..."
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
# Build URL with pagination
|
||||||
|
if [ -z "$AFTER" ]; then
|
||||||
|
URL="${BASE_URL}?limit=100"
|
||||||
|
else
|
||||||
|
URL="${BASE_URL}?limit=100&after=${AFTER}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fetch posts
|
||||||
|
RESPONSE=$(curl -s -A "$USER_AGENT" "$URL")
|
||||||
|
|
||||||
|
# Validate JSON
|
||||||
|
if ! echo "$RESPONSE" | jq empty 2>/dev/null; then
|
||||||
|
echo "Error: Failed to fetch or parse JSON. Exiting."
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract image URLs
|
||||||
|
IMAGE_URLS=$(echo "$RESPONSE" | jq -r '.data.children[] | select(.data.url | test("\\.(jpg|jpeg|png|gif)$")) | .data.url')
|
||||||
|
|
||||||
|
# Exit if no more images found
|
||||||
|
if [ -z "$IMAGE_URLS" ]; then
|
||||||
|
echo "No more images found on this page."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Download images
|
||||||
|
echo "$IMAGE_URLS" | while read -r image_url; do
|
||||||
|
[ -z "$image_url" ] && continue
|
||||||
|
FILENAME=$(basename "$image_url")
|
||||||
|
if [ ! -f "$DEST_FOLDER/$FILENAME" ]; then
|
||||||
|
echo "Downloading $FILENAME..."
|
||||||
|
curl -s -A "$USER_AGENT" -o "$DEST_FOLDER/$FILENAME" "$image_url"
|
||||||
|
else
|
||||||
|
echo "Skipping existing file $FILENAME"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Get 'after' token for pagination
|
||||||
|
AFTER=$(echo "$RESPONSE" | jq -r '.data.after')
|
||||||
|
if [ "$AFTER" == "null" ] || [ -z "$AFTER" ]; then
|
||||||
|
echo "Reached end of posts."
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Download complete. Images saved to $DEST_FOLDER"
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
reddit_downloader.sh: |
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Check if username is provided
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Usage: $0 <reddit_username> <destination_folder>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
USER="$1"
|
||||||
|
DEST_FOLDER="${2:-./${USER}_images}"
|
||||||
|
USER_AGENT="Mozilla/5.0 (compatible; RedditImageDownloader/1.0)"
|
||||||
|
|
||||||
|
mkdir -p "$DEST_FOLDER"
|
||||||
|
|
||||||
|
AFTER=""
|
||||||
|
BASE_URL="https://www.reddit.com/user/$USER/submitted/.json"
|
||||||
|
|
||||||
|
echo "Fetching all image posts from user $USER..."
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
# Build URL with pagination
|
||||||
|
if [ -z "$AFTER" ]; then
|
||||||
|
URL="${BASE_URL}?limit=100"
|
||||||
|
else
|
||||||
|
URL="${BASE_URL}?limit=100&after=${AFTER}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fetch posts
|
||||||
|
RESPONSE=$(curl -s -A "$USER_AGENT" "$URL")
|
||||||
|
|
||||||
|
# Validate JSON
|
||||||
|
if ! echo "$RESPONSE" | jq empty 2>/dev/null; then
|
||||||
|
echo "Error: Failed to fetch or parse JSON. Exiting."
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract image URLs
|
||||||
|
IMAGE_URLS=$(echo "$RESPONSE" | jq -r '.data.children[] | select(.data.url | test("\\.(jpg|jpeg|png|gif)$")) | .data.url')
|
||||||
|
|
||||||
|
# Exit if no more images found
|
||||||
|
if [ -z "$IMAGE_URLS" ]; then
|
||||||
|
echo "No more images found on this page."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Download images
|
||||||
|
echo "$IMAGE_URLS" | while read -r image_url; do
|
||||||
|
[ -z "$image_url" ] && continue
|
||||||
|
FILENAME=$(basename "$image_url")
|
||||||
|
if [ ! -f "$DEST_FOLDER/$FILENAME" ]; then
|
||||||
|
echo "Downloading $FILENAME..."
|
||||||
|
curl -s -A "$USER_AGENT" -o "$DEST_FOLDER/$FILENAME" "$image_url"
|
||||||
|
else
|
||||||
|
echo "Skipping existing file $FILENAME"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Get 'after' token for pagination
|
||||||
|
AFTER=$(echo "$RESPONSE" | jq -r '.data.after')
|
||||||
|
if [ "$AFTER" == "null" ] || [ -z "$AFTER" ]; then
|
||||||
|
echo "Reached end of posts."
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Download complete. Images saved to $DEST_FOLDER"
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
name: stash-reddit-dowloader
|
||||||
|
namespace: stash
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: stash-reddit-dowloader
|
||||||
|
namespace: stash
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: stash-reddit-dowloader
|
||||||
|
image: alpine
|
||||||
|
imagePullPolicy: Always
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /config
|
||||||
|
name: scripts
|
||||||
|
- mountPath: /data
|
||||||
|
mountPropagation: None
|
||||||
|
name: data-pvc
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- sleep 3600
|
||||||
|
# - /config/reddit_downloader.sh Countem1a /data
|
||||||
|
restartPolicy: Never
|
||||||
|
volumes:
|
||||||
|
- configMap:
|
||||||
|
defaultMode: 365
|
||||||
|
name: stash-reddit-dowloader
|
||||||
|
name: scripts
|
||||||
|
- name: data-pvc
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: data-pvc
|
||||||
|
backoffLimit: 4
|
||||||
|
|
||||||
@@ -17,9 +17,9 @@ variable "kubernetes" {
|
|||||||
config_map = optional(bool, false)
|
config_map = 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")
|
||||||
mount_path = string
|
mount_path = string
|
||||||
})))
|
})))
|
||||||
#secret = optional(map(string))
|
|
||||||
environment = optional(map(object({
|
environment = optional(map(object({
|
||||||
name = optional(string)
|
name = optional(string)
|
||||||
value = optional(string)
|
value = optional(string)
|
||||||
@@ -29,11 +29,14 @@ variable "kubernetes" {
|
|||||||
key = optional(string, null)
|
key = optional(string, null)
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
# secret_name = optional(string)
|
|
||||||
})))
|
})))
|
||||||
replicas = optional(number, 1)
|
replicas = optional(number, 1)
|
||||||
namespace = optional(string)
|
namespace = optional(string)
|
||||||
service_port = optional(number)
|
connected_namespace = optional(string, "")
|
||||||
|
# namespace = optional(string,coalesce(connected_namespace,""))
|
||||||
|
#block_namespace_creation = optional(bool, false)
|
||||||
|
service_port = optional(list(number))
|
||||||
|
service_type = optional(string, "ClusterIP")
|
||||||
service_name = optional(string)
|
service_name = optional(string)
|
||||||
liveness_tcp_socket = optional(number)
|
liveness_tcp_socket = optional(number)
|
||||||
liveness_http_get = optional(string)
|
liveness_http_get = optional(string)
|
||||||
@@ -44,13 +47,16 @@ variable "kubernetes" {
|
|||||||
secret_ref = optional(list(string))
|
secret_ref = optional(list(string))
|
||||||
config_map_ref = optional(list(string))
|
config_map_ref = optional(list(string))
|
||||||
extra_manifest = optional(list(string))
|
extra_manifest = optional(list(string))
|
||||||
requirements = optional(map(string), {
|
requirements = optional(map(string))
|
||||||
limits-cpu = "800m"
|
# requirements = optional(map(string), {
|
||||||
limits-memory = "500Mi"
|
# limits-cpu = "800m"
|
||||||
requests-cpu = "200m"
|
# limits-memory = "500Mi"
|
||||||
requests-memory = "200Mi"
|
# requests-cpu = "200m"
|
||||||
})
|
# requests-memory = "200Mi"
|
||||||
|
# })
|
||||||
|
dns_nameservers = optional(string)
|
||||||
environment_variables = optional(map(string), { name = "value" })
|
environment_variables = optional(map(string), { name = "value" })
|
||||||
|
security_context = optional(bool, false)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -64,9 +70,8 @@ locals {
|
|||||||
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
|
||||||
# database = value.database
|
storage_class_name = pvc.storage_class_name
|
||||||
# database = pvc.database
|
namespace = coalesce(value.namespace, value.connected_namespace, key)
|
||||||
namespace = coalesce(value.namespace, key)
|
|
||||||
}] if value.enabled == true && value.pvc != null
|
}] if value.enabled == true && value.pvc != null
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
@@ -85,7 +90,7 @@ locals {
|
|||||||
data "kubernetes_all_namespaces" "allns" {}
|
data "kubernetes_all_namespaces" "allns" {}
|
||||||
|
|
||||||
resource "kubernetes_namespace" "automatic" {
|
resource "kubernetes_namespace" "automatic" {
|
||||||
for_each = { for key, value in var.kubernetes : key => value if value.enabled == true }
|
for_each = { for key, value in var.kubernetes : key => value if value.enabled == true && value.connected_namespace == "" }
|
||||||
metadata {
|
metadata {
|
||||||
annotations = {
|
annotations = {
|
||||||
name = coalesce(each.value.namespace, each.key)
|
name = coalesce(each.value.namespace, each.key)
|
||||||
@@ -125,7 +130,7 @@ resource "kubernetes_manifest" "service" {
|
|||||||
resource "kubernetes_persistent_volume_claim" "automatic-pvc" {
|
resource "kubernetes_persistent_volume_claim" "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 }
|
||||||
metadata {
|
metadata {
|
||||||
namespace = each.value.namespace
|
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"
|
||||||
@@ -133,7 +138,7 @@ resource "kubernetes_persistent_volume_claim" "automatic-pvc" {
|
|||||||
}
|
}
|
||||||
spec {
|
spec {
|
||||||
access_modes = ["ReadWriteMany"]
|
access_modes = ["ReadWriteMany"]
|
||||||
storage_class_name = "nfs-storage-intelligent"
|
storage_class_name = each.value.storage_class_name
|
||||||
resources {
|
resources {
|
||||||
requests = {
|
requests = {
|
||||||
storage = each.value.pvc_size
|
storage = each.value.pvc_size
|
||||||
@@ -144,7 +149,7 @@ resource "kubernetes_persistent_volume_claim" "automatic-pvc" {
|
|||||||
resource "kubernetes_persistent_volume_claim" "automatic-pvc-database" {
|
resource "kubernetes_persistent_volume_claim" "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 = each.value.namespace
|
namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key)
|
||||||
name = "${each.key}-db-pvc"
|
name = "${each.key}-db-pvc"
|
||||||
labels = {
|
labels = {
|
||||||
deployment_method = "Terraform"
|
deployment_method = "Terraform"
|
||||||
@@ -164,7 +169,7 @@ resource "kubernetes_persistent_volume_claim" "automatic-pvc-database" {
|
|||||||
resource "kubernetes_persistent_volume_claim" "automatic-pvc-redis" {
|
resource "kubernetes_persistent_volume_claim" "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 = each.value.namespace
|
namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key)
|
||||||
name = "${each.key}-redis-pvc"
|
name = "${each.key}-redis-pvc"
|
||||||
labels = {
|
labels = {
|
||||||
deployment_method = "Terraform"
|
deployment_method = "Terraform"
|
||||||
@@ -185,19 +190,35 @@ resource "kubernetes_service" "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"
|
||||||
namespace = coalesce(each.value.namespace, each.key)
|
namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key)
|
||||||
labels = {
|
labels = {
|
||||||
deployment_method = "Terraform"
|
deployment_method = "Terraform"
|
||||||
}
|
}
|
||||||
|
annotations = each.value.service_type == "LoadBalancer" ? {
|
||||||
|
"metallb.universe.tf/ip-allocated-from-pool" = "first-pool"
|
||||||
|
} : {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
spec {
|
spec {
|
||||||
selector = {
|
selector = {
|
||||||
app = each.key
|
app = each.key
|
||||||
}
|
}
|
||||||
port {
|
dynamic "port" {
|
||||||
port = each.value.service_port
|
for_each = each.value.service_port != null ? each.value.service_port : []
|
||||||
target_port = each.value.service_port
|
content {
|
||||||
|
port = port.value
|
||||||
|
target_port = port.value
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# port {
|
||||||
|
# port = each.value.service_port
|
||||||
|
# target_port = each.value.service_port
|
||||||
|
# }
|
||||||
|
type = each.value.service_type
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -209,7 +230,7 @@ resource "kubernetes_service" "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.key)
|
namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key)
|
||||||
labels = {
|
labels = {
|
||||||
deployment_method = "Terraform"
|
deployment_method = "Terraform"
|
||||||
}
|
}
|
||||||
@@ -223,7 +244,6 @@ resource "kubernetes_service" "automatic_service_database" {
|
|||||||
target_port = try(each.value.database.port, 5432)
|
target_port = try(each.value.database.port, 5432)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -235,7 +255,7 @@ resource "kubernetes_service" "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"
|
||||||
namespace = coalesce(each.value.namespace, each.key)
|
namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key)
|
||||||
labels = {
|
labels = {
|
||||||
deployment_method = "Terraform"
|
deployment_method = "Terraform"
|
||||||
}
|
}
|
||||||
@@ -256,8 +276,9 @@ resource "kubernetes_service" "automatic_service_redis" {
|
|||||||
resource "kubernetes_deployment_v1" "automatic" {
|
resource "kubernetes_deployment_v1" "automatic" {
|
||||||
for_each = { for key, value in var.kubernetes : key => value if value.enabled == true }
|
for_each = { for key, value in var.kubernetes : key => value if value.enabled == true }
|
||||||
metadata {
|
metadata {
|
||||||
namespace = coalesce(each.value.namespace, each.key)
|
namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key)
|
||||||
name = coalesce(each.value.namespace, each.key)
|
name = coalesce(each.value.name, each.key)
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
app = each.key
|
app = each.key
|
||||||
deployment_method = "Terraform"
|
deployment_method = "Terraform"
|
||||||
@@ -286,10 +307,10 @@ resource "kubernetes_deployment_v1" "automatic" {
|
|||||||
image = each.value.image
|
image = each.value.image
|
||||||
name = coalesce(each.value.name, each.key)
|
name = coalesce(each.value.name, each.key)
|
||||||
dynamic "port" {
|
dynamic "port" {
|
||||||
for_each = each.value.service_port != null ? [""] : []
|
for_each = each.value.service_port != null ? each.value.service_port : []
|
||||||
content {
|
content {
|
||||||
container_port = each.value.service_port
|
container_port = port.value
|
||||||
name = each.key
|
name = "${each.key}-${port.value}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,7 +369,20 @@ resource "kubernetes_deployment_v1" "automatic" {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dynamic "resources" {
|
||||||
|
for_each = each.value.requirements != null ? [1] : []
|
||||||
|
content {
|
||||||
|
limits = {
|
||||||
|
cpu = each.value.requirements.limits-cpu
|
||||||
|
memory = each.value.requirements.limits-memory
|
||||||
|
}
|
||||||
|
requests = {
|
||||||
|
cpu = each.value.requirements.requests-cpu
|
||||||
|
memory = each.value.requirements.requests-memory
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# resources {
|
# resources {
|
||||||
# limits = {
|
# limits = {
|
||||||
@@ -361,6 +395,15 @@ resource "kubernetes_deployment_v1" "automatic" {
|
|||||||
# }
|
# }
|
||||||
# }
|
# }
|
||||||
|
|
||||||
|
dynamic "security_context" {
|
||||||
|
for_each = each.value.security_context == true ? [1] : []
|
||||||
|
content {
|
||||||
|
privileged = true
|
||||||
|
#capabilities = {
|
||||||
|
# add : ["NET_ADMIN", "NET_RAW"]
|
||||||
|
#}
|
||||||
|
}
|
||||||
|
}
|
||||||
dynamic "liveness_probe" {
|
dynamic "liveness_probe" {
|
||||||
for_each = each.value.liveness_tcp_socket != null || each.value.liveness_http_get != null ? [""] : []
|
for_each = each.value.liveness_tcp_socket != null || each.value.liveness_http_get != null ? [""] : []
|
||||||
content {
|
content {
|
||||||
@@ -371,7 +414,6 @@ resource "kubernetes_deployment_v1" "automatic" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dynamic "http_get" {
|
dynamic "http_get" {
|
||||||
for_each = each.value.liveness_http_get != null ? [""] : []
|
for_each = each.value.liveness_http_get != null ? [""] : []
|
||||||
content {
|
content {
|
||||||
@@ -385,7 +427,13 @@ resource "kubernetes_deployment_v1" "automatic" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dynamic "dns_config" {
|
||||||
|
for_each = each.value.dns_nameservers != null ? [1] : []
|
||||||
|
content {
|
||||||
|
nameservers = [each.value.dns_nameservers]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
dynamic "volume" {
|
dynamic "volume" {
|
||||||
for_each = each.value.pvc != null ? each.value.pvc : {}
|
for_each = each.value.pvc != null ? each.value.pvc : {}
|
||||||
@@ -429,7 +477,7 @@ resource "kubernetes_deployment_v1" "database-automatic" {
|
|||||||
|
|
||||||
|
|
||||||
metadata {
|
metadata {
|
||||||
namespace = coalesce(each.value.namespace, each.key)
|
namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key)
|
||||||
name = "${coalesce(each.value.namespace, each.key)}-db"
|
name = "${coalesce(each.value.namespace, each.key)}-db"
|
||||||
labels = {
|
labels = {
|
||||||
app = each.key
|
app = each.key
|
||||||
@@ -554,7 +602,7 @@ resource "kubernetes_deployment_v1" "redis-automatic" {
|
|||||||
|
|
||||||
|
|
||||||
metadata {
|
metadata {
|
||||||
namespace = coalesce(each.value.namespace, each.key)
|
namespace = coalesce(each.value.namespace, each.value.connected_namespace, each.key)
|
||||||
name = "${coalesce(each.value.namespace, each.key)}-redis"
|
name = "${coalesce(each.value.namespace, each.key)}-redis"
|
||||||
labels = {
|
labels = {
|
||||||
app = each.key
|
app = each.key
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
data:
|
|
||||||
POSTGRES_DB: dGVzdA==
|
|
||||||
POSTGRES_USER: dGVzdA==
|
|
||||||
POSTGRES_PASSWORD: dGVzdA==
|
|
||||||
kind: Secret
|
|
||||||
metadata:
|
|
||||||
name: mysecret
|
|
||||||
namespace: onitama
|
|
||||||
type: Opaque
|
|
||||||
+801
-165
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user