Skip to content

Commit

Permalink
[fluentd-kubernetes] add serviceaccount (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin authored Jun 23, 2020
1 parent 1ce8a8c commit 55d38cf
Show file tree
Hide file tree
Showing 11 changed files with 240 additions and 117 deletions.
8 changes: 5 additions & 3 deletions incubator/fluentd-kubernetes/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v1
description: Kubernetes logs collect and forward with Fluentd.
icon: https://raw.githubusercontent.com/fluent/fluentd-docs/master/public/logo/Fluentd_square.png
name: fluentd-kubernetes
version: 0.3.0
appVersion: 0.12
version: 0.4.0
appVersion: 1.8.0
home: https://www.fluentd.org/
sources:
- https://quay.io/repository/coreos/fluentd-kubernetes
Expand All @@ -12,4 +12,6 @@ maintainers:
- name: cloudposse
email: [email protected]
- name: goruha
email: [email protected]
email: [email protected]
- name: 3h4x
email: [email protected]
4 changes: 2 additions & 2 deletions incubator/fluentd-kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ env:
OUTPUT_BUFFER_QUEUE_LIMIT: 8

configDir: /etc/fluent/config.d
configMap:
configMaps:
general.conf: |
<match fluentd.**>
@type null
Expand Down Expand Up @@ -132,7 +132,7 @@ env:
OUTPUT_BUFFER_QUEUE_LIMIT: 8
configDir: /etc/fluent/config.d
configMap:
configMaps:
system.conf: |-
<system>
root_dir /tmp/fluentd-buffers/
Expand Down
21 changes: 21 additions & 0 deletions incubator/fluentd-kubernetes/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if .Values.serviceAccount.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Values.serviceAccount.name }}
labels:
app: {{ template "fluentd_kubernetes.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
rules:
- apiGroups:
- ""
resources:
- pods
- namespaces
verbs:
- get
- list
- watch
{{- end }}
19 changes: 19 additions & 0 deletions incubator/fluentd-kubernetes/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- if .Values.serviceAccount.enabled }}
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ .Values.serviceAccount.name }}
labels:
app: {{ template "fluentd_kubernetes.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
roleRef:
kind: ClusterRole
name: {{ .Values.serviceAccount.name }}
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: {{ .Values.serviceAccount.name }}
namespace: {{ .Release.Namespace }}
{{- end }}
31 changes: 23 additions & 8 deletions incubator/fluentd-kubernetes/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
{{ with index .Values "configMaps" -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "fluentd_kubernetes.fullname" . }}
name: {{ template "fluentd_kubernetes.fullname" $ }}-config
labels:
app: {{ template "fluentd_kubernetes.name" . }}
chart: {{ template "fluentd_kubernetes.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
app: {{ template "fluentd_kubernetes.name" $ }}
chart: {{ template "fluentd_kubernetes.chart" $ }}
release: {{ $.Release.Name }}
heritage: {{ $.Release.Service }}
data:
{{- range $key, $value := .Values.configMaps }}
{{ $key }}: |-
{{ $value | indent 4 }}
{{- range $key, $value := . }}
{{ $key }}: |- {{ $value | nindent 4 }}
{{- end }}
{{- end }}
{{- with index .Values "fluent.conf" }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "fluentd_kubernetes.fullname" $ }}-fluent-conf
labels:
app: {{ template "fluentd_kubernetes.name" $ }}
chart: {{ template "fluentd_kubernetes.chart" $ }}
release: {{ $.Release.Name }}
heritage: {{ $.Release.Service }}
data:
fluent.conf: |- {{ . | nindent 4 }}
{{- end }}
72 changes: 44 additions & 28 deletions incubator/fluentd-kubernetes/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,22 @@ spec:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
spec:
{{- if .Values.serviceAccount.name }}
serviceAccountName: {{ .Values.serviceAccount.name }}
{{- end }}
tolerations:
- key: node-role.kubernetes.io/master
- operator: Exists
effect: NoSchedule
{{- with index .Values "priorityClassName" }}
priorityClassName: {{ . }}
{{- end }}
containers:
{{- if .Values.image.pullSecrets }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range $pullSecret := .Values.image.pullSecrets }}
{{- range $pullSecret := .Values.image.pullSecrets }}
- name: {{ $pullSecret }}
{{- end }}
{{- end }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
Expand All @@ -42,30 +48,29 @@ spec:
runAsNonRoot: false
runAsUser: 0
env:
{{- range $name, $value := .Values.env.open }}
{{- if not (empty $value) }}
{{- range $name, $value := .Values.env.open }}
{{- if not (empty $value) }}
- name: {{ $name | quote }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
{{- $secret_name := include "fluentd_kubernetes.fullname" . }}
{{- range $name, $value := .Values.env.secret }}
{{- if not ( empty $value) }}
{{- end }}
{{- end }}
{{- $secret_name := include "fluentd_kubernetes.fullname" . }}
{{- range $name, $value := .Values.env.secret }}
{{- if not ( empty $value) }}
- name: {{ $name | quote }}
valueFrom:
secretKeyRef:
name: {{ $secret_name }}
key: {{ $name | quote }}
{{- end }}
{{- end }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
{{- end }}
resources: {{ toYaml .Values.resources | nindent 12 }}
ports:
{{- range $port := .Values.service.ports }}
{{- range $port := .Values.service.ports }}
- name: {{ $port.name }}
containerPort: {{ $port.containerPort }}
containerPort: {{ $port.targetPort }}
protocol: {{ $port.protocol }}
{{- end }}
{{- end }}
- name: http-input
containerPort: 9880
protocol: TCP
Expand All @@ -76,8 +81,15 @@ spec:
mountPath: /mnt/pos
- name: varlibdockercontainers
mountPath: /var/lib/docker/
- name: config-volume-{{ template "fluentd_kubernetes.fullname" . }}
mountPath: {{ .Values.configDir }}
{{- with index .Values "configMaps" }}
- name: config-volume-{{ template "fluentd_kubernetes.fullname" $ }}
mountPath: {{ $.Values.configDir }}
{{- end }}
{{- with index .Values "fluent.conf" }}
- name: fluent-conf
mountPath: /fluentd/etc/fluent.conf
subPath: fluent.conf
{{- end }}
volumes:
- name: varlog
hostPath:
Expand All @@ -87,18 +99,22 @@ spec:
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/
- name: config-volume-{{ template "fluentd_kubernetes.fullname" . }}
{{- with index .Values "fluent.conf" }}
- name: fluent-conf
configMap:
name: {{ template "fluentd_kubernetes.fullname" $ }}-fluent-conf
{{- end }}
{{- with index .Values "configMaps" }}
- name: config-volume-{{ template "fluentd_kubernetes.fullname" $ }}
configMap:
name: {{ template "fluentd_kubernetes.fullname" . }}
name: {{ template "fluentd_kubernetes.fullname" $ }}-config
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
nodeSelector: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
affinity: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
tolerations: {{ toYaml . | nindent 8 }}
{{- end }}
14 changes: 8 additions & 6 deletions incubator/fluentd-kubernetes/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{{ with .Values.env.secret }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "fluentd_kubernetes.fullname" . }}
name: {{ include "fluentd_kubernetes.fullname" $ }}
labels:
app: {{ template "fluentd_kubernetes.name" . }}
chart: {{ template "fluentd_kubernetes.chart" . }}
app: {{ template "fluentd_kubernetes.name" $ }}
chart: {{ template "fluentd_kubernetes.chart" $ }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
type: Opaque
data:
{{- range $name, $value := .Values.env.secret }}
{{- if not (empty $value) }}
{{- range $name, $value := . }}
{{- if not (empty $value) }}
{{ $name }}: {{ $value | b64enc }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
6 changes: 4 additions & 2 deletions incubator/fluentd-kubernetes/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{ if .Values.service.enabled -}}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -12,10 +13,11 @@ spec:
ports:
{{- range $port := .Values.service.ports }}
- name: {{ $port.name }}
port: {{ $port.externalPort }}
targetPort: {{ $port.containerPort }}
port: {{ $port.port }}
targetPort: {{ $port.targetPort }}
protocol: {{ $port.protocol }}
{{- end }}
selector:
app: {{ template "fluentd_kubernetes.name" . }}
release: {{ .Release.Name }}
{{- end }}
17 changes: 17 additions & 0 deletions incubator/fluentd-kubernetes/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.serviceAccount.enabled }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Values.serviceAccount.name }}
{{- with index .Values.serviceAccount "annotations"}}
annotations:
{{- range $key, $value := . }}
"{{ $key }}": "{{ $value }}"
{{- end }}
{{- end }}
labels:
app: {{ template "fluentd_kubernetes.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- end }}
18 changes: 18 additions & 0 deletions incubator/fluentd-kubernetes/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if .Values.serviceMonitor.enabled }}
kind: ServiceMonitor
apiVersion: monitoring.coreos.com/v1
metadata:
name: {{ template "fluentd_kubernetes.fullname" . }}
labels:
app: {{ template "fluentd_kubernetes.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
endpoints:
- port: metrics
selector:
matchLabels:
app: {{ template "fluentd_kubernetes.name" . }}
release: {{ .Release.Name }}
{{- end }}
Loading

0 comments on commit 55d38cf

Please sign in to comment.