podman: переход на Podman, Minikube, локальные образы и док для новичков
- Molecule: драйвер delegated, коллекция containers.podman, create/destroy/verify на Podman - Makefile: все вызовы docker заменены на podman, сокет /run/podman/podman.sock - Сборка образов: podman build (без buildx), buildall/buildall-image — только локально без push - Ansible-controller: Podman в образе, docker-compose на podman compose, сокет Podman - K8s: Kind заменён на Minikube (драйвер podman), скрипты и Makefile обновлены - Пресеты: проверка локальных образов, без podman pull (registry запрещён) - Документация: docs/podman.md, docs/quickstart-for-dummies.md (роли, плейбук, линт, тесты, пресеты, инвентори) - README: ссылка на quickstart-for-dummies Made-with: Cursor
This commit is contained in:
74
scripts/create_minikube_cluster.py
Normal file
74
scripts/create_minikube_cluster.py
Normal file
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Скрипт для создания Minikube кластера с драйвером Podman.
|
||||
Автор: Сергей Антропов
|
||||
Сайт: https://devops.org.ru
|
||||
"""
|
||||
import sys
|
||||
import yaml
|
||||
import subprocess
|
||||
|
||||
|
||||
def run_cmd(cmd, check=True):
|
||||
"""Выполнить команду на хосте."""
|
||||
print(f"[run] {cmd}")
|
||||
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
|
||||
if check and result.returncode != 0:
|
||||
print(f"[error] {result.stderr}")
|
||||
sys.exit(1)
|
||||
if result.stdout:
|
||||
print(result.stdout)
|
||||
return result
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: create_minikube_cluster.py <preset_file>")
|
||||
print(" Создаёт Minikube кластер с драйвером podman и опционально включает аддоны из пресета.")
|
||||
sys.exit(1)
|
||||
|
||||
preset_file = sys.argv[1]
|
||||
print(f"📋 Читаю пресет: {preset_file}")
|
||||
|
||||
with open(preset_file, "r", encoding="utf-8") as f:
|
||||
preset = yaml.safe_load(f) or {}
|
||||
|
||||
profile = preset.get("minikube_profile", "minikube")
|
||||
addons = preset.get("minikube_addons", [])
|
||||
cpus = preset.get("minikube_cpus", "2")
|
||||
memory = preset.get("minikube_memory", "4096")
|
||||
|
||||
print(f"\n☸️ Создание Minikube кластера (драйвер: podman)")
|
||||
print(f" Профиль: {profile}")
|
||||
print(f" CPU: {cpus}, Memory: {memory}")
|
||||
|
||||
# Проверяем, запущен ли уже кластер
|
||||
result = subprocess.run(
|
||||
f"minikube profile list 2>/dev/null | grep -E '^{profile}' | grep 'Running'",
|
||||
shell=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
if result.returncode == 0 and result.stdout.strip():
|
||||
print(f"⚠️ Кластер с профилем '{profile}' уже запущен.")
|
||||
print(" Для пересоздания выполните: minikube delete -p " + profile)
|
||||
else:
|
||||
run_cmd(
|
||||
f"minikube start --driver=podman --profile={profile} --cpus={cpus} --memory={memory}"
|
||||
)
|
||||
print(f"✅ Minikube кластер '{profile}' создан и запущен.")
|
||||
|
||||
# Включаем аддоны из пресета
|
||||
if addons:
|
||||
print(f"\n📦 Включение аддонов: {', '.join(addons)}")
|
||||
for addon in addons:
|
||||
run_cmd(f"minikube addons enable {addon} -p {profile}", check=False)
|
||||
|
||||
print("\n🎉 Готово. Использование:")
|
||||
print(f" kubectl config use-context {profile}")
|
||||
print(" minikube kubectl -- get nodes")
|
||||
print(" minikube dashboard -p " + profile)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user