我试图在 Kubernetes 中访问我的自定义资源定义端点,但找不到 Kubernetes 如何在 Kubernetes API 中公开我的自定义资源定义的确切示例。如果我用这个点击自定义服务 API:
https://localhost:6443/apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions
我收到了这个回复
"items": [
{
"metadata": {
"name": "accounts.stable.ibm.com",
"selfLink": "/apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/accounts.stable.ibm.com",
"uid": "eda9d695-d3d4-11e9-900f-025000000001",
"resourceVersion": "167252",
"generation": 1,
"creationTimestamp": "2019-09-10T14:11:48Z",
"deletionTimestamp": "2019-09-12T22:26:20Z",
"finalizers": [
"customresourcecleanup.apiextensions.k8s.io"
]
},
"spec": {
"group": "stable.ibm.com",
"version": "v1",
"names": {
"plural": "accounts",
"singular": "account",
"shortNames": [
"acc"
],
"kind": "Account",
"listKind": "AccountList"
},
"scope": "Namespaced",
"versions": [
{
"name": "v1",
"served": true,
"storage": true
}
],
"conversion": {
"strategy": "None"
}
},
"status": {
"conditions": [
{
"type": "NamesAccepted",
"status": "True",
"lastTransitionTime": "2019-09-10T14:11:48Z",
"reason": "NoConflicts",
"message": "no conflicts found"
},
{
"type": "Established",
"status": "True",
"lastTransitionTime": null,
"reason": "InitialNamesAccepted",
"message": "the initial names have been accepted"
},
{
"type": "Terminating",
"status": "True",
"lastTransitionTime": "2019-09-12T22:26:20Z",
"reason": "InstanceDeletionCheck",
"message": "could not confirm zero CustomResources remaining: timed out waiting for the condition"
}
],
"acceptedNames": {
"plural": "accounts",
"singular": "account",
"shortNames": [
"acc"
],
"kind": "Account",
"listKind": "AccountList"
},
"storedVersions": [
"v1"
]
}
}
]
}
这让我相信我已经正确地创建了自定义资源帐户。有许多示例似乎不太正确,我在 Kubernetes REST api 中找不到我的资源。我可以使用来自kubectl的自定义资源,但我需要使用 RESTful API 公开它。
https://localhost:6443/apis/stable.example.com/v1/namespaces/default/accounts
返回
404 page not found
然而:
https://localhost:6443/apis/apiextensions.k8s.io/v1beta1/apis/stable.ibm.com/namespaces/default/accounts
返回
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "the server could not find the requested resource",
"reason": "NotFound",
"details": {},
"code": 404
}
我查看了https://docs.okd.io/latest/admin_guide/custom_resource_definitions.html和https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/
确切的 URL 将不胜感激。