Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Refactor ServiceMonitor template to avoid duplicates across releases #742

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions charts/apisix/templates/service-monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,34 @@
# See the License for the specific language governing permissions and
# limitations under the License.

{{- if .Values.metrics.serviceMonitor.enabled }}
{{- if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ .Values.metrics.serviceMonitor.name | default (include "apisix.fullname" .) }}
namespace: {{ .Values.metrics.serviceMonitor.namespace | default .Release.Namespace }}
name: {{ .Values.serviceMonitor.name | default "apisix-service-monitor" }}
namespace: {{ .Values.serviceMonitor.namespace | default .Release.Namespace }}
labels:
{{- include "apisix.labels" . | nindent 4 }}
{{- if .Values.metrics.serviceMonitor.labels }}
{{- toYaml .Values.metrics.serviceMonitor.labels | nindent 4 }}
{{- if .Values.serviceMonitor.labels }}
{{- toYaml .Values.serviceMonitor.labels | nindent 4 }}
{{- end }}
{{- if .Values.metrics.serviceMonitor.annotations }}
annotations: {{- toYaml .Values.metrics.serviceMonitor.annotations | nindent 4 }}
{{- if .Values.serviceMonitor.annotations }}
annotations:
{{- toYaml .Values.serviceMonitor.annotations | nindent 4 }}
"helm.sh/hook": pre-install,post-install
"helm.sh/hook-weight": "-5"
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
{{- end }}
spec:
namespaceSelector:
matchNames:
- {{ .Values.metrics.serviceMonitor.namespace | default .Release.Namespace }}
- {{ .Values.serviceMonitor.namespace | default .Release.Namespace }}
selector:
matchLabels:
{{- include "apisix.labels" . | nindent 6 }}
app.kubernetes.io/service: apisix-prometheus-metrics
app.kubernetes.io/name: {{ include "apisix.name" . }}
app.kubernetes.io/service: apisix-gateway
endpoints:
- scheme: http
targetPort: prometheus
path: {{ .Values.apisix.prometheus.path }}
interval: {{ .Values.metrics.serviceMonitor.interval }}
{{- end }}
path: {{ .Values.serviceMonitor.path }}
interval: {{ .Values.serviceMonitor.interval }}
{{- end }}