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

JsonMappingException: No resource type found for:xxx #6752

Open
ningyougang opened this issue Dec 27, 2024 · 3 comments
Open

JsonMappingException: No resource type found for:xxx #6752

ningyougang opened this issue Dec 27, 2024 · 3 comments

Comments

@ningyougang
Copy link

ningyougang commented Dec 27, 2024

When load k8s configuration by below codes

public KubernetesClient getObject() throws Exception {
    return new DefaultKubernetesClient();
}  

// finally invoke below codes(transfer content to k8s Config)
public static Config parseConfigFromString(String contents) throws IOException {
   ObjectMapper mapper = Serialization.yamlMapper();
   // below is jackjson method
   return mapper.readValue(contents, Config.class);  <----------this line throws below exception
}  

exception info:

com.fasterxml.jackson.databind.JsonMappingException: No resource type found for:xxx.xxx.com/v1beta1#ClusterMetadata
at [Source: java.io.StringReader@43de88f3; line: 16, column: 7] (through reference chain: io.fabric8.kubernetes.api.model.Config["clusters"]->java.util.ArrayList[0]->io.fabric8.kubernetes.api.model.NamedCluster["cluster"]->io.fabric8.kubernetes.api.model.Cluster["extensions"]->java.util.ArrayList[0]->io.fabric8.kubernetes.api.model.NamedExtension["extension"])

Below is the example of the k8s config located in ~/.kube/config

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: xxx
    ################ below part is new added(begin)
    extensions:
    - extension:
        DetailAPI: https://xxx.xxx.com/#/promote/detail?corporateName=xxx&containerSeq=
        ImageResultAPI: ""
        Profile: real
        PromoteAPI: https://xxx.xxx.xxx.com/api/docker/info
        Type: default
        apiVersion: xxx.xxx.com/v1beta1
        kind: ClusterMetadata
        metadata:
          creationTimestamp: null
      name: metadata
     ################ above part is new added(end) 
    server: https://xx.xxx.xxx.com:6443
  name: name1
contexts:
- context:
    cluster: name1
    user: name1
  name: name1
current-context: xxx@xxx
kind: Config
preferences: {}
users:
- name: name1
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1beta1
      args:
      - login
      command: C:\Users\Administrator\Downloads\xxx.exe
      env:
      - name: XXX_ENDPOINT
        value: https://xxx.xxx.com:5000/v3
      - name: XXX_DOMAIN_ID
        value: default

Btw, if i removed below content

    ################ below part is new added(begin)
    extensions:
    - extension:
        DetailAPI: https://xxx.xxx.com/#/promote/detail?corporateName=xxx&containerSeq=
        ImageResultAPI: ""
        Profile: real
        PromoteAPI: https://xxx.xxx.xxx.com/api/docker/info
        Type: default
        apiVersion: xxx.xxx.com/v1beta1
        kind: ClusterMetadata
        metadata:
          creationTimestamp: null
      name: metadata
     ################ above part is new added(end) 

Can load k8s configuration successfully using jackjson.

@manusa
Copy link
Member

manusa commented Dec 27, 2024

What version of the client are you using?

@ningyougang
Copy link
Author

@manusa

io.fabric8:kubernetes-client:4.12.0

I checked other client(5.0.0), seems issue still exist.

@manusa
Copy link
Member

manusa commented Dec 27, 2024

Please try one of the latest major versions, 6.13.4 or 7.0.1.
Both versions you've used are extremely old.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants