apiVersion: v1
kind: Service
metadata:
  name: {{k8s_deploy.name}}
  namespace: {{k8s_deploy.namespace}}
  labels:
    {%- for label in k8s_deploy.labels %}
    {{label.key}}: {{label.value}}
    {%- endfor %}
spec:
  {%- if k8s_deploy.service.ports %}
  ports:
    {%- for port in k8s_deploy.service.ports %}
    - name: {{port.name}}
      {%- if port.container %}
      port: {{port.container}}
      {%- endif %}
      {%- if port.proto %}
      protocol: {{port.proto}}
      {%- endif %}
      {%- if port.target %}
      targetPort: {{port.target}}
      {%- endif %}
    {%- endfor %}
  {%- endif %}
  selector:
    {%- for label in k8s_deploy.sel_labels %}
    {{label.key}}: {{label.value}}
    {%- endfor %}
