refactor: перенос портов ingress в addon_ports

- Удалены ingress_host_http_port и ingress_host_https_port
- Все порты (ingress, prometheus, grafana, kiali) теперь в addon_ports
- Обновлен скрипт create_k8s_cluster.py для работы с новой структурой
- Все порты теперь пробрасываются через extraPortMappings в конфигурации Kind
- Порты теперь видны в контейнерах control-plane и worker
This commit is contained in:
Сергей Антропов
2025-10-26 08:38:57 +03:00
parent 5c8862e9bf
commit 33e329c091
2 changed files with 48 additions and 16 deletions

View File

@@ -44,14 +44,16 @@ kind_clusters:
istio: true istio: true
kiali: true kiali: true
prometheus_stack: true prometheus_stack: true
ingress_host_http_port: 8081
ingress_host_https_port: 8443
# Порты для доступа к аддонам извне # Порты для доступа к аддонам извне
# Документация: https://devops.org.ru # Документация: https://devops.org.ru
# Ingress HTTP: http://localhost:8081
# Ingress HTTPS: https://localhost:8443
# Prometheus: http://localhost:9090 # Prometheus: http://localhost:9090
# Grafana: http://localhost:3000 (admin/admin) # Grafana: http://localhost:3000 (admin/admin)
# Kiali: http://localhost:20001 # Kiali: http://localhost:20001
addon_ports: addon_ports:
ingress_http: 8081
ingress_https: 8443
prometheus: 9090 prometheus: 9090
grafana: 3000 grafana: 3000
kiali: 20001 kiali: 20001

View File

@@ -124,20 +124,50 @@ def main():
} }
} }
# Добавляем extraPortMappings для ingress если нужно # Добавляем extraPortMappings для всех портов из addon_ports
if cluster.get('addons', {}).get('ingress_nginx'): addon_ports = cluster.get('addon_ports', {})
config['nodes'][0]['extraPortMappings'] = [ port_mappings = []
{
'containerPort': 80, # Ingress порты
'hostPort': cluster.get('ingress_host_http_port', 8081), if addon_ports.get('ingress_http'):
'protocol': 'TCP' port_mappings.append({
}, 'containerPort': 80,
{ 'hostPort': addon_ports['ingress_http'],
'containerPort': 443, 'protocol': 'TCP'
'hostPort': cluster.get('ingress_host_https_port', 8443), })
'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 # Добавляем worker nodes
workers = cluster.get('workers', 0) workers = cluster.get('workers', 0)