ray-project / kuberay

A toolkit to run Ray applications on Kubernetes
Apache License 2.0
1.17k stars 373 forks source link

Use a default user agent 'kuberay-operator' instead of the default user-agent from controller-runtime #1982

Closed andrewsykim closed 6 months ago

andrewsykim commented 6 months ago

Why are these changes needed?

We are currently using the default controller-runtime user-agent which is manager/v0.0.0. This PR updates Kuberay's user-agent to kuberay-operator.

Note that it does not include the version of kuberay yet, but we should add that in a follow-up PR. Here's example HTTP log from apiserver that shows the new user-agent being used:

I0311 02:35:26.041556       1 httplog.go:131] "HTTP" verb="PUT" URI="/apis/ray.io/v1/namespaces/default/rayservices/rayservice-sample/status" latency="10.397049ms" userAgent="kuberay-operator" audit-ID="8b543d30-4d26-4e0f-96ff-7b2596d0ecb8" srcIP="10.244.0.3:54042" apf_pl="workload-low" apf_fs="service-accounts" apf_iseats=1 apf_fseats=0 apf_execution_time="8.0205ms" resp=200

Related issue number

Checks

andrewsykim commented 6 months ago

@kevin85421 PTAL

andrewsykim commented 6 months ago

Would you mind sharing more details on why we need this change? I don't have the related context. Thanks!

It's mainly for auditing HTTP traffic in kube-apiserver. If we use the default user-agent from controller-runtime (manager/v0.0.0), it will be hard to distinguish kuberay traffic from other clients that also use controller-runtime. Changing this to ray-operator will make it easy to filter out HTTP logs that came from kuberay

andrewsykim commented 6 months ago

How do I manually test this PR? I checked the apiserver logs in my local Kind cluster by running kubectl logs -n kube-system kube-apiserver-kind-control-plane, but I didn't find any log message similar to [...httplog.go:131] "HTTP" verb="PUT" .....

You need to increase log verbosity to see the HTTP logs.

Here's the kind cluster config I used:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  kubeadmConfigPatches:
  - |
    kind: ClusterConfiguration
    apiServer:
        extraArgs:
          v: "4"
kevin85421 commented 6 months ago

cc @Yicheng-Lu-llll would you mind reviewing this PR? Thanks!

Yicheng-Lu-llll commented 6 months ago

lgtm! I can reproduce it.

image