Skip to content

Commit

Permalink
Add support to fluentd-daemonset-azureservicebus
Browse files Browse the repository at this point in the history
Signed-off-by: Victor  Godoy Hernández <vigohe@gmail.com>
  • Loading branch information
vigohe committed Aug 3, 2021
1 parent 8f14a0d commit 91f4fd8
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
IMAGE_NAME := fluent/fluentd-kubernetes
X86_IMAGES := \
v1.13/debian-azureblob:v1.13.3-debian-azureblob-amd64-1.1,v1.13-debian-azureblob-amd64-1 \
v1.13/debian-azureservicebus:v1.13.3-debian-azureservicebus-amd64-1.1,v1.13-debian-azureservicebus-amd64-1 \
v1.13/debian-elasticsearch7:v1.13.3-debian-elasticsearch7-amd64-1.1,v1.13-debian-elasticsearch7-amd64-1,v1-debian-elasticsearch-amd64 \
v1.13/debian-elasticsearch6:v1.13.3-debian-elasticsearch6-amd64-1.1,v1.13-debian-elasticsearch6-amd64-1 \
v1.13/debian-loggly:v1.13.3-debian-loggly-amd64-1.1,v1.13-debian-loggly-amd64-1 \
Expand All @@ -34,6 +35,7 @@ X86_IMAGES := \

ARM64_IMAGES := \
v1.13/arm64/debian-azureblob:v1.13.3-debian-azureblob-arm64-1.1,v1.13-debian-azureblob-arm64-1 \
v1.13/arm64/debian-azureservicebus:v1.13.3-debian-azureservicebus-arm64-1.1,v1.13-debian-azureservicebus-arm64-1 \
v1.13/arm64/debian-elasticsearch7:v1.13.3-debian-elasticsearch7-arm64-1.1,v1.13-debian-elasticsearch7-arm64-1,v1-debian-elasticsearch-arm64 \
v1.13/arm64/debian-elasticsearch6:v1.13.3-debian-elasticsearch6-arm64-1.1,v1.13-debian-elasticsearch6-arm64-1 \
v1.13/arm64/debian-loggly:v1.13.3-debian-loggly-arm64-1.1,v1.13-debian-loggly-arm64-1 \
Expand Down
104 changes: 104 additions & 0 deletions fluentd-daemonset-azureservicebus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: fluentd
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: fluentd
rules:
- apiGroups:
- ""
resources:
- pods
- namespaces
verbs:
- get
- list
- watch
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: fluentd
roleRef:
kind: ClusterRole
name: fluentd
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: fluentd
namespace: kube-system
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluentd-azureblob
namespace: kube-system
labels:
k8s-app: fluentd-logging
version: v1
spec:
selector:
matchLabels:
k8s-app: fluentd-logging
version: v1
template:
metadata:
labels:
k8s-app: fluentd-logging
version: v1
spec:
serviceAccount: fluentd
serviceAccountName: fluentd
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
containers:
- name: fluentd-azureblob
image: fluent/fluentd-kubernetes-daemonset:v1-debian-azureblob
imagePullPolicy: Always
env:
- name: AZURESERVICEBUS_NAMESPACE
value: "mynamespace"
- name: AZURESERVICEBUS_QUEUENAME
value: "myqueuename"
- name: AZURESERIVCEBUS_ACCESSKEYNAME
value: "myaccesskeyname"
- name: AZURESERIVCEBUS_ACCESSKEYVALUEFILE
value: "myaccesskeyvaluefile"
- name: AZURESERIVCEBUS_TIMETOLIVE
value: "mytimetolive"
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 200Mi
volumeMounts:
- name: varlog
mountPath: /var/log
# When actual pod logs in /var/lib/docker/containers, the following lines should be used.
# - name: dockercontainerlogdirectory
# mountPath: /var/lib/docker/containers
# readOnly: true
# When actual pod logs in /var/log/pods, the following lines should be used.
- name: dockercontainerlogdirectory
mountPath: /var/log/pods
readOnly: true
terminationGracePeriodSeconds: 30
volumes:
- name: varlog
hostPath:
path: /var/log
# When actual pod logs in /var/lib/docker/containers, the following lines should be used.
# - name: dockercontainerlogdirectory
# hostPath:
# path: /var/lib/docker/containers
# When actual pod logs in /var/log/pods, the following lines should be used.
- name: dockercontainerlogdirectory
hostPath:
path: /var/log/pods
2 changes: 1 addition & 1 deletion templates/Dockerfile.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% fluentd_ver = version.split("-").first %>
<% target = (dockerfile.split("/").last.split("-").last) %>
<% requires_git = %w(graylog).include? target %>
<% requires_git = %w(graylog azureservicebus).include? target %>
<% is_arm64 = (dockerfile.split("/")[1] == "arm64") %>
# AUTOMATICALLY GENERATED
# DO NOT EDIT THIS FILE DIRECTLY, USE /templates/Dockerfile.erb
Expand Down
2 changes: 2 additions & 0 deletions templates/Gemfile.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ gem "fluent-plugin-google-cloud", "~> 0.4.10"
<% when "azureblob" %>
gem "azure-storage-blob", "~> 2.0"
gem "fluent-plugin-azure-storage-append-blob-lts", "~> 0.6.0"
<% when "azureservicebus" %>
gem "fluent-plugin-servicebus-queue", :git => "git://github.com/Azure/fluent-plugin-servicebus-queue.git"
<% when "s3" %>
gem "aws-sdk-s3", "~> 1.91"
gem "fluent-plugin-s3", "~> 1.5.1"
Expand Down
16 changes: 16 additions & 0 deletions templates/conf/fluent.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,20 @@
</buffer>
</match>

<% when "azureservicebus"%>
<match **>
@type azure_servicebus_queue
@id out_azure_servicebus_queue
namespace "#{ENV['AZURESERVICEBUS_NAMESPACE']}"
queueName "#{ENV['AZURESERVICEBUS_QUEUENAME']}"
accessKeyName "#{ENV['AZURESERIVCEBUS_ACCESSKEYNAME']}"
accessKeyValueFile "#{ENV['AZURESERIVCEBUS_ACCESSKEYVALUEFILE']}"
timeToLive "#{ENV['AZURESERIVCEBUS_TIMETOLIVE']}"
field "#{ENV['AZURESERVICEBUS_FIELD'] || 'message'}"
<buffer>
@type memory
flush_interval 1s
</buffer>
</match>

<% end %>

0 comments on commit 91f4fd8

Please sign in to comment.