Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minio enterprise #8

Merged
merged 117 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
766c71b
test ci
stavros-k Aug 13, 2024
974cc17
make sure if docker daemon does not start any containers, we fail
stavros-k Aug 13, 2024
9cb7f3f
fix image
stavros-k Aug 13, 2024
31fd10b
add minio enterprise
stavros-k May 14, 2024
518af83
test perms
stavros-k May 14, 2024
23e5e36
update lib funcs
stavros-k May 14, 2024
04a7819
named arsg
stavros-k May 14, 2024
d77d915
fix indents
stavros-k May 14, 2024
7d86300
imports
stavros-k May 14, 2024
ae0ccfa
fix identation
stavros-k May 14, 2024
3bf1f43
check if db is needed
stavros-k May 14, 2024
e1fc01f
add todo
stavros-k May 14, 2024
845f42b
one omre
stavros-k May 14, 2024
c919573
add dep
stavros-k May 14, 2024
0451bfe
fix
stavros-k May 14, 2024
f20c224
add macros
stavros-k May 16, 2024
e1e2057
auto perms
stavros-k May 16, 2024
db0cbca
remove dummy file
stavros-k May 16, 2024
b350d21
fix values
stavros-k May 16, 2024
676ac1e
updates
stavros-k May 21, 2024
09f3ee3
minio perms
stavros-k May 21, 2024
e421f0b
abstract away
stavros-k May 21, 2024
57f5f3b
cleaner
stavros-k May 21, 2024
9fa059d
safer,cleaner
stavros-k May 23, 2024
bba9fa9
new storage funcs
stavros-k May 23, 2024
92ba84f
storage options
stavros-k May 23, 2024
e277f2c
use built ins
stavros-k May 23, 2024
3f571fa
rename
stavros-k May 24, 2024
4855d32
spelling
stavros-k May 24, 2024
f466594
rename
stavros-k May 24, 2024
7edbaba
add vol suport
stavros-k May 27, 2024
0cc9a39
test vol
stavros-k May 27, 2024
13d4924
manually add container name
stavros-k May 27, 2024
44c72b1
volumes
stavros-k May 27, 2024
f041300
cleaner vols
stavros-k May 27, 2024
74c326a
do some renames
stavros-k May 28, 2024
78a3049
renames
stavros-k May 28, 2024
99e49b9
squash
stavros-k May 29, 2024
9184979
add todo
stavros-k May 29, 2024
4c2abd3
move few things to the lib, currently broken
stavros-k May 29, 2024
2208dba
more dynamic container names
stavros-k May 29, 2024
6c312b7
fix message
stavros-k May 29, 2024
fb247f7
cleanup
stavros-k May 30, 2024
b49ba09
update app
stavros-k May 30, 2024
6183eb8
spelling
stavros-k May 30, 2024
a5d9eae
remove port
stavros-k May 30, 2024
fe48d3c
more fixes
stavros-k May 30, 2024
ea3b248
fix pg test
stavros-k May 30, 2024
029387b
hm
stavros-k May 31, 2024
31e29bc
thats better
stavros-k May 31, 2024
d2cfda4
fmt
stavros-k May 31, 2024
0ad4953
back to jinja
stavros-k May 31, 2024
0093dd1
duh
stavros-k May 31, 2024
6521908
wait for it
stavros-k May 31, 2024
e8c854c
typo
stavros-k May 31, 2024
221047d
typo
stavros-k May 31, 2024
3c6baf8
ui
stavros-k May 31, 2024
86e6351
fix checks
stavros-k May 31, 2024
812c818
todo
stavros-k May 31, 2024
437a001
items is a builtin
stavros-k May 31, 2024
002fe25
fixes
stavros-k May 31, 2024
ebb6796
resources
stavros-k May 31, 2024
301722f
resources
stavros-k May 31, 2024
582ec0c
-.-
stavros-k May 31, 2024
df5093a
...
stavros-k May 31, 2024
0e0c693
use lib
stavros-k May 31, 2024
a974126
add rough migration paths
stavros-k Jun 4, 2024
dcaab2d
Update docker-compose.yaml
stavros-k Jun 4, 2024
b142da7
Update docker-compose.yaml
stavros-k Jun 4, 2024
030220e
move usages under value
stavros-k Jun 20, 2024
a8b64d6
update usages
stavros-k Jun 20, 2024
372544a
cleanup
stavros-k Jun 20, 2024
8161039
fix url
stavros-k Jun 20, 2024
9d698f5
order
stavros-k Jun 20, 2024
3b7724e
another url
stavros-k Jun 20, 2024
ac17958
fix
stavros-k Jun 20, 2024
8d27b38
fix hc too
stavros-k Jun 20, 2024
67b35c0
update app.yaml
stavros-k Jun 25, 2024
0d37cc1
update lib
stavros-k Jun 28, 2024
812a4bc
update lib
stavros-k Jul 2, 2024
9b7509d
update lib
stavros-k Jul 2, 2024
fc02178
update lib
stavros-k Jul 8, 2024
c20bd53
update lib
stavros-k Jul 10, 2024
3f22355
update lib
stavros-k Jul 10, 2024
467a873
update lib
stavros-k Jul 10, 2024
8ac96d3
update lib
stavros-k Jul 12, 2024
f8e3137
lint
stavros-k Jul 12, 2024
d3860cd
update lib
stavros-k Jul 15, 2024
f94092b
fix ixvol
stavros-k Jul 15, 2024
c4218e2
update lib
stavros-k Jul 15, 2024
f6c5b49
update lib
stavros-k Jul 15, 2024
f62faed
update lib
stavros-k Jul 17, 2024
4e27e2d
remove logsearch/postgres
stavros-k Jul 17, 2024
1684aa6
fmt
stavros-k Jul 17, 2024
379cb49
replace set _
stavros-k Jul 17, 2024
f075c1d
update lib
stavros-k Jul 18, 2024
d7c70ec
adapt to lib changes
stavros-k Jul 18, 2024
2748a5c
update lib
stavros-k Jul 18, 2024
d0f6809
update lib
stavros-k Jul 19, 2024
9362d80
update lib
stavros-k Jul 22, 2024
2b123ec
update lib
stavros-k Jul 25, 2024
c881b29
update lib
stavros-k Jul 29, 2024
58b47ea
update lib
stavros-k Aug 1, 2024
047b9c4
sync library
stavros-k Aug 2, 2024
520364d
updates
stavros-k Aug 13, 2024
b01888e
update lib
stavros-k Aug 13, 2024
77e13a0
update compose
stavros-k Aug 13, 2024
40418e9
typo
stavros-k Aug 13, 2024
39a668b
update ci checks
stavros-k Aug 13, 2024
f32459e
now actually fix app
stavros-k Aug 13, 2024
253550c
add migration
stavros-k Aug 14, 2024
48a8cb2
fix migration and update error message
stavros-k Aug 14, 2024
5bf3984
order
stavros-k Aug 14, 2024
18e7b78
remove test data
stavros-k Aug 14, 2024
b95c86b
update readme
stavros-k Aug 14, 2024
8af567e
fix ui
stavros-k Aug 14, 2024
ed9df34
Merge branch 'master' into add-minio-enterprise
stavros-k Aug 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 66 additions & 12 deletions .github/scripts/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,25 +229,79 @@ def get_parsed_containers():
return parsed_containers


def status_indicates_healthcheck_existence(container):
"""Assumes healthcheck exists if status contains "health" """
# eg "health: starting". This happens right after a container is started or restarted
return "health" in container.get("Status", "")


def state_indicates_restarting(container):
"""Assumes restarting if state is "restarting" """
return container.get("State", "") == "restarting"


def exit_code_indicates_normal_exit(container):
"""Assumes normal exit if there is no exit code or if it is 0"""
return container.get("ExitCode", 0) == 0


def health_indicates_healthy(container):
"""Assumes healthy if there is no health status or if it is "healthy" """
health = container.get("Health", "")
if health in ["healthy", ""]:
return True
return False


def is_considered_healthy(container):
message = [
f"Skipping container [{container['Name']}({container['ID']})] with status [{container.get('State')}]"
+ " for the following reasons:"
]
reasons = []

if health_indicates_healthy(container):
reasons.append("\t- Container is healthy")

if exit_code_indicates_normal_exit(container):
reasons.append(f"\t- Exit code is [{container.get('ExitCode', 0)}]")

if not state_indicates_restarting(container):
reasons.append("\t- Container is not restarting")

if not status_indicates_healthcheck_existence(container):
reasons.append("\t- Status does not indicate a healthcheck exists")

# Mark it as healthy if ALL of the following are true:
# 1. It is healthy
# 2. Its exit code is normal
# 3. Its not restarting
# 4. It does not indicate a healthcheck exists

# For #4, there was some cases where the container was restarting and at the time of check,
# the "Health" was empty and "State" was "running" (similar to init containers). This check
# added to try to catch those cases, by inspecting the "Status" field which if there is a healthcheck
# it will contain the word "health".
result = (
health_indicates_healthy(container)
and exit_code_indicates_normal_exit(container)
and not state_indicates_restarting(container)
and not status_indicates_healthcheck_existence(container)
)

return {"result": result, "reasons": "\n".join(message + reasons)}


def get_failed_containers():
parsed_containers = get_parsed_containers()

failed = []
for container in parsed_containers:
# Skip containers that are exited with 0 (eg init containers),
# but not restarting (during a restart exit code is 0)
if (
(
container.get("Health", "") == ""
or container.get("Health", "") == "healthy"
)
and container.get("ExitCode", 0) == 0
and (not container.get("State", "") == "restarting")
):
print_stderr(
f"Skipping container [{container['Name']}({container['ID']})] with status [{container.get('State')}]"
+ " because it exited with 0 and has no health status"
)
is_healthy = is_considered_healthy(container)
if is_healthy["result"]:
print_stderr(is_healthy["reasons"])
continue
failed.append(container)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,5 @@ Thank you for your understanding.
| whoogle | community | ✅ | - |
| wordpress | community | - | - |
| zerotier | community | ✅ | - |
| minio | enterprise | - | - |
| minio | enterprise | | ✅ |
| syncthing | enterprise | - | - |
8 changes: 7 additions & 1 deletion cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ words:
- consts
- cooldown
- cpus
- creds
- cuda
- ddns
- ddnss
Expand Down Expand Up @@ -48,6 +49,8 @@ words:
- goip
- goipde
- graalvm
- healthcheck
- healthchecks
- hetzner
- hexparrot
- homarr
Expand All @@ -59,6 +62,7 @@ words:
- inwx
- ionos
- ipaddr
- ipam
- ipfs
- ipify
- ipinfo
Expand All @@ -73,7 +77,6 @@ words:
- komga
- libsmbclient
- lidarr
- logsearch
- logseq
- luadns
- mangas
Expand Down Expand Up @@ -122,6 +125,9 @@ words:
- rclone
- rcon
- readarr
- rprivate
- rshared
- rslave
- scandir
- seeip
- selfhost
Expand Down
5 changes: 5 additions & 0 deletions ix-dev/enterprise/minio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# MinIO

[MinIO](https://min.io) is a High Performance Object Storage released under Apache License v2.0.
It is API compatible with Amazon S3 cloud storage service. Use MinIO to build high performance infrastructure
for machine learning, analytics and application data workloads.
34 changes: 34 additions & 0 deletions ix-dev/enterprise/minio/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
app_version: '2023-12-07'
capabilities: []
categories:
- networking
description: High Performance, Kubernetes Native Object Storage
home: https://min.io
host_mounts: []
icon: https://media.sys.truenas.net/apps/minio/icons/icon.png
keywords:
- object storage
- minio
- cloud
- s3
lib_version: 1.0.0
lib_version_hash: 317726af1e56541666942aeebcc7543e6f0946f96c322d35b612c0f2f7189a88
maintainers:
- email: [email protected]
name: truenas
url: https://www.truenas.com/
name: minio
run_as_context:
- description: MinIO runs as any non-root user.
gid: 568
group_name: minio
uid: 568
user_name: minio
screenshots:
- https://media.sys.truenas.net/apps/adguard-home/screenshots/screenshot1.png
- https://media.sys.truenas.net/apps/adguard-home/screenshots/screenshot2.png
sources:
- https://github.com/minio/minio
title: MinIO
train: enterprise
version: 1.0.0
11 changes: 11 additions & 0 deletions ix-dev/enterprise/minio/item.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
categories:
- networking
icon_url: https://media.sys.truenas.net/apps/minio/icons/icon.png
screenshots:
- https://media.sys.truenas.net/apps/adguard-home/screenshots/screenshot1.png
- https://media.sys.truenas.net/apps/adguard-home/screenshots/screenshot2.png
tags:
- object storage
- minio
- cloud
- s3
8 changes: 8 additions & 0 deletions ix-dev/enterprise/minio/ix_values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
images:
image:
repository: minio/minio
tag: RELEASE.2023-12-07T04-16-00Z

consts:
minio_container_name: minio
perms_container_name: permissions
58 changes: 58 additions & 0 deletions ix-dev/enterprise/minio/migrations/migrate_from_kubernetes
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/python3

import os
import sys
import yaml

from migration_helpers.resources import migrate_resources
from migration_helpers.storage import migrate_storage_item


def migrate(values):
config = values.get("helm_secret", {}).get("config", {})
if not config:
raise ValueError("No config found in values")

new_values = {
"minio": {
"credentials": {
"access_key": config["minioCreds"]["rootUser"],
"secret_key": config["minioCreds"]["rootPass"],
},
"logging": {
"quiet": config["minioLogging"]["quiet"],
"anonymous": config["minioLogging"]["anonymous"],
},
"multi_mode": {
"enabled": config["enableMultiMode"],
"entries": config.get("minioMultiMode", []),
},
},
"run_as": {
"user": config["minioRunAs"].get("user", 568),
"group": config["minioRunAs"].get("group", 568),
},
"network": {
"api_port": config["minioNetwork"]["apiPort"],
"console_port": config["minioNetwork"]["webPort"],
"host_network": config["minioNetwork"]["hostNetwork"],
"certificate_id": config["minioNetwork"].get("certificateID", None),
"server_url": config["minioNetwork"]["serverUrl"],
"console_url": config["minioNetwork"]["consoleUrl"],
},
"storage": {
"data_dirs": [migrate_storage_item(item) for item in config["minioStorage"]]
},
"resources": migrate_resources(config["resources"]),
}

return new_values


if __name__ == "__main__":
if len(sys.argv) != 2:
exit(1)

if os.path.exists(sys.argv[1]):
with open(sys.argv[1], "r") as f:
print(yaml.dump(migrate(yaml.safe_load(f.read()))))
Empty file.
27 changes: 27 additions & 0 deletions ix-dev/enterprise/minio/migrations/migration_helpers/cpu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import math
import re
import os

CPU_COUNT = os.cpu_count()

NUMBER_REGEX = re.compile(r"^[1-9][0-9]$")
FLOAT_REGEX = re.compile(r"^[0-9]+\.[0-9]+$")
MILI_CPU_REGEX = re.compile(r"^[0-9]+m$")


def transform_cpu(cpu) -> int:
result = 2
if NUMBER_REGEX.match(cpu):
result = int(cpu)
elif FLOAT_REGEX.match(cpu):
result = int(math.ceil(float(cpu)))
elif MILI_CPU_REGEX.match(cpu):
num = int(cpu[:-1])
num = num / 1000
result = int(math.ceil(num))

if CPU_COUNT is not None:
# Do not exceed the actual CPU count
result = min(result, CPU_COUNT)

return result
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def migrate_dns_config(dns_config):
if not dns_config:
return []

dns_opts = []
for opt in dns_config.get("options", []):
dns_opts.append(f"{opt['name']}:{opt['value']}")

return dns_opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def get_value_from_secret(secrets={}, secret_name="", key=""):
if not secrets or not secret_name or not key:
raise ValueError("Expected [secrets], [secret_name] and [key] to be set")
for secret in secrets.items():
curr_secret_name = secret[0]
curr_data = secret[1]

if curr_secret_name.endswith(secret_name):
if not curr_data.get(key, None):
raise ValueError(
f"Expected [{key}] to be set in secret [{curr_secret_name}]"
)
return curr_data[key]

raise ValueError(f"Secret [{secret_name}] not found")
49 changes: 49 additions & 0 deletions ix-dev/enterprise/minio/migrations/migration_helpers/memory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import re
import math
import psutil

TOTAL_MEM = psutil.virtual_memory().total

SINGLE_SUFFIX_REGEX = re.compile(r"^[1-9][0-9]*([EPTGMK])$")
DOUBLE_SUFFIX_REGEX = re.compile(r"^[1-9][0-9]*([EPTGMK])i$")
BYTES_INTEGER_REGEX = re.compile(r"^[1-9][0-9]*$")
EXPONENT_REGEX = re.compile(r"^[1-9][0-9]*e[0-9]+$")

SUFFIX_MULTIPLIERS = {
"K": 10**3,
"M": 10**6,
"G": 10**9,
"T": 10**12,
"P": 10**15,
"E": 10**18,
}

DOUBLE_SUFFIX_MULTIPLIERS = {
"Ki": 2**10,
"Mi": 2**20,
"Gi": 2**30,
"Ti": 2**40,
"Pi": 2**50,
"Ei": 2**60,
}


def transform_memory(memory):
result = 4096 # Default to 4GB

if re.match(SINGLE_SUFFIX_REGEX, memory):
suffix = memory[-1]
result = int(memory[:-1]) * SUFFIX_MULTIPLIERS[suffix]
elif re.match(DOUBLE_SUFFIX_REGEX, memory):
suffix = memory[-2:]
result = int(memory[:-2]) * DOUBLE_SUFFIX_MULTIPLIERS[suffix]
elif re.match(BYTES_INTEGER_REGEX, memory):
result = int(memory)
elif re.match(EXPONENT_REGEX, memory):
result = int(float(memory))

result = math.ceil(result)
result = min(result, TOTAL_MEM)
# Convert to Megabytes
result = result / 1024 / 1024
return int(result)
Loading
Loading