Kubernetes API 使用 CURL 进行测试得到 system:anonymous 问题
Kubernetes API testing with CURL getting system:anonymous issue
我试图 运行 curl -v -L --cacert cert.crt --key cert.key -k --request GET "https://*my-k8s-server-ip:port*/api/v1/namespaces/testing/services"
,它向我显示以下错误:
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {
},
"status": "Failure",
"message": "services is forbidden: User \"system:anonymous\" cannot list resource \"services\" in API group \"\" in the namespace \"testing\"",
"reason": "Forbidden",
"details": {
"kind": "services"
},
"code": 403
}* Connection #0 to host *my-k8s-server-ip* left intact
但是当我尝试使用 Postman 提供证书和密钥时,它工作得很好。
请帮忙。
Kubernetes API 服务器在这种情况下无法识别用户,这使得它默认为 system:anonymous
用户。
您需要使用 --cert
参数提供客户端证书,该证书应该在 CNAME 中包含用户(主题:CN)
curl -v -L --cacert cert.crt --key cert.key --cert client.crt -k --request GET "https://*my-k8s-server-ip:port*/api/v1/namespaces/testing/services
"
作为替代方案,您可以使用服务帐户中的令牌作为记录的 BEARER 令牌 here
我试图 运行 curl -v -L --cacert cert.crt --key cert.key -k --request GET "https://*my-k8s-server-ip:port*/api/v1/namespaces/testing/services"
,它向我显示以下错误:
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {
},
"status": "Failure",
"message": "services is forbidden: User \"system:anonymous\" cannot list resource \"services\" in API group \"\" in the namespace \"testing\"",
"reason": "Forbidden",
"details": {
"kind": "services"
},
"code": 403
}* Connection #0 to host *my-k8s-server-ip* left intact
但是当我尝试使用 Postman 提供证书和密钥时,它工作得很好。 请帮忙。
Kubernetes API 服务器在这种情况下无法识别用户,这使得它默认为 system:anonymous
用户。
您需要使用 --cert
参数提供客户端证书,该证书应该在 CNAME 中包含用户(主题:CN)
curl -v -L --cacert cert.crt --key cert.key --cert client.crt -k --request GET "https://*my-k8s-server-ip:port*/api/v1/namespaces/testing/services
"
作为替代方案,您可以使用服务帐户中的令牌作为记录的 BEARER 令牌 here