From 33e329c091e3081fbbf765cec630067822a9d1e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=90=D0=BD=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=BF=D0=BE=D0=B2?= Date: Sun, 26 Oct 2025 08:38:57 +0300 Subject: [PATCH] =?UTF-8?q?refactor:=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=20=D0=BF=D0=BE=D1=80=D1=82=D0=BE=D0=B2=20ingress?= =?UTF-8?q?=20=D0=B2=20addon=5Fports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Удалены ingress_host_http_port и ingress_host_https_port - Все порты (ingress, prometheus, grafana, kiali) теперь в addon_ports - Обновлен скрипт create_k8s_cluster.py для работы с новой структурой - Все порты теперь пробрасываются через extraPortMappings в конфигурации Kind - Порты теперь видны в контейнерах control-plane и worker --- molecule/presets/k8s/kubernetes.yml | 6 ++- scripts/create_k8s_cluster.py | 58 ++++++++++++++++++++++------- 2 files changed, 48 insertions(+), 16 deletions(-) diff --git a/molecule/presets/k8s/kubernetes.yml b/molecule/presets/k8s/kubernetes.yml index 16bd82b..0a94f56 100644 --- a/molecule/presets/k8s/kubernetes.yml +++ b/molecule/presets/k8s/kubernetes.yml @@ -44,14 +44,16 @@ kind_clusters: istio: true kiali: true prometheus_stack: true - ingress_host_http_port: 8081 - ingress_host_https_port: 8443 # Порты для доступа к аддонам извне # Документация: https://devops.org.ru + # Ingress HTTP: http://localhost:8081 + # Ingress HTTPS: https://localhost:8443 # Prometheus: http://localhost:9090 # Grafana: http://localhost:3000 (admin/admin) # Kiali: http://localhost:20001 addon_ports: + ingress_http: 8081 + ingress_https: 8443 prometheus: 9090 grafana: 3000 kiali: 20001 diff --git a/scripts/create_k8s_cluster.py b/scripts/create_k8s_cluster.py index 3ca5e40..426a99e 100755 --- a/scripts/create_k8s_cluster.py +++ b/scripts/create_k8s_cluster.py @@ -124,20 +124,50 @@ def main(): } } - # Добавляем extraPortMappings для ingress если нужно - if cluster.get('addons', {}).get('ingress_nginx'): - config['nodes'][0]['extraPortMappings'] = [ - { - 'containerPort': 80, - 'hostPort': cluster.get('ingress_host_http_port', 8081), - 'protocol': 'TCP' - }, - { - 'containerPort': 443, - 'hostPort': cluster.get('ingress_host_https_port', 8443), - 'protocol': 'TCP' - } - ] + # Добавляем extraPortMappings для всех портов из addon_ports + addon_ports = cluster.get('addon_ports', {}) + port_mappings = [] + + # Ingress порты + if addon_ports.get('ingress_http'): + port_mappings.append({ + 'containerPort': 80, + 'hostPort': addon_ports['ingress_http'], + 'protocol': 'TCP' + }) + if addon_ports.get('ingress_https'): + port_mappings.append({ + 'containerPort': 443, + 'hostPort': addon_ports['ingress_https'], + 'protocol': 'TCP' + }) + + # Prometheus порт + if addon_ports.get('prometheus'): + port_mappings.append({ + 'containerPort': 9090, + 'hostPort': addon_ports['prometheus'], + 'protocol': 'TCP' + }) + + # Grafana порт + if addon_ports.get('grafana'): + port_mappings.append({ + 'containerPort': 3000, + 'hostPort': addon_ports['grafana'], + 'protocol': 'TCP' + }) + + # Kiali порт + if addon_ports.get('kiali'): + port_mappings.append({ + 'containerPort': 20001, + 'hostPort': addon_ports['kiali'], + 'protocol': 'TCP' + }) + + if port_mappings: + config['nodes'][0]['extraPortMappings'] = port_mappings # Добавляем worker nodes workers = cluster.get('workers', 0)