gpt4 book ai didi

kubernetes - kube-apiserver身份验证(未授权)

转载 作者:行者123 更新时间:2023-12-02 11:44:43 25 4
gpt4 key购买 nike

我创建了用户teamcity,以便能够使用 kube-apiserver

kubectl create serviceaccount teamcity



使用下面的命令,我得到 secret 名称

kubectl get accourcissements teamcity -o yaml



为了找到我使用的最后一个命令生成的 token

kubectl get secret teamcity-token-lmr6z -o yaml



当我尝试通过curl连接时出现错误,我不知道我的错误在哪里:(
 curl -v -Sskk -H "Authorization: bearer ZXlKaGJH......wWHNIVzZ3" https://10.109.0.88:6443/api/v1/namespaces

HTTP/1.1 401 Unauthorized
Content-Type: application/json
Date: Thu, 05 Jul 2018 13:14:00 GMT
Content-Length: 165

{
"kind": "Status",
"apiVersion": "v1",
"metadata": {

},
"status": "Failure",
"message": "Unauthorized",
"reason": "Unauthorized",
"code": 401
* Connection #0 to host 10.109.0.88 left intact

我在kubernetes上找到了一个简短的说明,说明为什么会出现此错误(部分:匿名请求) https://kubernetes.io/docs/reference/access-authn-authz/authentication/

但是我仍然不明白我的错误在哪里,因为使用kubectl可以正常工作
kubectl  --token=ZXlKaGJHY2lPaUpTVXpJ........swWHNIVzZ3 get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-kubernetes NodePort 192.2.0.159 <none> 80:17502/TCP 13d
hello-kubernetes-olivier NodePort 192.2.0.235 <none> 80:17296/TCP 13d
kubernetes ClusterIP 192.2.0.1 <none> 443/TCP 14d

最佳答案

这可能是您的错别字,是“bearer”的一部分,我记得是“bearer”。

一些命令示例如下,Kubernetes - Accessing Clusters

$ APISERVER=$(kubectl config view | grep server | cut -f 2- -d ":" | tr -d " ")

$ TOKEN=$(kubectl describe secret $(kubectl get secrets | grep default | cut -f1 -d ' ') | grep -E '^token' | cut -f2 -d':' | tr -d '\t')

$ curl $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure
{
"kind": "APIVersions",
"versions": [
"v1"
],
"serverAddressByClientCIDRs": [
{
"clientCIDR": "0.0.0.0/0",
"serverAddress": "10.0.1.149:443"
}
]
}

关于kubernetes - kube-apiserver身份验证(未授权),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51192493/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com