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)