Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions base-image/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
############ escape=`

ARG WIN_TAG=ltsc2019

FROM mcr.microsoft.com/windows/servercore:$WIN_TAG as ruby-base
LABEL maintainer "Fluentd developers <[email protected]>"
LABEL Description="Fluentd docker image" Vendor="Fluent Organization" Version="1.13.1"


# Do not split this into multiple RUN!
# Docker creates a layer for every RUN-Statement
RUN powershell -Command "Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"

# Fluentd depends on cool.io whose fat gem is only available for Ruby < 2.5, so need to specify --platform ruby when install Ruby > 2.5 and install msys2 to get dev tools
# NOTE: For avoiding stalling with docker build on windows, we must use latest version of msys2.
RUN choco install -y ruby --version=2.7.2.1 --params "'/InstallDir:C:\ruby27'" \
&& MD C:\Users\ContainerUser\.gem \
&& MD C:\fluentd \
&& refreshenv \
&& echo gem: --user-install --no-document >> c:/Users/ContainerUser/.gemrc \
&& gem update --system

USER ContainerAdministrator
RUN setx /m PATH "C:\Users\ContainerUser\.gem\bin;%PATH%" \
&& setx /m GEM_HOME c:/Users/ContainerUser/.gem
USER ContainerUser



FROM ruby-base as ruby-build

USER ContainerAdministrator
RUN choco install -y msys2 --version 20210604.0.0 --params "'/NoPath /NoUpdate /InstallDir:C:\msys64'" \
&& setx /m PATH "C:\msys64\usr\bin;%PATH%" \
&& setx /m MSYS winsymlinks:nativestrict \
&& ridk install 3 \
&& mklink /J C:\msys64\fluentd C:\fluentd
USER ContainerUser

SHELL ["bash", "-lc"]
RUN "echo 'PATH=$PATH:/mingw64/bin:/c/ruby27/bin:/c/users/containeruser/.gem/ruby/2.7.0/bin' >> /etc/profile.d/000-mingw64.sh \
&& pacman -Suu --noconfirm && pacman -S --needed --noconfirm git \
"

# RUN "pacman -Suu --noconfirm && pacman -S --needed --noconfirm git"

COPY basegems/Gemfile /fluentd/Gemfile.basegems
COPY basegems/Gemfile.lock /fluentd/Gemfile.basegems.lock

COPY Gemfile /fluentd/Gemfile
COPY Gemfile.lock /fluentd/Gemfile.lock

RUN "\
gem install bundler:'>= 2.2.27' rexml:'>= 3.2.5' rdoc:'>= 6.3.2' json:'>= 2.5.1' webrick:'>= 1.7.0' bigdecimal \
&& cd /fluentd \
&& bundler config --global jobs 4 \
&& bundler config set --global without \"development test\" \
&& bundler config set --global cache_all 'false' \
&& bundler install --no-cache --gemfile=Gemfile.basegems \
&& bundler install --no-cache --gemfile=Gemfile \
&& git clone https://github.com/Cryptophobia/fluent-plugin-google-cloud.git fluent-plugin-google-cloud \
&& gem build -C fluent-plugin-google-cloud fluent-plugin-google-cloud.gemspec \
&& gem install --no-document fluent-plugin-google-cloud/fluent-plugin-google-cloud-*.gem \
&& git clone https://github.com/Cryptophobia/fluent-plugin-loggly.git fluent-plugin-loggly \
&& gem build -C fluent-plugin-loggly fluent-plugin-loggly.gemspec \
&& gem install fluent-plugin-loggly/fluent-plugin-loggly-*.gem \
&& rm -rf $GEM_HOME/cache/* $GEM_HOME/doc/* \
"
# RUN "cd /fluentd && bundle config list && du -h --max-depth 1 $GEM_HOME"

FROM ruby-base as ruby-runtime
COPY --from=ruby-build /Users/ContainerUser/.gem /Users/ContainerUser/.gem
COPY plugins /etc/fluent-plugin

USER ContainerAdministrator
RUN tzutil /s UTC \
&& (if not exist C:\etc\fluent-conf (MD C:\etc\fluent-conf)) \
&& (if not exist C:\etc\fluent-plugin (MD C:\etc\fluent-plugin)) \
&& (if not exist C:\var\run\secrets\kubernetes.io\serviceaccount (MD C:\var\run\secrets\kubernetes.io\serviceaccount)) \
&& (if not exist C:\var\log (MD C:\var\log)) \
&& (if not exist C:\var\lib\kubelet (MD C:\var\lib\kubelet))
USER ContainerUser
RUN powershell -Command "Invoke-WebRequest https://raw.githubusercontent.com/fluent/fluentd-kubernetes-daemonset/master/docker-image/v1.13/debian-elasticsearch7/plugins/parser_kubernetes.rb -OutFile C:\etc\fluent-plugin\parser_kubernetes.rb \
; Invoke-WebRequest https://raw.githubusercontent.com/fluent/fluentd-kubernetes-daemonset/master/docker-image/v1.13/debian-elasticsearch7/plugins/parser_multiline_kubernetes.rb -OutFile C:\etc\fluent-plugin\parser_multiline_kubernetes.rb \
"

COPY failsafe.conf /etc/fluent-conf/failsafe.conf
COPY entrypoint.ps1 /entrypoint.ps1
ENTRYPOINT ["powershell", "/entrypoint.ps1"]
14 changes: 12 additions & 2 deletions base-image/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
# Copyright © 2018 VMware, Inc. All Rights Reserved.
# SPDX-License-Identifier: BSD-2-Clause

IMAGE ?= vmware/base-fluentd-operator
TAG ?= latest
IMAGE ?= vmware/base-fluentd-operator
IMG_ARCH ?= amd64
WIN_TAG ?=
IMG_OS ?= linux
TAG ?= $(IMG_ARCH)-$(IMG_OS)$(shell v='$(WIN_TAG)'; echo "$${v:+-}$${v:-}")

.PHONY: test
ttt:
echo $(TAG)

build-image:
DOCKER_BUILDKIT=1 docker build -t $(IMAGE):$(TAG) .

build-windows-image:
@echo Building $(IMAGE):$(TAG)
docker build --network "Default Switch" -f Dockerfile.windows --build-arg WIN_TAG=$(WIN_TAG) -t $(IMAGE):$(TAG) .


shell:
docker run --entrypoint=/bin/bash \
-ti --rm -v `pwd`:/workspace --net=host \
Expand Down
25 changes: 25 additions & 0 deletions base-image/entrypoint.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
$FLUENTD_CONF = if ($env:FLUENTD_CONF) { $env:FLUENTD_CONF } else { "fluent.conf" };
$DEFAULT_FLUENT_CONF = "/etc/fluent-conf/${FLUENTD_CONF}";
$FLUENTD_OPT = $env:FLUENTD_OPT

echo "Using configuration: ${DEFAULT_FLUENT_CONF}"
echo "With FLUENTD_OPT: ${FLUENTD_OPT}"

$retries = if ($env:RETRIES) { $env:RETRIES } else { 60 };
$ready = $false

foreach ($attempt in 1..$retries) {
if (Test-Path -Path $DEFAULT_FLUENT_CONF -PathType Leaf) {
$ready = $true
break
}
echo "Waiting for config file to become available: $attempt of $retries"
Start-Sleep -Seconds 10
}
if ($ready -ne $true ) {return 1}
echo "Found configuration file: ${DEFAULT_FLUENT_CONF}"
$cmdline_args = "& fluentd", "-c", ${DEFAULT_FLUENT_CONF}, "-p", "/etc/fluent-plugin", $FLUENTD_OPT
$cmdline = $cmdline_args -join ' '
echo "cmdline $cmdline"
Invoke-Expression $cmdline
#& \fluentd.cmd -c ${DEFAULT_FLUENT_CONF} -p /etc/fluent/plugins $FLUENTD_OPT
112 changes: 112 additions & 0 deletions charts/log-router/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,115 @@ extensions/v1beta1
apps/v1
{{- end -}}
{{- end -}}



{{- define "node.kubeletRootPath" }}
{{- if eq .Values.nodeProfileName "windows" }}
{{- .Values.nodeProfile.kubeletRootPath | default "C:/var/lib/kubelet" -}}
{{- else }}
{{- .Values.nodeProfile.kubeletRootPath | default "/var/lib/kubelet" -}}
{{- end }}
{{- end }}



{{- define "node.fluentConfMountPath" }}
{{- if eq .Values.nodeProfileName "windows" }}
{{- .Values.nodeProfile.fluentConfMountPath | default "C:/etc/fluent-conf" -}}
{{- else }}
{{- .Values.nodeProfile.fluentConfMountPath | default "/fluentd/etc" -}}
{{- end }}
{{- end }}


{{- define "node.volumes" }}
- name: fluentconf
emptyDir: {}
{{- if eq .Values.nodeProfileName "windows" }}
- name: var
hostPath:
path: {{ .Values.nodeProfile.varHostPath | default "C:/var" }}
- name: varlibdocker
hostPath:
path: {{ .Values.nodeProfile.varLibDockerContainersHostPath | default "C:/ProgramData/docker" }}
{{- else }}
- name: kubeletroot
hostPath:
path: {{ .Values.nodeProfile.kubeletRootHostPath | default "/var/lib/kubelet" }}
- name: varlog
hostPath:
path: {{ .Values.nodeProfile.varLogHostPath | default "/var/log" }}
- name: varlibdockercontainers
hostPath:
path: {{ .Values.nodeProfile.varLibDockerContainersHostPath | default "/var/lib/docker/containers" }}
{{- end }}
{{- end }}


{{- define "node.fluendVolumeMounts" }}
- name: fluentconf
mountPath: {{ include "node.fluentConfMountPath" . }}
{{- if eq .Values.nodeProfileName "windows" }}
- name: var
mountPath: {{ .Values.nodeProfile.varMountPath | default "C:/var" }}
- name: varlibdocker
mountPath: {{ .Values.nodeProfile.varLibDockerContainersMountPath | default "C:/ProgramData/docker" }}
readOnly: true
{{- else }}
- name: kubeletroot
mountPath: {{ include "node.kubeletRootPath" . }}
readOnly: true
- name: varlog
mountPath: {{ .Values.nodeProfile.varLogMountPath | default "/var/log" }}
- name: varlibdockercontainers
mountPath: {{ .Values.nodeProfile.varLibDockerContainersMountPath | default "/var/lib/docker/containers" }}
readOnly: true
{{- end }}
{{- end }}


{{- define "node.operatorVolumeMounts" }}
- name: fluentconf
{{- if eq .Values.nodeProfileName "windows" }}
mountPath: {{ .Values.nodeProfile.fluentConfMountPath | default "C:/etc/fluent-conf" }}
{{- else }}
mountPath: {{ .Values.nodeProfile.fluentConfMountPath | default "/fluentd/etc" }}
{{- end }}
{{- end }}


{{- define "node.operatorBinary" }}
{{- if eq .Values.nodeProfileName "windows" }}
{{- .Values.nodeProfile.operatorBinary | default "c:/bin/config-reloader.exe" -}}
{{- else }}
{{- .Values.nodeProfile.operatorBinary | default "/bin/config-reloader" -}}
{{- end }}
{{- end }}


{{- define "node.fluentdBinary" }}
{{- if eq .Values.nodeProfileName "windows" }}
{{- .Values.nodeProfile.fluentdBinary | default "fluentd -p /etc/fluent-plugin" -}}
{{- else }}
{{- .Values.nodeProfile.fluentdBinary | default "/usr/local/bundle/bin/fluentd -p /fluentd/plugins" -}}
{{- end }}
{{- end }}

{{- define "node.templatesDir" }}
{{- if eq .Values.nodeProfileName "windows" }}
{{- .Values.nodeProfile.templatesDir | default "C:/templates" -}}
{{- else }}
{{- .Values.nodeProfile.templatesDir | default "/templates" -}}
{{- end }}
{{- end }}

{{- define "node.useSystemd" }}
{{- if .Values.nodeProfile.useSystemd }}
- {{ .Values.nodeProfile.useSystemd }}
{{- else }}
{{- if ne .Values.nodeProfileName "windows" }}
- {{ "--use-systemd" }}
{{- end }}
{{- end }}
{{- end }}
51 changes: 22 additions & 29 deletions charts/log-router/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,7 @@ spec:
containerPort: 24231
{{- end }}
volumeMounts:
- name: fluentconf
mountPath: /fluentd/etc
- name: varlog
mountPath: /var/log
- name: kubeletroot
mountPath: "{{ .Values.kubeletRoot }}"
readOnly: true
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
{{- include "node.fluendVolumeMounts" . | indent 10 }}
{{- if .Values.fluentd.extraVolumeMounts }}
{{ toYaml .Values.fluentd.extraVolumeMounts | indent 10 }}
{{- end }}
Expand All @@ -97,7 +88,7 @@ spec:
{{- end }}
{{- end }}
command:
- /bin/config-reloader
- {{ include "node.operatorBinary" . }}
- --datasource={{ .Values.datasource }}
{{- if .Values.crdMigrationMode }}
- --crd-migration-mode
Expand All @@ -109,17 +100,17 @@ spec:
{{- if not (empty .Values.bufferMountFolder) }}
- --buffer-mount-folder={{ .Values.bufferMountFolder }}
{{- end }}
- --output-dir=/fluentd/etc
- --templates-dir=/templates
- --output-dir={{ include "node.fluentConfMountPath" . }}
- --templates-dir={{ include "node.templatesDir" . }}
- --id={{ template "fluentd-router.fullname" . }}
- --fluentd-binary
{{- if .Values.logRotate.enabled }}
- /usr/local/bundle/bin/fluentd -p /fluentd/plugins --log-rotate-age {{ .Values.logRotate.logRotateAge }} --log-rotate-size {{ .Values.logRotate.logRotateSize | int }}
- {{ include "node.fluentdBinary" . }} --log-rotate-age {{ .Values.logRotate.logRotateAge }} --log-rotate-size {{ .Values.logRotate.logRotateSize | int }}
{{ else }}
- /usr/local/bundle/bin/fluentd -p /fluentd/plugins
- {{ include "node.fluentdBinary" . }}
{{ end }}
- --kubelet-root
- "{{ .Values.kubeletRoot }}"
- {{ include "node.kubeletRootPath" . }}
{{- if .Values.meta.key }}
- --meta-key={{ .Values.meta.key }}
- --meta-values={{- range $k, $v := .Values.meta.values }}{{$k}}={{$v}},
Expand All @@ -143,9 +134,21 @@ spec:
{{- if .Values.adminNamespace }}
- --admin-namespace={{ .Values.adminNamespace }}
{{- end }}
{{- if .Values.fluentdReloadPath }}
- --fluentd-reload-path={{ .Values.fluentdReloadPath }}
{{- end }}
{{- if .Values.execTimeout }}
- --exec-timeout={{ .Values.execTimeout }}
{{- end }}
{{- if .Values.statusAnnotation }}
- --status-annotation={{ .Values.statusAnnotation }}
{{- end }}
{{- if .Values.configmapAnnotation }}
- --annotation={{ .Values.configmapAnnotation }}
{{- end }}
{{ include "node.useSystemd" . | indent 10}}
volumeMounts:
- name: fluentconf
mountPath: /fluentd/etc
{{- include "node.operatorVolumeMounts" . | indent 10 }}
{{- if .Values.reloader.extraVolumeMounts }}
{{ toYaml .Values.reloader.extraVolumeMounts | indent 10 }}
{{- end }}
Expand All @@ -160,17 +163,7 @@ spec:
{{ toYaml .Values.tolerations | indent 8 }}
{{- end}}
volumes:
- name: fluentconf
emptyDir: {}
- name: kubeletroot
hostPath:
path: "{{ .Values.kubeletRoot }}"
- name: varlog
hostPath:
path: /var/log
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
{{- include "node.volumes" . | indent 6 }}
{{- if .Values.extraVolumes }}
{{ toYaml .Values.extraVolumes | indent 6 }}
{{- end }}
Expand Down
5 changes: 4 additions & 1 deletion charts/log-router/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ image:
logLevel: debug
fluentdLogLevel: debug
interval: 45
kubeletRoot: /var/lib/kubelet
# Profile name for operator "linux" or "windows"
nodeProfileName: "linux"
# Profile settings. See templates\_helpers.tpl
nodeProfile: {}
# bufferMountFolder -- a folder inside /var/log to write all fluentd buffers to
bufferMountFolder: ""

Expand Down
4 changes: 3 additions & 1 deletion config-reloader/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright © 2018 VMware, Inc. All Rights Reserved.
# SPDX-License-Identifier: BSD-2-Clause

ARG ARCH=amd64
ARG OS=linux
# builder image
FROM golang:1.16 as builder

Expand All @@ -14,7 +16,7 @@ RUN make in-docker-test
RUN make build VERSION=$VERSION

# always use the un-pushable image
FROM vmware/base-fluentd-operator:latest
FROM vmware/base-fluentd-operator:$ARCH-$OS

COPY templates /templates
COPY validate-from-dir.sh /bin/validate-from-dir.sh
Expand Down
Loading