Skip to content

Commit

Permalink
Merge pull request #20 from rh-mobb/aro-clf
Browse files Browse the repository at this point in the history
Aro clf
  • Loading branch information
paulczar authored Jan 26, 2022
2 parents ca1368a + 0d3cc97 commit 5bb2b85
Show file tree
Hide file tree
Showing 14 changed files with 357 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/aro-clf-am/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
11 changes: 11 additions & 0 deletions charts/aro-clf-am/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v2
name: aro-clf-am
description: A Helm chart for Kubernetes

type: application
version: 0.1.0

home: "https://rh-mobb.github.io/helm-charts/"

maintainers:
- name: rh-mobb
5 changes: 5 additions & 0 deletions charts/aro-clf-am/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# aro-clf-am Helm Chart

This chart configures an ARO Cluster to forward logs to Azure Monitor.

see https://mobb.ninja/docs/aro/clf-to-azure/ for detailed usage
24 changes: 24 additions & 0 deletions charts/aro-clf-am/files/operators.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
subscriptions:
- name: cluster-logging
channel: stable
installPlanApproval: Automatic
source: redhat-operators
sourceNamespace: openshift-marketplace
namespace: openshift-logging
startingCSV: cluster-logging.5.3.3-4
- name: elasticsearch-operator
channel: stable
installPlanApproval: Automatic
source: redhat-operators
sourceNamespace: openshift-marketplace
namespace: openshift-operators-redhat
startingCSV: elasticsearch-operator.5.3.3-4

operatorGroups:
- name: openshift-logging
namespace: openshift-logging
targetNamespace: openshift-logging
- name: openshift-operators-redhat
namespace: openshift-operators-redhat
targetNamespace: all

Empty file.
62 changes: 62 additions & 0 deletions charts/aro-clf-am/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "aro-clf-am.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 "aro-clf-am.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 "aro-clf-am.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "aro-clf-am.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "aro-clf-am.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
26 changes: 26 additions & 0 deletions charts/aro-clf-am/templates/clf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: logging.openshift.io/v1
kind: ClusterLogForwarder
metadata:
name: instance
namespace: openshift-logging
labels:
{{- include "aro-clf-am.labels" . | nindent 4 }}
spec:
outputs:
- name: fluentbit
type: fluentdForward
url: 'tcp://{{ include "aro-clf-am.fullname" . }}.{{ .Release.Namespace }}:24224'
pipelines:
- name: forward-to-fluentbit
inputRefs:
{{- if .Values.clf.infrastructure }}
- infrastructure
{{- end }}
{{- if .Values.clf.application }}
- application
{{- end }}
{{- if .Values.clf.audit }}
- audit
{{- end }}
outputRefs:
- fluentbit
19 changes: 19 additions & 0 deletions charts/aro-clf-am/templates/clusterlogging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: logging.openshift.io/v1
kind: ClusterLogging
metadata:
name: instance
namespace: openshift-logging
spec:
collection:
logs:
fluentd: {}
type: fluentd
logStore:
elasticsearch:
nodeCount: 0
type: elasticsearch
managementState: Managed
visualization:
kibana:
replicas: 0
type: kibana
32 changes: 32 additions & 0 deletions charts/aro-clf-am/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "aro-clf-am.fullname" . }}-config
labels:
{{- include "aro-clf-am.labels" . | nindent 4 }}
data:
fluent-bit.conf: |
[SERVICE]
Flush 1
Log_Level info
Daemon off
Parsers_File parsers.conf
HTTP_Server On
HTTP_Listen 0.0.0.0
HTTP_Port 2020
@INCLUDE input.conf
@INCLUDE output.conf
output.conf: |
[OUTPUT]
Name azure
Match *.*
Customer_ID ${WorkspaceId}
Shared_Key ${SharedKey}
Log_Type openshift
input.conf: |
[INPUT]
Name forward
Listen 0.0.0.0
Port 24224
Buffer_Chunk_Size 1M
Buffer_Max_Size 10M
54 changes: 54 additions & 0 deletions charts/aro-clf-am/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ include "aro-clf-am.fullname" . }}
labels:
{{- include "aro-clf-am.labels" . | nindent 4 }}
kubernetes.io/cluster-service: "true"
spec:
selector:
matchLabels:
{{- include "aro-clf-am.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
prometheus.io/scrape: "true"
prometheus.io/port: "2020"
prometheus.io/path: /api/v1/metrics/prometheus
{{- end }}
labels:
{{- include "aro-clf-am.selectorLabels" . | nindent 8 }}
kubernetes.io/cluster-service: "true"
spec:
serviceAccountName: {{ include "aro-clf-am.fullname" . }}
terminationGracePeriodSeconds: 10
containers:
- name: fluent-bit
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: 2020
- containerPort: 24224
env:
- name: WorkspaceId
valueFrom:
secretKeyRef:
name: {{ include "aro-clf-am.fullname" . }}
key: WorkspaceId
- name: SharedKey
valueFrom:
secretKeyRef:
name: {{ include "aro-clf-am.fullname" . }}
key: SharedKey
- name: LogName
value: logapp
volumeMounts:
- name: fluent-bit-etc
mountPath: /fluent-bit/etc/
volumes:
- name: fluent-bit-etc
configMap:
name: {{ include "aro-clf-am.fullname" . }}-config
14 changes: 14 additions & 0 deletions charts/aro-clf-am/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# kubectl create secret generic fluentbit-secrets -n azure-log-forwarder \
# --from-literal=WorkspaceId=$WORKSPACE_ID \
# --from-literal=SharedKey=$SHARED_KEY

apiVersion: v1
kind: Secret
metadata:
name: {{ include "aro-clf-am.fullname" . }}
labels:
{{- include "aro-clf-am.labels" . | nindent 4 }}
type: Opaque
data:
WorkspaceId: {{ .Values.azure.workspaceId | b64enc }}
SharedKey: {{ .Values.azure.sharedKey | b64enc }}
14 changes: 14 additions & 0 deletions charts/aro-clf-am/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "aro-clf-am.fullname" . }}
labels:
{{- include "aro-clf-am.labels" . | nindent 4 }}
kubernetes.io/cluster-service: "true"
spec:
ports:
- protocol: TCP
port: 24224
targetPort: 24224
selector:
{{- include "aro-clf-am.selectorLabels" . | nindent 4 }}
40 changes: 40 additions & 0 deletions charts/aro-clf-am/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{- if .Values.serviceAccount.create -}}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "aro-clf-am.serviceAccountName" . }}
labels:
{{- include "aro-clf-am.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "aro-clf-am.serviceAccountName" . }}
rules:
- apiGroups: [ "" ]
resources:
- namespaces
- pods
verbs:
- get
- watch
- list
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "aro-clf-am.serviceAccountName" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "aro-clf-am.serviceAccountName" . }}
subjects:
- kind: ServiceAccount
name: {{ include "aro-clf-am.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
33 changes: 33 additions & 0 deletions charts/aro-clf-am/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Default values for aro-clf-am.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

azure:
workspaceId: ""
sharedKey: ""

clf:
infrastructure: true
application: true
audit: false


image:
repository: fluent/fluent-bit
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: 1.6

nameOverride: ""
fullnameOverride: ""

serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

0 comments on commit 5bb2b85

Please sign in to comment.