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

kubeadm uses and configures kube-log-runner #124359

Closed
system51 opened this issue Apr 18, 2024 · 8 comments
Closed

kubeadm uses and configures kube-log-runner #124359

system51 opened this issue Apr 18, 2024 · 8 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. kind/support Categorizes issue or PR as a support question. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@system51
Copy link

What happened?

klog command line flags are deprecated starting with Kubernetes v1.23 and removed in Kubernetes v1.26,I hope to use kube-log-runner to configure log output to a specified file,I deploy using kubeadm

What did you expect to happen?

I deploy using kubeadm,I hope to use kube-log-runner to configure log output to a specified file。How should I edit the kube-apiserver.yaml file

/apps/k8s/bin/kube-log-runner -log-file=/apps/k8s/log/kube-apiserver.log --also-stdout=false /apps/k8s/bin/kube-apiserver $KUBE_APISERVER_OPTS

How can we reproduce it (as minimally and precisely as possible)?

Deploy kubernetes using kubeadm

Anything else we need to know?

No response

Kubernetes version

kubeadm version: &version.Info{Major:"1", Minor:"29", GitVersion:"v1.29.2", GitCommit:"4b8e819355d791d96b7e9d9efe4cbafae2311c88", GitTreeState:"clean", BuildDate:"2024-02-14T10:39:04Z", GoVersion:"go1.21.7", Compiler:"gc", Platform:"linux/amd64"}

Cloud provider

nothing

OS version

NAME="Rocky Linux"
VERSION="8.7 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.7"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.7 (Green Obsidian)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:8:GA"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-8"
ROCKY_SUPPORT_PRODUCT_VERSION="8.7"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.7"
[root@k8s-master-01 manifests]# uname -rn
k8s-master-01 6.7.6-1.el8.elrepo.x86_64

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, ...) and versions (if applicable)

@system51 system51 added the kind/bug Categorizes issue or PR as related to a bug. label Apr 18, 2024
@k8s-ci-robot k8s-ci-robot added needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 18, 2024
@neolit123
Copy link
Member

neolit123 commented Apr 18, 2024

@k8s-ci-robot k8s-ci-robot added sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 18, 2024
@neolit123
Copy link
Member

neolit123 commented Apr 18, 2024

/kind support

@k8s-ci-robot k8s-ci-robot added the kind/support Categorizes issue or PR as a support question. label Apr 18, 2024
@logicalhan
Copy link
Member

/triage accepted
/assign @serathius

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 18, 2024
@system51
Copy link
Author

system51 commented Apr 19, 2024

I have found the solution, but I have a question why not integrate kube-log-runner into the kubernetes base image, such as kube-apiserver, kube-controller-manager, etc. The following is the correct configuration

spec:
  containers:
  - command:
    - /apps/kube-log-runner
    - --log-file=/apps/k8s/log/kube-apiserver.log
    - --also-stdout=false
    - kube-apiserver
    - --advertise-address=10.168.137.26
    - --allow-privileged=true
    - --authorization-mode=Node,RBAC
    - --client-ca-file=/etc/kubernetes/pki/ca.crt
    - --enable-admission-plugins=NodeRestriction
……
    volumeMounts:
    - mountPath: /apps/kube-log-runner
      name: kube-log-runner
    - mountPath: /apps/k8s/log
      name: k8s-logs
  volumes:
  - hostPath:
      path: /root/kube-log-runner
      type: File
    name: kube-log-runner
  - hostPath:
      path: /var/log/kubernetes/kube-apiserver
      type: DirectoryOrCreate
    name: k8s-logs

@mengjiao-liu
Copy link
Member

mengjiao-liu commented Apr 19, 2024

but I have a question why not integrate kube-log-runner into the kubernetes base image

In fact, the kubernetes base image already integrates the kube-log-runner binary.

The Kubernetes registry.k8s.io/build-image/go-runner image wraps the gcr.io/distroless/static image and provides kube-log-runner under its traditional name as /go-runner. It gets maintained in https://github.com/kubernetes/release/tree/master/images/build/go-runner.

see details for https://github.com/kubernetes/component-base/tree/master/logs/kube-log-runner#container-base-image

Maybe @pohly @dims know more context?

@system51 You can use the go-runner(i.e. kube-log-runner) command directly without having to mount it:

Here is the manifest:

spec:
  containers:
  - command:
    - /go-runner
    - --log-file=/var/log/kube-apiserver.log
    - --also-stdout=false
    - --redirect-stderr=true
    - kube-apiserver
    - --advertise-address=10.6.9.1
    - --allow-privileged=true
    - --authorization-mode=Node,RBAC
    - --client-ca-file=/etc/kubernetes/pki/ca.crt
    - --enable-admission-plugins=NodeRestriction
    - mountPath: /var/log/kube-apiserver.log
      name: logfile
      readOnly: false
  volumes:
  - hostPath:
      path: /var/log/kube-apiserver.log
      type: FileOrCreate
    name: logfile

@system51
Copy link
Author

@mengjiao-liu Thank you very much for your solution, it works after I tried it。

@serathius serathius removed their assignment Apr 19, 2024
@pohly
Copy link
Contributor

pohly commented Apr 19, 2024

Seems to be resolved? Reopen if not...

/close

@k8s-ci-robot
Copy link
Contributor

@pohly: Closing this issue.

In response to this:

Seems to be resolved? Reopen if not...

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. kind/support Categorizes issue or PR as a support question. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests

7 participants