如何解决像流一样的golang kubectl日志
我正在使用一个自定义的书面http代理,该代理使用kubernetes client-go库来拦截某些kubectl请求并对其进行修改。 一切正常,但kubect日志-f 几乎卡住了。 我正在查看kubectl日志包
func handleLog(client *client.Client,namespace,podID string,logOptions *api.PodLogOptions,out io.Writer) error {
// TODO: transform this into a PodLogOptions call
req := client.RESTClient.Get().
Namespace(namespace).
Name(podID).
Resource("pods").
SubResource("log").
Param("follow",strconv.FormatBool(logOptions.Follow)).
Param("container",logOptions.Container).
Param("previous",strconv.FormatBool(logOptions.Previous)).
Param("timestamps",strconv.FormatBool(logOptions.Timestamps))
if logOptions.SinceSeconds != nil {
req.Param("sinceSeconds",strconv.FormatInt(*logOptions.SinceSeconds,10))
}
if logOptions.SinceTime != nil {
req.Param("sinceTime",logOptions.SinceTime.Format(time.RFC3339))
}
if logOptions.LimitBytes != nil {
req.Param("limitBytes",strconv.FormatInt(*logOptions.LimitBytes,10))
}
if logOptions.TailLines != nil {
req.Param("tailLines",strconv.FormatInt(*logOptions.TailLines,10))
}
readCloser,err := req.Stream()
if err != nil {
return err
}
defer readCloser.Close()
_,err = io.Copy(out,readCloser)
return err
}
目前还不清楚如何使用writer http方法使用写出将json返回kubectl
谢谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。