Open
Description
Please provide an in-depth description of the question you have:
Guided by the blog: https://karmada.io/docs/tutorials/karmada-search/, i want to get pod from the true K8s.
What i did:
- Install karmada-search with default configs by helm chart
- Init a clientSet by default config
restConfig, err := config.ClientConfig()
if err != nil {
return err
}
restConfig = metadata.ConfigFor(restConfig)
clientSet, err := kubernetes.NewForConfig(restConfig)
if err != nil {
return err
}
- Exec a command like below
pod, err := kubeClientset.CoreV1().Pods(namespace).Get(ctx, podName, metav1.GetOptions{})
- Error log printed in kramada-search
E0214 08:14:12.024022 1 writers.go:122] "Unhandled Error" err="apiserver was unable to write a JSON response: object *unstructured.Unstructured does not implement the protobuf marshalling interface and cannot be encoded to a protobuf message"
If i specify the restConfig of the clientSet like this: restConfig.AcceptContentTypes = "application/json"
, the problem is gone.
The default AcceptContentTypes is like this:
// ConfigFor returns a copy of the provided config with the
// appropriate metadata client defaults set.
func ConfigFor(inConfig *rest.Config) *rest.Config {
config := rest.CopyConfig(inConfig)
config.AcceptContentTypes = "application/vnd.kubernetes.protobuf,application/json"
config.ContentType = "application/vnd.kubernetes.protobuf"
config.NegotiatedSerializer = metainternalversionscheme.Codecs.WithoutConversion()
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()
}
return config
}
What do you think about this question?:
Environment:
- Karmada version: 1.12.3
- Kubernetes version: 1.19.3
- Others: Installed by helm chart, with all default configs
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status