how to authenticate to google container engine kubernetes API server using either k8s REST or fabric8 API?

落花浮王杯 提交于 2020-01-07 03:41:15

问题


I'm trying to write a service that spawns container based applications within a Kubernetes cluster. I'd like to do some testing against Google Container Engine as a baseline; however, I am having trouble figuring out how to get my REST client to authenticate with the k8s API server (the master).

I came across a good hint here: http://www.scriptscoop.net/t/9c6a16719a43/google-container-engine-rest-api-authorization.html

The author says "I know that OAuth works [against Google Container Engine]", and they sound knowledgable. So, I'm thinking of trying oauth (I guess oauth2.) However, trial and error will take me a lot longer than adapting from some working code that works against Google Container Engine via either the k8s REST or fabric8 API.

If anyone can give me a pointer to such code, or even discussions of such code, I'd appreciate it very much ! thanks /chris


回答1:


The Kubernetes apiserver doesn't (yet) work with OAuth, so you will need to use one of the supported authentication mechanisms (http basic auth, bearer token auth, or client certificates) when making API requests.

Every pod has a service account automatically applied that allows it to access the apiserver using a bearer token. See How do I access the Kubernetes api from within a pod container?.

With the credentials from the service account, you can deploy an application that will create new objects in the system (pods, replication controllers, etc) to spawn container based applications.



来源:https://stackoverflow.com/questions/34586900/how-to-authenticate-to-google-container-engine-kubernetes-api-server-using-eithe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!