Files
awx-operator/roles/installer/templates/service.yaml.j2
2021-08-14 19:50:29 -04:00

58 lines
1.8 KiB
Django/Jinja

---
apiVersion: v1
kind: Service
metadata:
name: '{{ meta.name }}-service'
namespace: '{{ meta.namespace }}'
labels:
app.kubernetes.io/name: '{{ meta.name }}'
app.kubernetes.io/part-of: '{{ meta.name }}'
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
app.kubernetes.io/component: '{{ deployment_type }}'
app.kubernetes.io/operator-version: '{{ lookup("env", "OPERATOR_VERSION") }}'
{{ service_labels | indent(width=4) }}
{% if service_type | lower == 'loadbalancer' and loadbalancer_annotations %}
annotations:
{{ loadbalancer_annotations | indent(width=4) }}
{% endif %}
spec:
ports:
{% if service_type | lower != 'loadbalancer' and loadbalancer_protocol | lower != 'https' %}
- port: 80
protocol: TCP
targetPort: 8052
name: http
{% endif %}
{% if ingress_type | lower == 'route' and route_tls_termination_mechanism | lower == 'passthrough' %}
- port: 443
protocol: TCP
targetPort: 8053
name: https
{% endif %}
{% if service_type | lower == 'loadbalancer' and loadbalancer_protocol | lower == 'https' %}
- port: {{ loadbalancer_port }}
protocol: TCP
targetPort: 8052
name: https
{% elif service_type | lower == 'loadbalancer' and loadbalancer_protocol | lower != 'https' %}
- port: {{ loadbalancer_port }}
protocol: TCP
targetPort: 8052
name: http
{% elif service_type | lower == "nodeport" %}
- port: {{ nodeport_port }}
protocol: TCP
targetPort: 8052
name: http
type: NodePort
{% endif %}
selector:
app.kubernetes.io/name: '{{ meta.name }}'
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
app.kubernetes.io/component: '{{ deployment_type }}'
{% if service_type | lower == "loadbalancer" %}
type: LoadBalancer
{% else %}
type: ClusterIP
{% endif %}