---
# Kubernetes Service generated by Vibe Infra
apiVersion: v1
kind: Service
metadata:
  name: {{ name }}
  namespace: {{ namespace }}
  {% if labels %}
  labels:
    {% for key, value in labels.items() %}
    {{ key }}: {{ value }}
    {% endfor %}
    managed-by: athena
  {% endif %}
spec:
  type: {{ spec.get('type', 'ClusterIP') }}
  selector:
    app: {{ name }}
    {% for key, value in labels.items() %}
    {{ key }}: {{ value }}
    {% endfor %}
  {% if spec.get('ports') %}
  ports:
  {% for port in spec.ports %}
  - name: {{ port.get('name', 'port-' ~ loop.index) }}
    protocol: {{ port.get('protocol', 'TCP') }}
    port: {{ port.port }}
    targetPort: {{ port.get('targetPort', port.port) }}
    {% if spec.type == 'NodePort' and port.get('nodePort') %}
    nodePort: {{ port.nodePort }}
    {% endif %}
  {% endfor %}
  {% endif %}
