raijin-server 0.2.21__py3-none-any.whl → 0.2.23__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- raijin_server/__init__.py +1 -1
- raijin_server/modules/cert_manager.py +83 -0
- raijin_server/modules/grafana.py +138 -2
- raijin_server/modules/harness.py +127 -12
- raijin_server/modules/istio.py +155 -5
- raijin_server/modules/kafka.py +166 -12
- raijin_server/modules/kong.py +148 -4
- raijin_server/modules/loki.py +155 -9
- raijin_server/modules/minio.py +181 -4
- raijin_server/modules/prometheus.py +160 -1
- raijin_server/modules/secrets.py +189 -5
- raijin_server/modules/velero.py +141 -22
- {raijin_server-0.2.21.dist-info → raijin_server-0.2.23.dist-info}/METADATA +1 -1
- {raijin_server-0.2.21.dist-info → raijin_server-0.2.23.dist-info}/RECORD +18 -18
- {raijin_server-0.2.21.dist-info → raijin_server-0.2.23.dist-info}/WHEEL +0 -0
- {raijin_server-0.2.21.dist-info → raijin_server-0.2.23.dist-info}/entry_points.txt +0 -0
- {raijin_server-0.2.21.dist-info → raijin_server-0.2.23.dist-info}/licenses/LICENSE +0 -0
- {raijin_server-0.2.21.dist-info → raijin_server-0.2.23.dist-info}/top_level.txt +0 -0
raijin_server/modules/velero.py
CHANGED
|
@@ -1,47 +1,166 @@
|
|
|
1
|
-
"""Backup e restore com Velero."""
|
|
1
|
+
"""Backup e restore com Velero (production-ready)."""
|
|
2
|
+
|
|
3
|
+
import time
|
|
2
4
|
|
|
3
5
|
import typer
|
|
4
6
|
|
|
5
7
|
from raijin_server.utils import ExecutionContext, ensure_tool, require_root, run_cmd
|
|
6
8
|
|
|
7
9
|
|
|
10
|
+
def _check_existing_velero(ctx: ExecutionContext) -> bool:
|
|
11
|
+
"""Verifica se existe instalacao do Velero."""
|
|
12
|
+
result = run_cmd(
|
|
13
|
+
["kubectl", "get", "deployment", "velero", "-n", "velero"],
|
|
14
|
+
ctx,
|
|
15
|
+
check=False,
|
|
16
|
+
)
|
|
17
|
+
return result.returncode == 0
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _uninstall_velero(ctx: ExecutionContext) -> None:
|
|
21
|
+
"""Remove instalacao anterior do Velero."""
|
|
22
|
+
typer.echo("Removendo instalacao anterior do Velero...")
|
|
23
|
+
|
|
24
|
+
run_cmd(
|
|
25
|
+
["velero", "uninstall", "--force"],
|
|
26
|
+
ctx,
|
|
27
|
+
check=False,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Remove schedules
|
|
31
|
+
run_cmd(
|
|
32
|
+
["velero", "schedule", "delete", "--all", "--confirm"],
|
|
33
|
+
ctx,
|
|
34
|
+
check=False,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
time.sleep(5)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _wait_for_velero_ready(ctx: ExecutionContext, timeout: int = 180) -> bool:
|
|
41
|
+
"""Aguarda pods do Velero ficarem Ready."""
|
|
42
|
+
typer.echo("Aguardando pods do Velero ficarem Ready...")
|
|
43
|
+
deadline = time.time() + timeout
|
|
44
|
+
|
|
45
|
+
while time.time() < deadline:
|
|
46
|
+
result = run_cmd(
|
|
47
|
+
[
|
|
48
|
+
"kubectl", "-n", "velero", "get", "pods",
|
|
49
|
+
"-l", "component=velero",
|
|
50
|
+
"-o", "jsonpath={range .items[*]}{.metadata.name}={.status.phase} {end}",
|
|
51
|
+
],
|
|
52
|
+
ctx,
|
|
53
|
+
check=False,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
if result.returncode == 0:
|
|
57
|
+
output = (result.stdout or "").strip()
|
|
58
|
+
if output:
|
|
59
|
+
pods = []
|
|
60
|
+
for item in output.split():
|
|
61
|
+
if "=" in item:
|
|
62
|
+
parts = item.rsplit("=", 1)
|
|
63
|
+
if len(parts) == 2:
|
|
64
|
+
pods.append((parts[0], parts[1]))
|
|
65
|
+
|
|
66
|
+
if pods and all(phase == "Running" for _, phase in pods):
|
|
67
|
+
typer.secho(" Velero Ready.", fg=typer.colors.GREEN)
|
|
68
|
+
return True
|
|
69
|
+
|
|
70
|
+
time.sleep(10)
|
|
71
|
+
|
|
72
|
+
typer.secho(" Timeout aguardando Velero.", fg=typer.colors.YELLOW)
|
|
73
|
+
return False
|
|
74
|
+
|
|
75
|
+
|
|
8
76
|
def run(ctx: ExecutionContext) -> None:
|
|
9
77
|
require_root(ctx)
|
|
10
|
-
ensure_tool("velero", ctx, install_hint="Instale o binario do Velero.")
|
|
78
|
+
ensure_tool("velero", ctx, install_hint="Instale o binario do Velero: https://velero.io/docs/main/basic-install/")
|
|
79
|
+
|
|
80
|
+
# Prompt opcional de limpeza
|
|
81
|
+
if _check_existing_velero(ctx):
|
|
82
|
+
cleanup = typer.confirm(
|
|
83
|
+
"Instalacao anterior do Velero detectada. Limpar antes de reinstalar?",
|
|
84
|
+
default=False,
|
|
85
|
+
)
|
|
86
|
+
if cleanup:
|
|
87
|
+
_uninstall_velero(ctx)
|
|
11
88
|
|
|
12
89
|
typer.echo("Instalando Velero no cluster...")
|
|
13
|
-
|
|
14
|
-
|
|
90
|
+
|
|
91
|
+
provider = typer.prompt("Provider (aws, azure, gcp)", default="aws")
|
|
92
|
+
bucket = typer.prompt("Bucket para backups", default="velero-backups")
|
|
15
93
|
region = typer.prompt("Region", default="us-east-1")
|
|
16
|
-
s3_url = typer.prompt("S3 URL", default="https://s3.amazonaws.com")
|
|
94
|
+
s3_url = typer.prompt("S3 URL (para MinIO usar http://minio.minio.svc:9000)", default="https://s3.amazonaws.com")
|
|
17
95
|
secret_file = typer.prompt("Arquivo de credenciais (secret-file)", default="/etc/velero/credentials")
|
|
96
|
+
use_restic = typer.confirm("Habilitar Restic/Kopia para backups de PV?", default=True)
|
|
18
97
|
schedule = typer.prompt("Schedule cron para backups (ex: '0 2 * * *')", default="0 2 * * *")
|
|
19
98
|
|
|
99
|
+
# Build velero install command with tolerations
|
|
100
|
+
install_cmd = [
|
|
101
|
+
"velero",
|
|
102
|
+
"install",
|
|
103
|
+
"--provider", provider,
|
|
104
|
+
"--bucket", bucket,
|
|
105
|
+
"--secret-file", secret_file,
|
|
106
|
+
"--backup-location-config", f"region={region},s3Url={s3_url}",
|
|
107
|
+
"--pod-annotations", "prometheus.io/scrape=true,prometheus.io/port=8085",
|
|
108
|
+
]
|
|
109
|
+
|
|
110
|
+
# Add plugin based on provider
|
|
111
|
+
if provider == "aws":
|
|
112
|
+
install_cmd.extend(["--plugins", "velero/velero-plugin-for-aws:v1.8.0"])
|
|
113
|
+
elif provider == "azure":
|
|
114
|
+
install_cmd.extend(["--plugins", "velero/velero-plugin-for-microsoft-azure:v1.8.0"])
|
|
115
|
+
elif provider == "gcp":
|
|
116
|
+
install_cmd.extend(["--plugins", "velero/velero-plugin-for-gcp:v1.8.0"])
|
|
117
|
+
|
|
118
|
+
if use_restic:
|
|
119
|
+
install_cmd.append("--use-node-agent")
|
|
120
|
+
|
|
121
|
+
# For MinIO/S3-compatible, disable SSL verification if using http
|
|
122
|
+
if s3_url.startswith("http://"):
|
|
123
|
+
install_cmd.extend(["--backup-location-config", "s3ForcePathStyle=true"])
|
|
124
|
+
|
|
125
|
+
run_cmd(install_cmd, ctx)
|
|
126
|
+
|
|
127
|
+
# Apply tolerations patch
|
|
128
|
+
typer.echo("Aplicando tolerations para control-plane...")
|
|
129
|
+
tolerations_patch = """spec:
|
|
130
|
+
template:
|
|
131
|
+
spec:
|
|
132
|
+
tolerations:
|
|
133
|
+
- key: node-role.kubernetes.io/control-plane
|
|
134
|
+
operator: Exists
|
|
135
|
+
effect: NoSchedule
|
|
136
|
+
- key: node-role.kubernetes.io/master
|
|
137
|
+
operator: Exists
|
|
138
|
+
effect: NoSchedule"""
|
|
139
|
+
|
|
20
140
|
run_cmd(
|
|
21
|
-
[
|
|
22
|
-
|
|
23
|
-
"install",
|
|
24
|
-
"--provider",
|
|
25
|
-
provider,
|
|
26
|
-
"--bucket",
|
|
27
|
-
bucket,
|
|
28
|
-
"--secret-file",
|
|
29
|
-
secret_file,
|
|
30
|
-
"--backup-location-config",
|
|
31
|
-
f"region={region},s3Url={s3_url}",
|
|
32
|
-
"--use-restic",
|
|
33
|
-
],
|
|
141
|
+
["kubectl", "-n", "velero", "patch", "deployment", "velero",
|
|
142
|
+
"--type=strategic", "-p", tolerations_patch],
|
|
34
143
|
ctx,
|
|
144
|
+
check=False,
|
|
35
145
|
)
|
|
36
146
|
|
|
147
|
+
if not ctx.dry_run:
|
|
148
|
+
_wait_for_velero_ready(ctx)
|
|
149
|
+
|
|
37
150
|
typer.echo("Criando schedule de backup padrao...")
|
|
38
151
|
run_cmd([
|
|
39
152
|
"velero",
|
|
40
153
|
"create",
|
|
41
154
|
"schedule",
|
|
42
155
|
"raijin-daily",
|
|
43
|
-
"--schedule",
|
|
44
|
-
|
|
45
|
-
"--
|
|
46
|
-
"*",
|
|
156
|
+
"--schedule", schedule,
|
|
157
|
+
"--include-namespaces", "*",
|
|
158
|
+
"--ttl", "720h", # 30 dias
|
|
47
159
|
], ctx, check=False)
|
|
160
|
+
|
|
161
|
+
typer.secho("\n✓ Velero instalado com sucesso.", fg=typer.colors.GREEN, bold=True)
|
|
162
|
+
typer.echo("\nComandos uteis:")
|
|
163
|
+
typer.echo(" velero backup get # Listar backups")
|
|
164
|
+
typer.echo(" velero backup create manual-backup # Criar backup manual")
|
|
165
|
+
typer.echo(" velero restore create --from-backup <name> # Restaurar")
|
|
166
|
+
typer.echo(" velero schedule get # Listar schedules")
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
raijin_server/__init__.py,sha256=
|
|
1
|
+
raijin_server/__init__.py,sha256=I_fkWDB-5TUP0NDV7veqIiKtCPCo88OjVOrc0McymDM,95
|
|
2
2
|
raijin_server/cli.py,sha256=71nn7QN0f3MJkXcHr0STXmxljr-CaPibzOoiItbOT88,28571
|
|
3
3
|
raijin_server/config.py,sha256=QNiEVvrbW56XgvNn5-h3bkJm46Xc8mjNqPbvixXD8N0,4829
|
|
4
4
|
raijin_server/healthchecks.py,sha256=lzXdFw6S0hOYbUKbqksh4phb04lXgXdTspP1Dsz4dx8,15401
|
|
@@ -8,38 +8,38 @@ raijin_server/modules/__init__.py,sha256=e_IbkhLGPcF8to9QUmIESP6fpcTOYcIhaXLKIvq
|
|
|
8
8
|
raijin_server/modules/apokolips_demo.py,sha256=8ltsXRbVDwlDwLMIvh02NG-FeAfBWw_v6lh7IGOyNqs,13725
|
|
9
9
|
raijin_server/modules/bootstrap.py,sha256=oVIGNRW_JbgY8zXNHGAIP0vGbbHNHyQexthxo5zhbcw,9762
|
|
10
10
|
raijin_server/modules/calico.py,sha256=TTPF1bLFdAKb3IVOqFqRxNblULkRmMMRylsIBp4w8I8,6700
|
|
11
|
-
raijin_server/modules/cert_manager.py,sha256=
|
|
11
|
+
raijin_server/modules/cert_manager.py,sha256=XkFlXJjiP4_9It_PJaFcVYMS-QKTzzFAt839QQ9qNsg,50223
|
|
12
12
|
raijin_server/modules/essentials.py,sha256=2xUXCyCQtFGd2DnCKV81N1R6bEJqH8zaet8mLovtQ1I,689
|
|
13
13
|
raijin_server/modules/firewall.py,sha256=h6AISqiZeTinVT7BjmQIS872qRAFZJLg7meqlth3cfw,757
|
|
14
14
|
raijin_server/modules/full_install.py,sha256=xiKe2GLuZ97c4YdTmhP-kwDVuJJ9Xq3dlgcLlqSPeYM,15518
|
|
15
|
-
raijin_server/modules/grafana.py,sha256=
|
|
15
|
+
raijin_server/modules/grafana.py,sha256=DdDLxmTeFnDRvcRLkpg1RuR9o1ZAArk2W-DTLLyfWHg,6009
|
|
16
16
|
raijin_server/modules/hardening.py,sha256=4hz3ifkMhPlXa2n7gPxN0gitQgzALZ-073vuU3LM4RI,1616
|
|
17
|
-
raijin_server/modules/harness.py,sha256=
|
|
18
|
-
raijin_server/modules/istio.py,sha256=
|
|
19
|
-
raijin_server/modules/kafka.py,sha256=
|
|
20
|
-
raijin_server/modules/kong.py,sha256=
|
|
17
|
+
raijin_server/modules/harness.py,sha256=uWTxTVJlY_VB6xi4ftMtTSaIb96HA8WJQS-RbyxU45M,5391
|
|
18
|
+
raijin_server/modules/istio.py,sha256=YUC6-r9gY9Ay-NtbN23wn9eAGRAEgsIn8IuBJUDFM5w,6156
|
|
19
|
+
raijin_server/modules/kafka.py,sha256=n7ZpLPWv6sKBJhdBiPe7VgeDB24YiCIOWvOQkWwt03Y,5664
|
|
20
|
+
raijin_server/modules/kong.py,sha256=cRDzAP9Ne3Qte6sqmxWUS-aJVgiaf4B0uqFvg02Nw5E,5076
|
|
21
21
|
raijin_server/modules/kubernetes.py,sha256=waSf2cCVnLicN5o3M47MzMzmHHtvKeFXm1__8ynQzA0,11871
|
|
22
|
-
raijin_server/modules/loki.py,sha256=
|
|
22
|
+
raijin_server/modules/loki.py,sha256=aNiUpnOFppZMXoQwYhn7IoPMzwUz4aHi6pbiqj1PRjc,5022
|
|
23
23
|
raijin_server/modules/metallb.py,sha256=uUuklc_RsQ-W2qDVRMQAxQm9HKGEqso444b1IwBpM6w,8554
|
|
24
|
-
raijin_server/modules/minio.py,sha256=
|
|
24
|
+
raijin_server/modules/minio.py,sha256=wxL8U1Zl3XtI-wymIeZonmi561v1zf-bY4TTVPKisLA,6221
|
|
25
25
|
raijin_server/modules/network.py,sha256=QRlYdcryCCPAWG3QQ_W7ld9gJgETI7H8gwntOU7UqFE,4818
|
|
26
26
|
raijin_server/modules/observability_dashboards.py,sha256=fVz0WEOQrUTF5rJ__Nu_onyBuwL_exFmysWMmg8AE9w,7319
|
|
27
27
|
raijin_server/modules/observability_ingress.py,sha256=Fh1rlFWueBNHnOkHuoHYyhILmpO-iQXINybSUYbYsHQ,5738
|
|
28
|
-
raijin_server/modules/prometheus.py,sha256=
|
|
28
|
+
raijin_server/modules/prometheus.py,sha256=wT9jdcC-8vVysVKgMR5isGbxxpvGFPRf7fhMAGd9kJU,10761
|
|
29
29
|
raijin_server/modules/sanitize.py,sha256=_RnWn1DUuNrzx3NnKEbMvf5iicgjiN_ubwT59e0rYWY,6040
|
|
30
|
-
raijin_server/modules/secrets.py,sha256=
|
|
30
|
+
raijin_server/modules/secrets.py,sha256=d4j12feQL8m_4-hYN5FfboQHvBc75TFeGno3OzrXokE,9266
|
|
31
31
|
raijin_server/modules/ssh_hardening.py,sha256=oQdk-EVnEHNMKIWvoFuZzI4jK0nNO8IAY4hkB4pj8zw,4025
|
|
32
32
|
raijin_server/modules/traefik.py,sha256=crEYIqAidAhh_H93qIvCbTtJ7BjO-3ef77alLc_--Gg,3535
|
|
33
|
-
raijin_server/modules/velero.py,sha256=
|
|
33
|
+
raijin_server/modules/velero.py,sha256=yDtqd6yUu0L5wzLCjYXqvvxB_RyaAoZtntb6HoHVAOo,5642
|
|
34
34
|
raijin_server/modules/vpn.py,sha256=hF-0vA17VKTxhQLDBSEeqI5aPQpiaaj4IpUf9l6lr64,8297
|
|
35
35
|
raijin_server/scripts/__init__.py,sha256=deduGfHf8BMVWred4ux5LfBDT2NJ5XYeJAt2sDEU4qs,53
|
|
36
36
|
raijin_server/scripts/checklist.sh,sha256=j6E0Kmk1EfjLvKK1VpCqzXJAXI_7Bm67LK4ndyCxWh0,1842
|
|
37
37
|
raijin_server/scripts/install.sh,sha256=Y1ickbQ4siQ0NIPs6UgrqUr8WWy7U0LHmaTQbEgavoI,3949
|
|
38
38
|
raijin_server/scripts/log_size_metric.sh,sha256=Iv4SsX8AuCYRou-klYn32mX41xB6j0xJGLBO6riw4rU,1208
|
|
39
39
|
raijin_server/scripts/pre-deploy-check.sh,sha256=XqMo7IMIpwUHF17YEmU0-cVmTDMoCGMBFnmS39FidI4,4912
|
|
40
|
-
raijin_server-0.2.
|
|
41
|
-
raijin_server-0.2.
|
|
42
|
-
raijin_server-0.2.
|
|
43
|
-
raijin_server-0.2.
|
|
44
|
-
raijin_server-0.2.
|
|
45
|
-
raijin_server-0.2.
|
|
40
|
+
raijin_server-0.2.23.dist-info/licenses/LICENSE,sha256=kJsMCjOiRZE0AQNtxWqBa32z9kMAaF4EUxyHj3hKaJo,1105
|
|
41
|
+
raijin_server-0.2.23.dist-info/METADATA,sha256=4Acy_Ht1vivZ_M7NXcFWCNSgdtgBVKUq4_fOOxYtq4I,22476
|
|
42
|
+
raijin_server-0.2.23.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
43
|
+
raijin_server-0.2.23.dist-info/entry_points.txt,sha256=3ZvxDX4pvcjkIRsXAJ69wIfVmKa78LKo-C3QhqN2KVM,56
|
|
44
|
+
raijin_server-0.2.23.dist-info/top_level.txt,sha256=Yz1xneCRtsZOzbPIcTAcrSxd-1p80pohMXYAZ74dpok,14
|
|
45
|
+
raijin_server-0.2.23.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|