Skip to content

Commit

Permalink
feat: conditionally enable k8s logs requirements
Browse files Browse the repository at this point in the history
Adds the ability to conditionally enable some role and volume access
settings to enable k8s logs as a source
Also adds the ability to supply a PersistentVolumeClaim name

ref: LOG-18839
  • Loading branch information
matt-march committed Feb 2, 2024
1 parent 42f9841 commit 711f44e
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/edge/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ icon: https://app.mezmo.com/assets/img/mz-logo-square-128.png
description: A Helm chart for deploying Mezmo Edge
type: application
appVersion: "3.1.2"
version: 0.8.3
version: 0.8.4
maintainers:
- name: Mezmo
email: help@mezmo.com
2 changes: 2 additions & 0 deletions charts/edge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,7 @@ helm install edge mezmo/edge \
| service.sourcePorts.start | int | 8000 | The start of the port range (inclusive [start, end])
| service.sourcePorts.end | int | 8010 | The end of the port range (set 0 or "" to disable port range)
| service.sourcePorts.list | array[] | [] | Optional list of discrete ports to configure on the service
| enableK8sLogs | boolean | false | Whether or not to add ClusterRole and Volume access required for k8s logs source
| pvcClaimName | string | "" | Optional name for an existing PersistentStorageClaim to use for default storage

\* Port 8686 is reserved for internal use, and should not be additionally configured for sourcePorts
35 changes: 35 additions & 0 deletions charts/edge/templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{{- if .Values.enableK8sLogs }}
# Permissions to use Kubernetes API.
# Requires that RBAC authorization is enabled.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "edge.fullname" . }}
labels:
{{- include "edge.labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
resources:
- namespaces
- nodes
- pods
verbs:
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "edge.fullname" . }}
labels:
{{- include "edge.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "edge.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "edge.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end }}
29 changes: 28 additions & 1 deletion charts/edge/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,25 @@ spec:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
volumes:
- name: data
{{- if .Values.pvcClaimName }}
persistentVolumeClaim:
claimName: {{ .Values.pvcClaimName | quote }}
{{- else }}
emptyDir: {}
{{- end }}
- name: config
projected:
sources:
- configMap:
name: {{ include "edge.fullname" . }}
{{- if .Values.enableK8sLogs }}
- hostPath:
path: /var/log/
name: var-log
- hostPath:
path: /var/lib/
name: var-lib
{{- end }}
terminationGracePeriodSeconds: 60
containers:
- name: {{ .Chart.Name }}
Expand Down Expand Up @@ -71,6 +84,12 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.labels['apps.kubernetes.io/pod-index']
{{- if .Values.enableK8sLogs }}
- name: EDGE_SELF_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
{{- end }}
- name: MEZMO_RESHAPE_MESSAGE
value: "1"
args:
Expand All @@ -80,10 +99,18 @@ spec:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: data
mountPath: "/vector-data-dir"
mountPath: "/data/vector"
- name: config
mountPath: "/etc/vector/"
readOnly: true
{{- if .Values.enableK8sLogs }}
- mountPath: /var/log/
name: var-log
readOnly: true
- mountPath: /var/lib/
name: var-lib
readOnly: true
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
5 changes: 5 additions & 0 deletions charts/edge/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,8 @@ podSecurityContext: {}
securityContext: {}

imagePullSecrets: []

enableK8sLogs: false

# Optional PersistentStorageClaim name to use for default storage
pvcClaimName: ""

0 comments on commit 711f44e

Please sign in to comment.