i created user teamcity to be able to use kube-apiserver
kubectl create serviceaccount teamcity
With the command below i get the secrets name
kubectl get accourcissements teamcity -o yaml
To find the token who were generated by the last command i use
kubectl get secret teamcity-token-lmr6z -o yaml
when i try to connect by curl i've an error and i dont understand where is my mistake :(
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
I found a small description on kubernetes about why i get this error (section : Anonymous requests) https://kubernetes.io/docs/reference/access-authn-authz/authentication/
But i still not understand where is my mistake because with kubectl it's work
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