I have a factory-default installation of K3S on Ubuntu 22.04 (VM)
Environmental Info:
K3s Version:
k3s version v1.25.5+k3s2 (de654222)
go version go1.19.4
rancher/mirrored-library-traefik:2.9.4
Node(s) CPU architecture, OS, and Version:
Linux server 5.15.0-57-generic #63-Ubuntu SMP Thu Nov 24 13:43:17 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
VM running on Multipass/Windows 10 Pro
Cluster Configuration:
Single node installation with:
curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" sh -
Describe the bug:
I edited /var/lib/rancher/k3s/server/manifests/traefik-config.yaml as recommended by k3s docs (see Helm | K3s) in order to change the default configuration of traefik, to enable the access log and keep/drop some fields and headers, using the common format, it works but some fields/headers are being ignored.
Steps To Reproduce:
- sudo nano /var/lib/rancher/k3s/server/manifests/traefik-config.yaml
apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
name: traefik
namespace: kube-system
spec:
valuesContent: |-
logs:
access:
enabled: true
fields:
general:
defaultmode: keep
names:
StartUTC: drop
StartLocal: keep
RouterName: drop
ServiceURL: drop
RequestCount: drop
OriginDuration: keep
ClientUsername: drop
headers:
defaultmode: keep
names:
Cookie: keep
User-Agent: drop
Referer: drop
I am using these traefik references:
Values YAML
Access Logs reference
Expected behavior:
All fields and headers with "keep" value should be printed in log record, and those with "drop" value should not be printed.
Actual behavior:
The configuration partially works:
Cookie header is not printed in log record.
StartLocal and OriginDuration fields are not printed in log record.
StartUTC is not being dropped, still printed.
This is a sample of the access logs obtained via kubectl:
kubectl logs -n kube-system $(kubectl get pod -n kube-system -o name | grep "^pod/traefik")
10.42.0.1 - - [27/Jan/2023:04:01:49 +0000] "POST /ms/login HTTP/2.0" 200 61 "-" "-" - "-" "-" 5ms
10.42.0.1 - - [27/Jan/2023:04:01:49 +0000] "GET /demo/menu.html HTTP/2.0" 200 1005 "-" "-" - "-" "-" 0ms
10.42.0.1 - - [27/Jan/2023:04:01:52 +0000] "GET /demo/products.html HTTP/2.0" 200 1923 "-" "-" - "-" "-" 1ms
10.42.0.1 - - [27/Jan/2023:04:01:52 +0000] "GET /ms/products/view HTTP/2.0" 200 11520 "-" "-" - "-" "-" 3ms
10.42.0.1 - - [27/Jan/2023:04:01:54 +0000] "GET /ping HTTP/1.1" 200 2 "-" "-" - "-" "-" 0ms
10.42.0.1 - - [27/Jan/2023:04:01:54 +0000] "GET /ping HTTP/1.1" 200 2 "-" "-" - "-" "-" 0ms
10.42.0.1 - - [27/Jan/2023:04:01:54 +0000] "GET /demo/menu.html HTTP/2.0" 200 1005 "-" "-" - "-" "-" 0ms
10.42.0.1 - - [27/Jan/2023:04:01:55 +0000] "GET /demo/shippers.html HTTP/2.0" 200 1612 "-" "-" - "-" "-" 0ms
10.42.0.1 - - [27/Jan/2023:04:01:55 +0000] "GET /ms/shippers/view HTTP/2.0" 200 456 "-" "-" - "-" "-" 2ms
10.42.0.1 - - [27/Jan/2023:04:01:56 +0000] "GET /demo/menu.html HTTP/2.0" 200 1005 "-" "-" - "-" "-" 1ms
10.42.0.1 - - [27/Jan/2023:04:01:57 +0000] "GET /demo/categ.html HTTP/2.0" 200 2332 "-" "-" - "-" "-" 0ms
10.42.0.1 - - [27/Jan/2023:04:01:57 +0000] "GET /ms/categ/view HTTP/2.0" 200 308 "-" "-" - "-" "-" 2ms
10.42.0.1 - - [27/Jan/2023:04:01:59 +0000] "GET /ms/categ/get?categ_id=49 HTTP/2.0" 200 58 "-" "-" - "-" "-" 3ms
10.42.0.1 - - [27/Jan/2023:04:01:59 +0000] "POST /ms/categ/update HTTP/2.0" 200 16 "-" "-" - "-" "-" 2ms
10.42.0.1 - - [27/Jan/2023:04:01:59 +0000] "GET /ms/categ/view HTTP/2.0" 200 308 "-" "-" - "-" "-" 1ms
10.42.0.1 - - [27/Jan/2023:04:02:01 +0000] "GET /ms/logout HTTP/2.0" 200 16 "-" "-" - "-" "-" 1ms
10.42.0.1 - - [27/Jan/2023:04:02:01 +0000] "GET /demo/index.html HTTP/2.0" 200 2314 "-" "-" - "-" "-" 1ms
Thank you.