diff --git a/charts/fluent-bit b/charts/fluent-bit deleted file mode 120000 index 8f38531..0000000 --- a/charts/fluent-bit +++ /dev/null @@ -1 +0,0 @@ -../../fluent-bit-helm/charts/fluent-bit \ No newline at end of file diff --git a/charts/kubezero-logging/Chart.yaml b/charts/kubezero-logging/Chart.yaml index 344c0b1..e455c45 100644 --- a/charts/kubezero-logging/Chart.yaml +++ b/charts/kubezero-logging/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: kubezero-logging description: KubeZero Umbrella Chart for complete EFK stack type: application -version: 0.5.1 +version: 0.5.2 appVersion: 1.3.1 home: https://kubezero.com icon: https://cdn.zero-downtime.net/assets/kubezero/logo-small-64.png @@ -23,12 +23,11 @@ dependencies: repository: https://helm.elastic.co condition: eck-operator.enabled - name: fluentd - version: 2.5.1 - repository: https://kubernetes-charts.storage.googleapis.com/ + version: 2.5.3 + repository: charts/fluentd condition: fluentd.enabled -# - name: fluent-bit -# version: 0.7.10 -# repository: https://zero-down-time.github.io/kubezero/ - # repository: https://fluent.github.io/helm-charts -# condition: fluent-bit.enabled + - name: fluent-bit + version: 0.7.10 + repository: charts/fluent-bit + condition: fluent-bit.enabled kubeVersion: ">= 1.16.0" diff --git a/charts/kubezero-logging/charts/fluentd/.helmignore b/charts/kubezero-logging/charts/fluentd/.helmignore new file mode 100644 index 0000000..f0c1319 --- /dev/null +++ b/charts/kubezero-logging/charts/fluentd/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/charts/kubezero-logging/charts/fluentd/Chart.yaml b/charts/kubezero-logging/charts/fluentd/Chart.yaml new file mode 100644 index 0000000..90be6be --- /dev/null +++ b/charts/kubezero-logging/charts/fluentd/Chart.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +description: DEPRECATED A Fluentd Elasticsearch Helm chart for Kubernetes. +icon: https://raw.githubusercontent.com/fluent/fluentd-docs/master/public/logo/Fluentd_square.png +name: fluentd +version: 2.5.3 +appVersion: v2.4.0 +home: https://www.fluentd.org/ +sources: +- https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/fluentd-elasticsearch/fluentd-es-image +- https://quay.io/repository/coreos/fluentd-kubernetes +- https://github.com/coreos/fluentd-kubernetes-daemonset +- https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html diff --git a/charts/kubezero-logging/charts/fluentd/README.md b/charts/kubezero-logging/charts/fluentd/README.md new file mode 100644 index 0000000..06cb698 --- /dev/null +++ b/charts/kubezero-logging/charts/fluentd/README.md @@ -0,0 +1,121 @@ +# ⚠️ Repo Archive Notice + +As of Nov 13, 2020, charts in this repo will no longer be updated. +For more information, see the Helm Charts [Deprecation and Archive Notice](https://github.com/helm/charts#%EF%B8%8F-deprecation-and-archive-notice), and [Update](https://helm.sh/blog/charts-repo-deprecation/). + +# fluentd + +[Fluentd](https://www.fluentd.org/) collects events from various data sources and writes them to files, RDBMS, NoSQL, IaaS, SaaS, Hadoop and so on. Fluentd helps you unify your logging infrastructure (Learn more about the Unified Logging Layer). + +## DEPRECATION NOTICE + +This chart is deprecated and no longer supported. + +## TL;DR; + +```console +$ helm install stable/fluentd +``` + +## Introduction + +This chart bootstraps an fluentd deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```console +$ helm install stable/fluentd --name my-release +``` + +The command deploys fluentd on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. + +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment: + +```console +$ helm delete my-release +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Autoscaling + +By enabling autoscaling the chart will use statefulset with hpa instead of deployment with PVC. +Please be noted to [statefulset limitation](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#limitations) +The autoscaling is disabled by default for backward compatibility + +## Configuration + +The following table lists the configurable parameters of the fluentd chart and their default values. + +Parameter | Description | Default +--- | --- | --- +`useStatefulSet` | Deploy as a StatefulSet regardless of whether autoscaling is enabled | `nil` +`affinity` | node/pod affinities | `{}` +`configMaps` | Fluentd configuration | See [values.yaml](values.yaml) +`output.host` | output host | `elasticsearch-client.default.svc.cluster.local` +`output.port` | output port | `9200` +`output.scheme` | output scheme | `http` +`output.sslVersion` | output ssl version | `TLSv1` +`output.buffer_chunk_limit` | output buffer chunk limit | `2M` +`output.buffer_queue_limit` | output buffer queue limit | `8` +`deployment.labels` | Additional labels for pods | `{}` +`image.pullPolicy` | Image pull policy | `IfNotPresent` +`image.repository` | Image repository | `gcr.io/google-containers/fluentd-elasticsearch` +`image.tag` | Image tag | `v2.4.0` +`imagePullSecrets` | Specify image pull secrets | `nil` (does not add image pull secrets to deployed pods) +`extraEnvVars` | Adds additional environment variables to the deployment (in yaml syntax) | `{}` See [values.yaml](values.yaml) +`extraVolumeMounts` | Mount extra volumes (in yaml syntax) | `` See [values.yaml](values.yaml) +`extraVolumes` | Extra volumes (in yaml syntax) | `` See [values.yaml](values.yaml) +`ingress.enabled` | enable ingress | `false` +`ingress.labels` | list of labels for the ingress rule | See [values.yaml](values.yaml) +`ingress.annotations` | list of annotations for the ingress rule | `kubernetes.io/ingress.class: nginx` See [values.yaml](values.yaml) +`ingress.hosts` | host definition for ingress | See [values.yaml](values.yaml) +`ingress.tls` | tls rules for ingress | See [values.yaml](values.yaml) +`nodeSelector` | node labels for pod assignment | `{}` +`replicaCount` | desired number of pods | `1` ??? +`resources` | pod resource requests & limits | `{}` +`plugins.enabled` | Enable Plugins Installation | `false` +`plugins.pluginsList` | List of plugins to install | `[]` +`rbac.create` | Specifies whether RBAC resources should be created | `true` +`serviceAccount.create` | Specifies whether a service account should be created. | `true` +`serviceAccount.name` | Name of the service account. +`priorityClassName` | priorityClassName | `nil` +`service.loadBalancerIP` | If `service.type` is `LoadBalancer` set custom IP load balancer IP address | `nil` +`service.ports` | port definition for the service | See [values.yaml](values.yaml) +`service.type` | type of service | `ClusterIP` +`service.annotations` | list of annotations for the service | `{}` +`tolerations` | List of node taints to tolerate | `[]` +`persistence.enabled` | Enable buffer persistence | `false` +`persistence.accessMode` | Access mode for buffer persistence | `ReadWriteOnce` +`persistence.size` | Volume size for buffer persistence | `10Gi` +`autoscaling.enabled` | Set this to `true` to enable autoscaling | `false` +`autoscaling.minReplicas` | Set minimum number of replicas | `2` +`autoscaling.maxReplicas` | Set maximum number of replicas | `5` +`autoscaling.metrics` | metrics used for autoscaling | See [values.yaml](values.yaml) +`terminationGracePeriodSeconds` | Optional duration in seconds the pod needs to terminate gracefully | `30` +`metrics.enabled` | Set this to `true` to enable Prometheus metrics HTTP endpoint | `false` +`metrics.service.port` | Prometheus metrics HTTP endpoint port | `24231` +`metrics.serviceMonitor.enabled` | Set this to `true` to create ServiceMonitor for Prometheus operator | `false` +`metrics.serviceMonitor.additionalLabels` | Additional labels that can be used so ServiceMonitor will be discovered by Prometheus | `{}` +`metrics.serviceMonitor.namespace` | Optional namespace in which to create ServiceMonitor | `nil` +`metrics.serviceMonitor.interval` | Scrape interval. If not set, the Prometheus default scrape interval is used | `nil` +`metrics.serviceMonitor.scrapeTimeout` | Scrape timeout. If not set, the Prometheus default scrape timeout is used | `nil` + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```console +$ helm install stable/fluentd --name my-release \ + --set=image.tag=v0.0.2,resources.limits.cpu=200m +``` + +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, + +```console +$ helm install stable/fluentd --name my-release -f values.yaml +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) diff --git a/charts/kubezero-logging/charts/fluentd/templates/NOTES.txt b/charts/kubezero-logging/charts/fluentd/templates/NOTES.txt new file mode 100644 index 0000000..ab58dca --- /dev/null +++ b/charts/kubezero-logging/charts/fluentd/templates/NOTES.txt @@ -0,0 +1,6 @@ +To verify that Fluentd Elasticsearch has started, run: + + kubectl --namespace={{ .Release.Namespace }} get all -l "app={{ template "fluentd.name" . }},release={{ .Release.Name }}" + +THIS APPLICATION CAPTURES ALL CONSOLE OUTPUT AND FORWARDS IT TO Elasticsearch. Anything that might be identifying, +including things like IP addresses, container images, and object names will NOT be anonymized. diff --git a/charts/kubezero-logging/charts/fluentd/templates/_helpers.tpl b/charts/kubezero-logging/charts/fluentd/templates/_helpers.tpl new file mode 100644 index 0000000..557177f --- /dev/null +++ b/charts/kubezero-logging/charts/fluentd/templates/_helpers.tpl @@ -0,0 +1,43 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "fluentd.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "fluentd.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "fluentd.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "fluentd.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "fluentd.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/kubezero-logging/charts/fluentd/templates/clusterrole.yaml b/charts/kubezero-logging/charts/fluentd/templates/clusterrole.yaml new file mode 100644 index 0000000..ccdf142 --- /dev/null +++ b/charts/kubezero-logging/charts/fluentd/templates/clusterrole.yaml @@ -0,0 +1,21 @@ +{{- if .Values.rbac.create -}} +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: {{ include "fluentd.fullname" . }} + labels: + app: {{ template "fluentd.name" . }} + chart: {{ template "fluentd.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +rules: +- apiGroups: + - "" + resources: + - "namespaces" + - "pods" + verbs: + - "get" + - "watch" + - "list" +{{- end -}} diff --git a/charts/kubezero-logging/charts/fluentd/templates/clusterrolebinding.yaml b/charts/kubezero-logging/charts/fluentd/templates/clusterrolebinding.yaml new file mode 100644 index 0000000..7d4b85c --- /dev/null +++ b/charts/kubezero-logging/charts/fluentd/templates/clusterrolebinding.yaml @@ -0,0 +1,19 @@ +{{- if .Values.rbac.create -}} +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: {{ template "fluentd.fullname" . }} + labels: + app: {{ template "fluentd.name" . }} + chart: {{ template "fluentd.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +subjects: +- kind: ServiceAccount + name: {{ template "fluentd.fullname" . }} + namespace: {{ .Release.Namespace }} +roleRef: + kind: ClusterRole + name: {{ template "fluentd.fullname" . }} + apiGroup: rbac.authorization.k8s.io +{{- end -}} diff --git a/charts/kubezero-logging/charts/fluentd/templates/configmap.yaml b/charts/kubezero-logging/charts/fluentd/templates/configmap.yaml new file mode 100644 index 0000000..81d52c0 --- /dev/null +++ b/charts/kubezero-logging/charts/fluentd/templates/configmap.yaml @@ -0,0 +1,37 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "fluentd.fullname" . }} + labels: + app: {{ template "fluentd.name" . }} + chart: {{ template "fluentd.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: +{{- range $key, $value := .Values.configMaps }} + {{ $key }}: |- +{{ $value | indent 4 }} +{{- end }} +{{- if .Values.metrics.enabled }} + metrics.conf: | + + @type prometheus + port {{ .Values.metrics.service.port }} + + + + @type prometheus_monitor + + + + @type prometheus_output_monitor + +{{- end }} +{{- if and (.Values.plugins.enabled) (gt (len .Values.plugins.pluginsList) 0) }} + install-plugins.sh: |- + #!/bin/sh + {{- range $plugin := .Values.plugins.pluginsList }} + fluent-gem install {{ $plugin }} + {{- end }} + exec /run.sh +{{- end }} diff --git a/charts/kubezero-logging/charts/fluentd/templates/deployment.yaml b/charts/kubezero-logging/charts/fluentd/templates/deployment.yaml new file mode 100644 index 0000000..7afd466 --- /dev/null +++ b/charts/kubezero-logging/charts/fluentd/templates/deployment.yaml @@ -0,0 +1,151 @@ +{{- $statefulSet := or (.Values.autoscaling.enabled) (.Values.useStatefulSet) -}} +apiVersion: apps/v1 +{{- if $statefulSet }} +kind: StatefulSet +{{- else}} +kind: Deployment +{{- end}} +metadata: + name: {{ template "fluentd.fullname" . }} + labels: + app: {{ template "fluentd.name" . }} + chart: {{ template "fluentd.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: +{{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} +{{- end }} +{{- if .Values.autoscaling.enabled }} + serviceName: {{ template "fluentd.name" . }} +{{- end }} + selector: + matchLabels: + app: {{ template "fluentd.name" . }} + release: {{ .Release.Name }} + {{- if and .Values.persistence.enabled (not .Values.autoscaling.enabled) }} + strategy: + type: Recreate + {{- end }} + template: + metadata: + labels: + app: {{ template "fluentd.name" . }} + release: {{ .Release.Name }} +{{- with .Values.deployment.labels }} +{{ toYaml . | indent 8 }} +{{- end }} + annotations: + checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + {{- if .Values.annotations }} + {{- toYaml .Values.annotations | nindent 8 }} + {{- end }} + spec: +{{- if .Values.image.pullSecrets }} + imagePullSecrets: + {{- range $pullSecret := .Values.image.pullSecrets }} + - name: {{ $pullSecret }} + {{- end }} +{{- end }} + terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if and (.Values.plugins.enabled) (gt (len .Values.plugins.pluginsList) 0) }} + command: ["/bin/sh", "-c", "/etc/fluent/config.d/install-plugins.sh"] + {{- end }} + env: + - name: OUTPUT_HOST + value: {{ .Values.output.host | quote }} + - name: OUTPUT_PORT + value: {{ .Values.output.port | quote }} + - name: OUTPUT_SCHEME + value: {{ .Values.output.scheme | quote }} + - name: OUTPUT_SSL_VERSION + value: {{ .Values.output.sslVersion | quote }} + - name: OUTPUT_BUFFER_CHUNK_LIMIT + value: {{ .Values.output.buffer_chunk_limit | quote }} + - name: OUTPUT_BUFFER_QUEUE_LIMIT + value: {{ .Values.output.buffer_queue_limit | quote }} + {{- range $key, $value := .Values.env }} + - name: {{ $key | quote }} + value: {{ $value | quote }} + {{- end }} + {{- if .Values.extraEnvVars }} +{{ toYaml .Values.extraEnvVars | indent 10 }} + {{- end }} + resources: +{{ toYaml .Values.resources | indent 12 }} + ports: +{{- range $port := .Values.service.ports }} + - name: {{ $port.name }} + containerPort: {{ $port.containerPort }} + protocol: {{ $port.protocol }} +{{- end }} +{{- if .Values.metrics.enabled }} + - name: metrics + containerPort: {{ .Values.metrics.service.port }} + protocol: TCP +{{- end }} + - name: http-input + containerPort: 9880 + protocol: TCP + livenessProbe: + httpGet: + # Use percent encoding for query param. + # The value is {"log": "health check"}. + # the endpoint itself results in a new fluentd + # tag 'fluentd.pod-healthcheck' + path: /fluentd.pod.healthcheck?json=%7B%22log%22%3A+%22health+check%22%7D + port: 9880 + initialDelaySeconds: 5 + timeoutSeconds: 1 + volumeMounts: + - name: config-volume-{{ template "fluentd.fullname" . }} + mountPath: /etc/fluent/config.d + - name: buffer + mountPath: "/var/log/fluentd-buffers" +{{- if .Values.extraVolumeMounts }} +{{ toYaml .Values.extraVolumeMounts | indent 8 }} +{{- end }} + serviceAccountName: {{ template "fluentd.fullname" . }} + volumes: + - name: config-volume-{{ template "fluentd.fullname" . }} + configMap: + name: {{ template "fluentd.fullname" . }} + defaultMode: 0777 + {{- if and .Values.persistence.enabled (not $statefulSet) }} + - name: buffer + persistentVolumeClaim: + claimName: {{ template "fluentd.fullname" . }} + {{- else if (not .Values.persistence.enabled) }} + - name: buffer + emptyDir: {} + {{- end }} +{{- if .Values.extraVolumes }} +{{ toYaml .Values.extraVolumes | indent 8 }} +{{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} +{{- if and .Values.persistence.enabled ($statefulSet) }} + volumeClaimTemplates: + - metadata: + name: buffer + spec: + accessModes: [{{ .Values.persistence.accessMode }}] + storageClassName: {{ .Values.persistence.storageClass }} + resources: + requests: + storage: {{ .Values.persistence.size }} +{{- end }} diff --git a/charts/kubezero-logging/charts/fluentd/templates/hpa.yaml b/charts/kubezero-logging/charts/fluentd/templates/hpa.yaml new file mode 100644 index 0000000..3ffd699 --- /dev/null +++ b/charts/kubezero-logging/charts/fluentd/templates/hpa.yaml @@ -0,0 +1,20 @@ +{{- if and .Values.autoscaling.enabled}} +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "fluentd.fullname" . }} + labels: + app: {{ template "fluentd.name" . }} + chart: {{ template "fluentd.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: StatefulSet + name: {{ include "fluentd.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- toYaml .Values.autoscaling.metrics | nindent 4 }} +{{- end }} diff --git a/charts/kubezero-logging/charts/fluentd/templates/ingress.yaml b/charts/kubezero-logging/charts/fluentd/templates/ingress.yaml new file mode 100644 index 0000000..4ed5891 --- /dev/null +++ b/charts/kubezero-logging/charts/fluentd/templates/ingress.yaml @@ -0,0 +1,36 @@ +{{- if .Values.ingress.enabled -}} +{{- $serviceName := include "fluentd.fullname" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "fluentd.fullname" . }} + labels: + app: {{ template "fluentd.name" . }} + chart: {{ template "fluentd.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- if .Values.ingress.labels }} +{{ toYaml .Values.ingress.labels | indent 4 }} +{{- end }} +{{- if .Values.ingress.annotations }} + annotations: +{{ tpl ( toYaml .Values.ingress.annotations | indent 4 ) . }} +{{- end }} +spec: + rules: + {{- range $host := .Values.ingress.hosts }} + - http: + paths: + - path: {{ $host.path | default "/" }} + backend: + serviceName: {{ $serviceName }} + servicePort: {{ $host.servicePort }} + {{- if (not (empty $host.name)) }} + host: {{ $host.name }} + {{- end -}} + {{- end -}} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end -}} \ No newline at end of file diff --git a/charts/kubezero-logging/charts/fluentd/templates/pvc.yaml b/charts/kubezero-logging/charts/fluentd/templates/pvc.yaml new file mode 100644 index 0000000..694967b --- /dev/null +++ b/charts/kubezero-logging/charts/fluentd/templates/pvc.yaml @@ -0,0 +1,29 @@ +{{- $statefulSet := or (.Values.autoscaling.enabled) (.Values.useStatefulSet) -}} +{{- if and .Values.persistence.enabled (not $statefulSet) -}} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ template "fluentd.fullname" . }} + labels: + app: {{ template "fluentd.name" . }} + chart: {{ template "fluentd.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- if .Values.persistence.annotations }} + annotations: +{{ toYaml .Values.persistence.annotations | indent 4 }} +{{- end }} +spec: + accessModes: + - {{ .Values.persistence.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} +{{- if .Values.persistence.storageClass }} +{{- if (eq "-" .Values.persistence.storageClass) }} + storageClassName: "" +{{- else }} + storageClassName: "{{ .Values.persistence.storageClass }}" +{{- end }} +{{- end }} +{{- end -}} diff --git a/charts/kubezero-logging/charts/fluentd/templates/role.yaml b/charts/kubezero-logging/charts/fluentd/templates/role.yaml new file mode 100644 index 0000000..36d48d9 --- /dev/null +++ b/charts/kubezero-logging/charts/fluentd/templates/role.yaml @@ -0,0 +1,17 @@ +{{- if .Values.rbac.create }} +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: Role +metadata: + name: {{ template "fluentd.fullname" . }} + labels: + app: {{ template "fluentd.name" . }} + chart: {{ template "fluentd.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +rules: +- apiGroups: ['extensions'] + resources: ['podsecuritypolicies'] + verbs: ['use'] + resourceNames: + - {{ template "fluentd.fullname" . }} +{{- end }} diff --git a/charts/kubezero-logging/charts/fluentd/templates/rolebinding.yaml b/charts/kubezero-logging/charts/fluentd/templates/rolebinding.yaml new file mode 100644 index 0000000..09f5b0f --- /dev/null +++ b/charts/kubezero-logging/charts/fluentd/templates/rolebinding.yaml @@ -0,0 +1,19 @@ +{{- if .Values.rbac.create }} +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: RoleBinding +metadata: + name: {{ template "fluentd.fullname" . }} + labels: + app: {{ template "fluentd.name" . }} + chart: {{ template "fluentd.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +roleRef: + kind: Role + name: {{ template "fluentd.fullname" . }} + apiGroup: rbac.authorization.k8s.io +subjects: +- kind: ServiceAccount + name: {{ template "fluentd.fullname" . }} + namespace: {{ .Release.Namespace }} +{{- end }} diff --git a/charts/kubezero-logging/charts/fluentd/templates/service.yaml b/charts/kubezero-logging/charts/fluentd/templates/service.yaml new file mode 100644 index 0000000..1590cb5 --- /dev/null +++ b/charts/kubezero-logging/charts/fluentd/templates/service.yaml @@ -0,0 +1,35 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "fluentd.fullname" . }} + labels: + app: {{ template "fluentd.name" . }} + chart: {{ template "fluentd.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: +{{ toYaml .Values.service.annotations | indent 4 }} +spec: + type: {{ .Values.service.type }} + {{ if (and (eq .Values.service.type "LoadBalancer") (not (empty .Values.service.loadBalancerIP))) }} + loadBalancerIP: {{ .Values.service.loadBalancerIP }} + {{ end }} + ports: + {{- range $port := .Values.service.ports }} + - name: {{ $port.name }} + port: {{ $port.containerPort }} + targetPort: {{ $port.containerPort }} + protocol: {{ $port.protocol }} + {{- end }} + {{ if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }} + nodePort: {{ .Values.service.nodePort }} + {{ end }} + {{- if .Values.metrics.enabled }} + - name: metrics + port: {{ .Values.metrics.service.port }} + targetPort: metrics + protocol: TCP + {{- end }} + selector: + app: {{ template "fluentd.name" . }} + release: {{ .Release.Name }} diff --git a/charts/kubezero-logging/charts/fluentd/templates/serviceaccount.yaml b/charts/kubezero-logging/charts/fluentd/templates/serviceaccount.yaml new file mode 100644 index 0000000..f1db1da --- /dev/null +++ b/charts/kubezero-logging/charts/fluentd/templates/serviceaccount.yaml @@ -0,0 +1,11 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "fluentd.serviceAccountName" . }} + labels: + app: {{ template "fluentd.name" . }} + chart: {{ template "fluentd.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- end -}} diff --git a/charts/kubezero-logging/charts/fluentd/templates/servicemonitor.yaml b/charts/kubezero-logging/charts/fluentd/templates/servicemonitor.yaml new file mode 100644 index 0000000..76c55b7 --- /dev/null +++ b/charts/kubezero-logging/charts/fluentd/templates/servicemonitor.yaml @@ -0,0 +1,33 @@ +{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "fluentd.fullname" . }} + {{- if .Values.metrics.serviceMonitor.namespace }} + namespace: {{ .Values.metrics.serviceMonitor.namespace }} + {{- end }} + labels: + app: {{ template "fluentd.name" . }} + chart: {{ template "fluentd.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + {{- if .Values.metrics.serviceMonitor.additionalLabels }} +{{ toYaml .Values.metrics.serviceMonitor.additionalLabels | indent 4 }} + {{- end }} +spec: + endpoints: + - port: metrics + {{- if .Values.metrics.serviceMonitor.interval }} + interval: {{ .Values.metrics.serviceMonitor.interval }} + {{- end }} + {{- if .Values.metrics.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }} + {{- end }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: + app: {{ include "fluentd.name" . }} + release: {{ .Release.Name }} +{{- end }} diff --git a/charts/kubezero-logging/charts/fluentd/values.yaml b/charts/kubezero-logging/charts/fluentd/values.yaml new file mode 100644 index 0000000..6023fee --- /dev/null +++ b/charts/kubezero-logging/charts/fluentd/values.yaml @@ -0,0 +1,224 @@ +# Default values for fluentd. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 1 + +image: + repository: gcr.io/google-containers/fluentd-elasticsearch + tag: v2.4.0 + pullPolicy: IfNotPresent + # pullSecrets: + # - secret1 + # - secret2 + +output: + host: elasticsearch-client.default.svc.cluster.local + port: 9200 + scheme: http + sslVersion: TLSv1 + buffer_chunk_limit: 2M + buffer_queue_limit: 8 + +env: {} + +# Extra Environment Values - allows yaml definitions +extraEnvVars: +# - name: VALUE_FROM_SECRET +# valueFrom: +# secretKeyRef: +# name: secret_name +# key: secret_key + +# extraVolumes: +# - name: es-certs +# secret: +# defaultMode: 420 +# secretName: es-certs +# extraVolumeMounts: +# - name: es-certs +# mountPath: /certs +# readOnly: true + +plugins: + enabled: false + pluginsList: [] + +service: + annotations: {} + type: ClusterIP + # loadBalancerIP: + # type: NodePort + # nodePort: + # Used to create Service records + ports: + - name: "monitor-agent" + protocol: TCP + containerPort: 24220 + +metrics: + enabled: false + service: + port: 24231 + serviceMonitor: + enabled: false + additionalLabels: {} + # namespace: monitoring + # interval: 30s + # scrapeTimeout: 10s + +annotations: {} +# prometheus.io/scrape: "true" +# prometheus.io/port: "24231" + +# Pod Labels +deployment: + labels: {} + +ingress: + enabled: false + annotations: + kubernetes.io/ingress.class: nginx +# kubernetes.io/tls-acme: "true" +# # Depending on which version of ingress controller you may need to configure properly - https://kubernetes.github.io/ingress-nginx/examples/rewrite/#rewrite-target +# nginx.ingress.kubernetes.io/rewrite-target: / + labels: [] + # If doing TCP or UDP ingress rule don't forget to update your Ingress Controller to accept TCP connections - https://kubernetes.github.io/ingress-nginx/user-guide/exposing-tcp-udp-services/ + hosts: +# - name: "http-input.local" +# protocol: TCP +# servicePort: 9880 +# path: / + tls: {} + # Secrets must be manually created in the namespace. +# - secretName: http-input-tls +# hosts: +# - http-input.local + +configMaps: + general.conf: | + # Prevent fluentd from handling records containing its own logs. Otherwise + # it can lead to an infinite loop, when error in sending one message generates + # another message which also fails to be sent and so on. + + @type null + + + # Used for health checking + + @type http + port 9880 + bind 0.0.0.0 + + + # Emits internal metrics to every minute, and also exposes them on port + # 24220. Useful for determining if an output plugin is retryring/erroring, + # or determining the buffer queue length. + + @type monitor_agent + bind 0.0.0.0 + port 24220 + tag fluentd.monitor.metrics + + system.conf: |- + + root_dir /tmp/fluentd-buffers/ + + forward-input.conf: | + + @type forward + port 24224 + bind 0.0.0.0 + + output.conf: | + + @id elasticsearch + @type elasticsearch + @log_level info + include_tag_key true + # Replace with the host/port to your Elasticsearch cluster. + host "#{ENV['OUTPUT_HOST']}" + port "#{ENV['OUTPUT_PORT']}" + scheme "#{ENV['OUTPUT_SCHEME']}" + ssl_version "#{ENV['OUTPUT_SSL_VERSION']}" + logstash_format true + + @type file + path /var/log/fluentd-buffers/kubernetes.system.buffer + flush_mode interval + retry_type exponential_backoff + flush_thread_count 2 + flush_interval 5s + retry_forever + retry_max_interval 30 + chunk_limit_size "#{ENV['OUTPUT_BUFFER_CHUNK_LIMIT']}" + queue_limit_length "#{ENV['OUTPUT_BUFFER_QUEUE_LIMIT']}" + overflow_action block + + + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 500m + # memory: 200Mi + # requests: + # cpu: 500m + # memory: 200Mi + +rbac: + # Specifies whether RBAC resources should be created + create: true + +serviceAccount: + # Specifies whether a ServiceAccount should be created + create: true + # The name of the ServiceAccount to use. + # If not set and create is true, a name is generated using the fullname template + name: + +## Persist data to a persistent volume +persistence: + enabled: false + + ## If defined, storageClassName: + ## If set to "-", storageClassName: "", which disables dynamic provisioning + ## If undefined (the default) or set to null, no storageClassName spec is + ## set, choosing the default provisioner. (gp2 on AWS, standard on + ## GKE, AWS & OpenStack) + ## + # storageClass: "-" + # annotations: {} + accessMode: ReadWriteOnce + size: 10Gi + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +# Enable autoscaling using HorizontalPodAutoscaler +autoscaling: + enabled: false + minReplicas: 2 + maxReplicas: 5 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 60 + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 60 + +# Consider to set higher value when using in conjuction with autoscaling +# Full description about this field: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.15/#pod-v1-core +terminationGracePeriodSeconds: 30