'K8s client is returning page not found when trying to creae custom namespace object
I have used following json for custom namespace object in kubernetes.
const azureIdentityJson = {
'apiVersion': 'aadpodidentity.k8s.io/v1',
'kind': 'AzureIdentity',
'metadata': {
'name': identityName,
'namespace': namespace,
'annotations': {
'aadpodidentity.k8s.io/Behavior': 'namespaced'
}
},
'spec': {
'type': 0,
'resourceID': managedIdentityId,
'clientID': managedIdentityClientId
}
};
await k8sClient.createCustomObject('aadpodidentity.k8s.io', 'v1', 'azureidentities', azureIdentityJson);
and createCustomObject function is as follows.
public async createCustomObject (customTypeName: string, customVersion: string, plural: string, customObjectManifest: any): Promise<any> {
const client = this.kubeConfig.makeApiClient(k8s.CustomObjectsApi);
return new Promise<string>((resolve, reject) => {
client.createNamespacedCustomObject(customTypeName, customVersion, customObjectManifest.metadata.namespace ? customObjectManifest.metadata.namespace : 'default', plural, customObjectManifest).then(
(response) => {
resolve(response);
},
(err) => {
reject(err.response && err.response.body ? err.response.body : err);
},
);
});
}
when executing, getting 404, page not found error. No other information were there. It was working fine earlier. Please help here. Stuck almost a month now.
Thanks in advance
Solution 1:[1]
CustomResources store structured data in custom fields likebuilt-in fields apiVersion, kind and metadata, which are explicitly validated by the api.There might be issue among one of these.
Try to upgrade Aks version or node js version.
custom resource objects must sometimes be converted between the version they are stored at and the version they are served at. If the conversion involves schema changes and requires custom logic, a conversion webhook should be used. If there are no schema changes, the default None conversion strategy may be used and only the apiVersion field will be modified when serving different versions.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | kavyasaraboju-MT |
