Skip to content

Commit

Permalink
Add setup for S3 compatible log forwarding in Results
Browse files Browse the repository at this point in the history
  • Loading branch information
khrm committed Nov 11, 2024
1 parent d888aa4 commit 9e48acf
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/e2e/02-logs-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
# Copyright 2020 The Tekton Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# shellcheck disable=SC2181 # To ignore long command exit code check

set -e

ROOT="$(git rev-parse --show-toplevel)"

curl https://dl.min.io/client/mc/release/linux-amd64/mc \
--create-dirs \
-o $HOME/minio-binaries/mc

chmod +x $HOME/minio-binaries/mc
export PATH=$PATH:$HOME/minio-binaries/

mc alias set myPlayMinio https://play.min.io:9000 Q3AM3UQ867SPQQA43P2F zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG

mc mb myPlayMinio/tekton-logs

helm upgrade --install vector vector/vector --namespace logging --values ${ROOT}/test/e2e/blob-logs/vector-s3.yaml

kubectl apply -f ${ROOT}/test/e2e/blob-logs/vector-minio-config.yaml
kubectl delete pod $(kubectl get pod -o=name -n tekton-pipelines | grep tekton-results-api | sed "s/^.\{4\}//") -n tekton-pipelines
kubectl wait deployment "tekton-results-api" --namespace="tekton-pipelines" --for="condition=available" --timeout="120s"
kubectl delete pod $(kubectl get pod -o=name -n tekton-pipelines | grep tekton-results-watcher | sed "s/^.\{4\}//") -n tekton-pipelines
kubectl wait deployment "tekton-results-watcher" --namespace="tekton-pipelines" --for="condition=available" --timeout="120s"
69 changes: 69 additions & 0 deletions test/e2e/blob-logs/vector-minio-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright 2023 The Tekton Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# quay.io/khrm/gcse-emulator:latest is image for
# https://github.com/fullstorydev/emulators/tree/master/storage
# There's no official image for STORAGE EMULATORS.
apiVersion: v1
data:
config: |
DB_USER=
DB_PASSWORD=
DB_HOST=tekton-results-postgres-service.tekton-pipelines.svc.cluster.local
DB_PORT=5432
DB_NAME=tekton-results
DB_SSLMODE=disable
DB_SSLROOTCERT=
DB_ENABLE_AUTO_MIGRATION=true
DB_MAX_IDLE_CONNECTIONS=10
DB_MAX_OPEN_CONNECTIONS=10
GRPC_WORKER_POOL=2
K8S_QPS=5
K8S_BURST=10
PROFILING=false
PROFILING_PORT=6060
SERVER_PORT=8080
PROMETHEUS_PORT=9090
PROMETHEUS_HISTOGRAM=false
TLS_PATH=/etc/tls
AUTH_DISABLE=true
AUTH_IMPERSONATE=true
LOG_LEVEL=debug
LOGS_API=true
LOGS_TYPE=blob
LOGS_BUFFER_SIZE=32768
LOGS_PATH=/logs
GCS_BUCKET_NAME=
STORAGE_EMULATOR_HOST=
CONVERTER_ENABLE=false
CONVERTER_DB_LIMIT=50
MAX_RETENTION=
LOGGING_PLUGIN_PROXY_PATH=/api/logs/v1/application
LOGGING_PLUGIN_TOKEN_PATH=/var/run/secrets/kubernetes.io/serviceaccount/token
LOGGING_PLUGIN_NAMESPACE_KEY=kubernetes_namespace_name
LOGGING_PLUGIN_STATIC_LABELS='log_type=application'
LOGGING_PLUGIN_CA_CERT=
LOGGING_PLUGIN_QUERY_LIMIT=1700
LOGGING_PLUGIN_TLS_VERIFICATION_DISABLE=
LOGGING_PLUGIN_FORWARDER_DELAY_DURATION=10
LOGGING_PLUGIN_API_URL=s3://tekton-logs
LOGGING_PLUGIN_QUERY_PARAMS='v1alpha2LogType=true&use_path_style=true'
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/part-of: tekton-results
app.kubernetes.io/version: devel
name: tekton-results-api-config
namespace: tekton-pipelines
59 changes: 59 additions & 0 deletions test/e2e/blob-logs/vector-s3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
role: Agent
customConfig:
data_dir: /vector-data-dir
api:
enabled: true
address: 127.0.0.1:8686
playground: false
sources:
kubernetes_logs:
type: kubernetes_logs
extra_label_selector: "app.kubernetes.io/managed-by=tekton-pipelines"
internal_metrics:
type: internal_metrics
transforms:
remap_app_logs:
type: remap
inputs: [kubernetes_logs]
source: |-
.log_type = "application"
.kubernetes_namespace_name = .kubernetes.pod_namespace
if exists(.kubernetes.pod_labels."tekton.dev/taskRunUID") {
.taskRunUID = del(.kubernetes.pod_labels."tekton.dev/taskRunUID")
} else {
.taskRunUID = "none"
}
if exists(.kubernetes.pod_labels."tekton.dev/pipelineRunUID") {
.pipelineRunUID = del(.kubernetes.pod_labels."tekton.dev/pipelineRunUID")
.result = .pipelineRunUID
} else {
.result = .taskRunUID
}
if exists(.kubernetes.pod_labels."tekton.dev/task") {
.task = del(.kubernetes.pod_labels."tekton.dev/task")
} else {
.task = "none"
}
if exists(.kubernetes.pod_namespace) {
.namespace = del(.kubernetes.pod_namespace)
} else {
.namespace = "unlabeled"
}
.pod = .kubernetes.pod_name
.container = .kubernetes.container_name
sinks:
aws_s3:
type: "aws_s3"
bucket: "tekton-logs"
inputs: ["remap_app_logs"]
auth:
access_key_id: "Q3AM3UQ867SPQQA43P2F"
secret_access_key: "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
compression: "none"
region: "us-east-1"
endpoint: "https://play.min.io:9000"
encoding:
codec: "text"
key_prefix: "/logs/{{ `{{ .namespace }}` }}/{{`{{ .result }}`}}/{{`{{ .taskRunUID }}`}}/{{`{{ .container }}`}}"
filename_time_format: ""
filename_append_uuid: false

0 comments on commit 9e48acf

Please sign in to comment.