简体   繁体   English

Kubernetes REST API - 未经授权

[英]Kubernetes REST API - Unauthorized

I have following Kubernetes REST API request我有以下 Kubernetes REST API 请求

GET https://theserver/api/v1/pods?includeUninitialized=true

and included following HTTP Headers in the request:并在请求中包含以下 HTTP 标头:

Authorization: Basic ***************
Accept: application/json, */*
User-Agent: kubectl.exe/v1.13.0 (windows/amd64) kubernetes/ddf47ac

Result is the following error结果是以下错误

{
    "kind": "Status",
    "apiVersion": "v1",
    "metadata": {},
    "status": "Failure",
    "message": "Unauthorized",
    "reason": "Unauthorized",
    "code": 401
}

I already tried the following:我已经尝试了以下方法:

  • Analog kubectl request "kubectl describe pods --all-namespaces" works fine (but I need REST)模拟 kubectl 请求“kubectl describe pods --all-namespaces”工作正常(但我需要 REST)
  • Used "--v=12" parameter as in newkind101's comment to Kubernetes REST API to see the underlying REST API calls - looks same as mine在 newkind101 对Kubernetes REST API的评论中使用“--v=12”参数来查看底层 REST API 调用 - 看起来和我的一样
  • Read Kubernetes Documentation - but I failed to find detail information which HTTP headers or/and HTTP body values to send to authenticate properly (few thing I could retrieve from curl sample calls in that docs)阅读 Kubernetes 文档 - 但我未能找到详细信息,哪些 HTTP 标头或/和 HTTP 正文值要发送以正确进行身份验证(我几乎无法从该文档中的 curl 示例调用中检索到)
  • I read Access Kubernetes API using REST APIs but want to understand my issue before I use a framework like GoDaddy使用 REST API阅读了Access Kubernetes API,但想在使用像 GoDaddy 这样的框架之前了解我的问题

kubectl seems to do a bit more than I can see with the "--v=12" parameter. kubectl 似乎比我用“--v=12”参数看到的要多一些。 This bit is likely connected to things in ".kube/config" file.此位可能与“.kube/config”文件中的内容有关。 Still I don't know what exactly and where to put in my HTTP request.我仍然不知道在我的 HTTP 请求中到底放什么和放在哪里。

据我所知,默认情况下基本身份验证方法是禁用的,需要通过在 API 服务器配置中添加--basic-auth-file标志来启用,因此对 REST API 的所有请求都被标识为匿名用户,可能会导致401 Unauthorized错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM