# Headless service for stable DNS entries of StatefulSet members.
apiVersion: v1
kind: Service
metadata:
  name: {{ template "fullname" . }}
  labels:
    {{- include "common.labels.matchLabels" . | nindent 4 }}
    app.kubernetes.io/component: gitee-mysql
    app: {{ template "fullname" . }}
    chart: "{{ template "mysqlha.chart" . }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
spec:
  ports:
  - name: {{ template "fullname" . }}
    port: 3306
  clusterIP: None
  selector:
    {{- include "common.labels.matchLabels" . | nindent 4 }}
    app.kubernetes.io/component: gitee-mysql
    app: {{ template "fullname" . }}
---
# announce service 
apiVersion: v1
kind: Service
metadata:
  name: {{ template "fullname" . }}-announce
  labels:
    {{- include "common.labels.matchLabels" . | nindent 4 }}
    app.kubernetes.io/component: gitee-mysql
    app.kubernetes.io/component: metrics
    app: {{ template "fullname" . }}
    chart: "{{ template "mysqlha.chart" . }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
  annotations:
{{- if and (.Values.metrics.enabled) (.Values.metrics.annotations) }}
{{ toYaml .Values.metrics.annotations | indent 4 }}
{{- end }}
spec:
  publishNotReadyAddresses: true
  type: ClusterIP
  ports:
  - name: {{ template "fullname" . }}
    port: 3306
  {{- if .Values.metrics.enabled }}
  - name: metrics
    port: 9104
    targetPort: metrics
  {{- end }}
  selector:
    {{- include "common.labels.matchLabels" . | nindent 4 }}
    app.kubernetes.io/component: gitee-mysql
    app: {{ template "fullname" . }}
    statefulset.kubernetes.io/pod-name: {{ template "fullname" . }}-0
---

apiVersion: v1
kind: Service
metadata:
  name: {{ template "fullname" . }}-haproxy
  labels:
    {{- include "common.labels.matchLabels" . | nindent 4 }}
    app.kubernetes.io/component: gitee-mysql
    app.kubernetes.io/component: metrics
    app: {{ template "fullname" . }}
    chart: "{{ template "mysqlha.chart" . }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
  annotations:
spec:
  publishNotReadyAddresses: true
  type: ClusterIP
  ports:
  - name: {{ template "fullname" . }}
    port: 3306
  selector:
    {{- include "common.labels.matchLabels" . | nindent 4 }}
    app.kubernetes.io/component: gitee-mysql
    app: {{ template "fullname" . }}
    statefulset.kubernetes.io/pod-name: {{ template "fullname" . }}-0
