service.j2 798 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. apiVersion: "v1"
  2. kind: "Service"
  3. metadata:
  4. name: "{{obj_name}}"
  5. {% if annotations is defined%}
  6. annotations:
  7. {% for key, value in annotations.items() %}
  8. {{key}}: {{value}}
  9. {% endfor %}
  10. {% endif %}
  11. {% if labels is defined%}
  12. labels:
  13. {% for key, value in labels.items() %}
  14. {{key}}: {{value}}
  15. {% endfor %}
  16. {% endif %}
  17. spec:
  18. {% if headless is defined and headless %}
  19. portalIP: None
  20. clusterIP: None
  21. {% endif %}
  22. ports:
  23. {% for port in ports %}
  24. -
  25. {% for key, value in port.items() %}
  26. {{key}}: {{value}}
  27. {% endfor %}
  28. {% if port.targetPort is undefined %}
  29. clusterIP: "None"
  30. {% endif %}
  31. {% endfor %}
  32. {% if service_targetPort is defined %}
  33. targetPort: {{service_targetPort}}
  34. {% endif %}
  35. selector:
  36. {% for key, value in selector.items() %}
  37. {{key}}: {{value}}
  38. {% endfor %}