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

Add some templating #367

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion charts/log-router/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
apiVersion: v1
description: Distribution of Fluentd as K8S daemonset
name: log-router
version: 0.4.0
version: 0.4.1
home: https://github.com/vmware/kube-fluentd-operator
sources:
- https://github.com/vmware/kube-fluentd-operator
appVersion: v1.16.8
27 changes: 27 additions & 0 deletions charts/log-router/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,33 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "fluentd-router.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "fluentd-router.labels" -}}
helm.sh/chart: {{ include "fluentd-router.chart" . }}
{{ include "fluentd-router.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "fluentd-router.selectorLabels" -}}
app.kubernetes.io/name: {{ include "fluentd-router.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Set apiVersion based on .Capabilities.APIVersions
*/}}
Expand Down
5 changes: 1 addition & 4 deletions charts/log-router/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ apiVersion: {{ template "rbacAPIVersion" . }}
kind: ClusterRole
metadata:
labels:
app: {{ template "fluentd-router.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- include "fluentd-router.labels" . | nindent 4 }}
{{- if .Values.extraLabels }}
{{ toYaml .Values.extraLabels | indent 4 }}
{{- end }}
Expand Down
15 changes: 5 additions & 10 deletions charts/log-router/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,15 @@ kind: DaemonSet
metadata:
name: {{ template "fluentd-router.fullname" . }}
labels:
app: {{ template "fluentd-router.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- include "fluentd-router.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
app: {{ template "fluentd-router.name" . }}
release: {{ .Release.Name }}
{{- include "fluentd-router.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
app: {{ template "fluentd-router.name" . }}
release: {{ .Release.Name }}
{{- include "fluentd-router.selectorLabels" . | nindent 8 }}
annotations:
checksum/fluentd-extraenv: {{ toYaml .Values.fluentd.extraEnv | sha256sum }}
checksum/reloader-extraenv: {{ toYaml .Values.reloader.extraEnv | sha256sum }}
Expand All @@ -43,7 +38,7 @@ spec:
{{- end }}
containers:
- name: fluentd
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
env:
- name: K8S_NODE_NAME
valueFrom:
Expand Down Expand Up @@ -79,7 +74,7 @@ spec:
resources:
{{ toYaml .Values.fluentd.resources | indent 12 }}
- name: reloader
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.prometheusEnabled }}
ports:
Expand Down
5 changes: 1 addition & 4 deletions charts/log-router/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ apiVersion: {{ template "rbacAPIVersion" . }}
kind: ClusterRoleBinding
metadata:
labels:
app: {{ template "fluentd-router.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- include "fluentd-router.labels" . | nindent 4 }}
{{- if .Values.extraLabels }}
{{ toYaml .Values.extraLabels | indent 4 }}
{{- end }}
Expand Down
7 changes: 2 additions & 5 deletions charts/log-router/templates/sa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app: {{ template "fluentd-router.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- include "fluentd-router.labels" . | nindent 4 }}
name: {{ template "fluentd-router.fullname" . }}
{{- if .Values.rbac.serviceAccount.annotations }}
annotations: {{ toYaml .Values.rbac.serviceAccount.annotations | nindent 4 }}
Expand All @@ -19,4 +16,4 @@ metadata:
imagePullSecrets:
- name: {{ .Values.imagePullSecret}}
{{end}}
{{- end }}
{{- end }}
5 changes: 1 addition & 4 deletions charts/log-router/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ kind: Secret
metadata:
name: {{ template "fluentd-router.fullname" . }}
labels:
app: {{ template "fluentd-router.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- include "fluentd-router.labels" . | nindent 4 }}
annotations:
checksum/fluentd-extraenv: {{ toYaml .Values.fluentd.extraEnv | sha256sum }}
checksum/reloader-extraenv: {{ toYaml .Values.reloader.extraEnv | sha256sum }}
Expand Down
18 changes: 5 additions & 13 deletions charts/log-router/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@ apiVersion: v1
kind: Service
metadata:
labels:
app: {{ template "fluentd-router.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- include "fluentd-router.labels" . | nindent 4 }}
metrics: fluentd
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "24231"
name: {{ template "fluentd-router.fullname" . }}
spec:
selector:
app: {{ template "fluentd-router.name" . }}
release: {{ .Release.Name }}
{{- include "fluentd-router.selectorLabels" . | nindent 4 }}
ports:
- port: 24231
name: prometheus
Expand All @@ -31,21 +27,17 @@ apiVersion: v1
kind: Service
metadata:
labels:
app: {{ template "fluentd-router.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- include "fluentd-router.labels" . | nindent 4 }}
metrics: reloader
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: {{ .Values.metricsPort | quote }}
name: {{ template "fluentd-router.fullname" . }}-reloader
spec:
selector:
app: {{ template "fluentd-router.name" . }}
release: {{ .Release.Name }}
{{- include "fluentd-router.selectorLabels" . | nindent 4 }}
ports:
- port: {{ .Values.metricsPort }}
name: metrics
targetPort: metrics
{{- end }}
{{- end }}
26 changes: 12 additions & 14 deletions charts/log-router/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ kind: ServiceMonitor
metadata:
name: {{ template "fluentd-router.fullname" . }}
labels:
app: {{ template "fluentd-router.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- include "fluentd-router.labels" . | nindent 4 }}
{{- with .Values.serviceMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
jobLabel: app
jobLabel: {{ .Values.serviceMonitor.jobLabel | quote }}
selector:
matchLabels:
app: {{ template "fluentd-router.name" . }}
release: {{ .Release.Name }}
{{- include "fluentd-router.selectorLabels" . | nindent 6 }}
metrics: fluentd
endpoints:
- port: prometheus
Expand All @@ -28,16 +27,15 @@ kind: ServiceMonitor
metadata:
name: {{ template "fluentd-router.fullname" . }}-reloader
labels:
app: {{ template "fluentd-router.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- include "fluentd-router.labels" . | nindent 4 }}
{{- with .Values.serviceMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
jobLabel: app
jobLabel: {{ .Values.serviceMonitor.jobLabel | quote }}
selector:
matchLabels:
app: {{ template "fluentd-router.name" . }}
release: {{ .Release.Name }}
{{- include "fluentd-router.selectorLabels" . | nindent 6 }}
metrics: reloader
endpoints:
- port: metrics
Expand Down
19 changes: 12 additions & 7 deletions charts/log-router/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ defaultConfigmap: "fluentd-config"
image:
repository: vmware/kube-fluentd-operator
pullPolicy: IfNotPresent
tag: latest
# tag is an override of the image tag, which is by default set by the
# appVersion field in Chart.yaml.
tag: ""
pullSecret: ""

logLevel: debug
Expand Down Expand Up @@ -114,14 +116,17 @@ logRotate:


serviceMonitor:
# enable support for Prometheus Operator
enabled: false
# enable support for Prometheus Operator
enabled: false

# Job label for scrape target
jobLabel: app.kubernetes.io/name

# Job label for scrape target
jobLabel: app
# Scrape interval. If not set, the Prometheus default scrape interval is used.
interval: ""

# Scrape interval. If not set, the Prometheus default scrape interval is used.
interval: ""
# Additional labels for Prometheus Operator
labels: {}

allowTagExpansion: false

Expand Down