Merge pull request #102039 from serathius/protobuff
Enable protocol-buffers by default
This commit is contained in:
		| @@ -27,7 +27,6 @@ import ( | ||||
| 	"k8s.io/cli-runtime/pkg/genericclioptions" | ||||
| 	"k8s.io/client-go/discovery" | ||||
| 	corev1client "k8s.io/client-go/kubernetes/typed/core/v1" | ||||
| 	"k8s.io/klog/v2" | ||||
| 	cmdutil "k8s.io/kubectl/pkg/cmd/util" | ||||
| 	"k8s.io/kubectl/pkg/metricsutil" | ||||
| 	"k8s.io/kubectl/pkg/util/i18n" | ||||
| @@ -71,6 +70,7 @@ func NewCmdTopNode(f cmdutil.Factory, o *TopNodeOptions, streams genericclioptio | ||||
| 	if o == nil { | ||||
| 		o = &TopNodeOptions{ | ||||
| 			IOStreams:          streams, | ||||
| 			UseProtocolBuffers: true, | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -90,7 +90,7 @@ func NewCmdTopNode(f cmdutil.Factory, o *TopNodeOptions, streams genericclioptio | ||||
| 	cmd.Flags().StringVarP(&o.Selector, "selector", "l", o.Selector, "Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)") | ||||
| 	cmd.Flags().StringVar(&o.SortBy, "sort-by", o.SortBy, "If non-empty, sort nodes list using specified field. The field can be either 'cpu' or 'memory'.") | ||||
| 	cmd.Flags().BoolVar(&o.NoHeaders, "no-headers", o.NoHeaders, "If present, print output without headers") | ||||
| 	cmd.Flags().BoolVar(&o.UseProtocolBuffers, "use-protocol-buffers", o.UseProtocolBuffers, "If present, protocol-buffers will be used to request metrics.") | ||||
| 	cmd.Flags().BoolVar(&o.UseProtocolBuffers, "use-protocol-buffers", o.UseProtocolBuffers, "Enables using protocol-buffers to access Metrics API.") | ||||
|  | ||||
| 	return cmd | ||||
| } | ||||
| @@ -115,8 +115,6 @@ func (o *TopNodeOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [] | ||||
| 	} | ||||
| 	if o.UseProtocolBuffers { | ||||
| 		config.ContentType = "application/vnd.kubernetes.protobuf" | ||||
| 	} else { | ||||
| 		klog.Warning("Using json format to get metrics. Next release will switch to protocol-buffers, switch early by passing --use-protocol-buffers flag") | ||||
| 	} | ||||
| 	o.MetricsClient, err = metricsclientset.NewForConfig(config) | ||||
| 	if err != nil { | ||||
|   | ||||
| @@ -87,6 +87,7 @@ func NewCmdTopPod(f cmdutil.Factory, o *TopPodOptions, streams genericclioptions | ||||
| 	if o == nil { | ||||
| 		o = &TopPodOptions{ | ||||
| 			IOStreams:          streams, | ||||
| 			UseProtocolBuffers: true, | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -108,7 +109,7 @@ func NewCmdTopPod(f cmdutil.Factory, o *TopPodOptions, streams genericclioptions | ||||
| 	cmd.Flags().BoolVar(&o.PrintContainers, "containers", o.PrintContainers, "If present, print usage of containers within a pod.") | ||||
| 	cmd.Flags().BoolVarP(&o.AllNamespaces, "all-namespaces", "A", o.AllNamespaces, "If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.") | ||||
| 	cmd.Flags().BoolVar(&o.NoHeaders, "no-headers", o.NoHeaders, "If present, print output without headers.") | ||||
| 	cmd.Flags().BoolVar(&o.UseProtocolBuffers, "use-protocol-buffers", o.UseProtocolBuffers, "If present, protocol-buffers will be used to request metrics.") | ||||
| 	cmd.Flags().BoolVar(&o.UseProtocolBuffers, "use-protocol-buffers", o.UseProtocolBuffers, "Enables using protocol-buffers to access Metrics API.") | ||||
| 	return cmd | ||||
| } | ||||
|  | ||||
| @@ -136,8 +137,6 @@ func (o *TopPodOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []s | ||||
| 	} | ||||
| 	if o.UseProtocolBuffers { | ||||
| 		config.ContentType = "application/vnd.kubernetes.protobuf" | ||||
| 	} else { | ||||
| 		klog.Warning("Using json format to get metrics. Next release will switch to protocol-buffers, switch early by passing --use-protocol-buffers flag") | ||||
| 	} | ||||
| 	o.MetricsClient, err = metricsclientset.NewForConfig(config) | ||||
| 	if err != nil { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot