Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kots]: configure a log collector for ephemeral containers #10679

Merged
merged 2 commits into from
Jun 23, 2022
Merged
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
4 changes: 2 additions & 2 deletions .werft/jobs/build/build-and-publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ function publishKots(werft: Werft, jobConfig: JobConfig) {
{ slice: phases.PUBLISH_KOTS },
);

// Generate the logo
exec(`make logo -C ${REPLICATED_DIR}`, { slice: phases.PUBLISH_KOTS });
// Generate the logo and pull any Helm charts
exec(`make logo helm -C ${REPLICATED_DIR}`, { slice: phases.PUBLISH_KOTS });

// Update the additionalImages in the kots-app.yaml
exec(`/tmp/installer mirror kots --file ${REPLICATED_YAML_DIR}/kots-app.yaml`, { slice: phases.PUBLISH_KOTS });
Expand Down
2 changes: 1 addition & 1 deletion install/kots/BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ packages:
- REPLICATED_APP
config:
commands:
- ["make", "lint"]
- ["make", "helm", "lint"]
10 changes: 8 additions & 2 deletions install/kots/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
CHANNEL_STABLE = Stable
CHANNEL_BETA = Beta
CHANNEL_UNSTABLE = Unstable
CHARTS_DIR = charts
YAML_DIR = manifests

all: logo lint create_dev_release
all: logo helm lint create_dev_release

create_dev_release:
@if [ "${REPLICATED_DEV_CHANNEL}" = "" ]; then \
Expand All @@ -23,6 +24,12 @@ create_unstable_release:
replicated release create --lint --ensure-channel --yaml-dir ${YAML_DIR} --promote ${CHANNEL_UNSTABLE}
.PHONY: create_unstable_release

helm:
@echo "Installing Helm dependencies"
@rm -f ${YAML_DIR}/*.tgz
@for f in $(shell ls -d ${CHARTS_DIR}/*/); do cd $${f} && helm dep up && helm package . --destination ../../${YAML_DIR} && cd -; done
.PHONY: helm

logo:
@echo "Generating Base64 logo and saving to manifests/kots-app.yaml"

Expand All @@ -32,4 +39,3 @@ logo:
lint:
replicated release lint --yaml-dir ${YAML_DIR}
.PHONY: lint

11 changes: 11 additions & 0 deletions install/kots/charts/fluent-bit/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: v2
description: Gitpod fluent-bit
name: fluent-bit
version: 0.20.2
dependencies:
- name: fluent-bit
version: 0.20.2
repository: https://fluent.github.io/helm-charts
84 changes: 84 additions & 0 deletions install/kots/manifests/gitpod-log-collector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: kots.io/v1beta1
kind: HelmChart
metadata:
name: fluent-bit
spec:
chart:
name: fluent-bit
chartVersion: 0.20.2
helmVersion: v3
useHelmInstall: true
weight: 10
values:
fluent-bit:
extraVolumes:
- name: collector
hostPath:
path: /gitpod
type: DirectoryOrCreate

extraVolumeMounts:
- name: collector
mountPath: /gitpod

extraContainers:
- name: kots
image: busybox:1
command:
- sh
- -c
args:
- while true; do echo "waiting" && sleep 60; done
volumeMounts:
- name: collector
mountPath: /gitpod
readOnly: true

labels:
app: gitpod
component: gitpod-log-collector

podLabels:
app: gitpod
component: gitpod-log-collector

# Config requires four space indentations
config:
inputs: |
[INPUT]
Name tail
Path /var/log/containers/*.log
Parser docker
Tag <pod_name>.<container_name>
Tag_Regex (?<pod_name>[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)_(?<namespace_name>[^_]+)_(?<container_name>.+)-
Skip_Long_Lines On

filters: |
[FILTER]
Name stdout

outputs: |
[OUTPUT]
Name file
Match imagebuild*
Mkdir true
Path /gitpod/log-collector
Format plain

[OUTPUT]
Name file
Match installer*
Mkdir true
Path /gitpod/log-collector
Format plain

# Workspaces
[OUTPUT]
Name file
Match ws*.workspace
Mkdir true
Path /gitpod/log-collector
Format plain
3 changes: 3 additions & 0 deletions install/kots/manifests/kots-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ spec:
- deployment/ws-manager-bridge
- deployment/ws-proxy
- service/proxy
additionalImages:
- cr.fluentbit.io/fluent/fluent-bit:1.9.4 # Defined by Fluent Bit Helm chart
- busybox:1 # Used to pull log files to pull from Fluent Bit, which doesn't container tar binary
8 changes: 8 additions & 0 deletions install/kots/manifests/kots-support-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,20 @@ spec:
- clusterInfo: {}
- clusterResources: {}
- logs:
name: logs
selector:
- app=gitpod
namespace: '{{repl Namespace }}'
limits:
maxAge: 720h
maxLines: 10000
- copy:
name: log-collector
selector:
- component=gitpod-log-collector
namespace: '{{repl Namespace }}'
containerPath: /gitpod/log-collector
containerName: kots
- configMap:
selector:
- app=gitpod
Expand Down