Skip to content

Commit

Permalink
add more options in nginx chart (#49)
Browse files Browse the repository at this point in the history
* add more options in nginx chart

* fix end of lines
  • Loading branch information
LeoQuote authored May 26, 2023
1 parent 5eb4368 commit f55b522
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/nginx/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.0
version: 0.3.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
18 changes: 17 additions & 1 deletion charts/nginx/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,21 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- with .Values.args }}
args:
{{- toYaml . | nindent 12 }}
{{- end}}
{{- with .Values.env }}
env:
{{- toYaml . | nindent 12 }}
{{- end}}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: 80
containerPort: {{ .Values.containerPort }}
protocol: TCP
livenessProbe:
httpGet:
Expand All @@ -47,6 +59,10 @@ spec:
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumes}}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
20 changes: 20 additions & 0 deletions charts/nginx/templates/prometheusrule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if .Values.prometheusRule.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ template "nginx.fullname" . }}
{{- with .Values.prometheusRule.namespace }}
namespace: {{ . }}
{{- end }}
labels:
{{ include "nginx.labels" . | indent 4 }}
{{- with .Values.prometheusRule.additionalLabels }}
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- with .Values.prometheusRule.rules }}
groups:
- name: {{ template "nginx.name" $ }}
rules: {{ tpl (toYaml .) $ | nindent 8 }}
{{- end }}
{{- end }}
48 changes: 48 additions & 0 deletions charts/nginx/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{- if .Values.serviceMonitor.enabled }}
{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) ( .Values.serviceMonitor.enabled ) }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
{{- if .Values.serviceMonitor.labels }}
labels:
{{ toYaml .Values.serviceMonitor.labels | indent 4}}
{{- end }}
name: {{ template "nginx.fullname" . }}
{{- if .Values.serviceMonitor.namespace }}
namespace: {{ .Values.serviceMonitor.namespace }}
{{- end }}
spec:
endpoints:
- port: http
{{- if .Values.serviceMonitor.interval }}
interval: {{ .Values.serviceMonitor.interval }}
{{- end }}
{{- if .Values.serviceMonitor.telemetryPath }}
path: {{ .Values.serviceMonitor.telemetryPath }}
{{- end }}
{{- if .Values.serviceMonitor.timeout }}
scrapeTimeout: {{ .Values.serviceMonitor.timeout }}
{{- end }}
{{- if .Values.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{ toYaml .Values.serviceMonitor.metricRelabelings | indent 4 }}
{{- end }}
{{- if .Values.serviceMonitor.relabelings }}
relabelings:
{{ toYaml .Values.serviceMonitor.relabelings | indent 4 }}
{{- end }}
jobLabel: {{ template "nginx.fullname" . }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
{{- include "nginx.selectorLabels" . | nindent 6 }}
{{- if .Values.serviceMonitor.targetLabels }}
targetLabels:
{{- range .Values.serviceMonitor.targetLabels }}
- {{ . }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
20 changes: 20 additions & 0 deletions charts/nginx/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ service:
type: ClusterIP
port: 80

containerPort: 80

volumes: []

volumeMounts: []

env: []

ingress:
enabled: false
className: ""
Expand Down Expand Up @@ -80,3 +88,15 @@ nodeSelector: {}
tolerations: []

affinity: {}


serviceMonitor:
enabled: false


prometheusRule:
enabled: false
# namespace: monitoring
# additionalLabels: {}
# release: prometheus-operator
# rules: []

0 comments on commit f55b522

Please sign in to comment.