简体   繁体   English

是否可以在集群内的容器内运行 kubectl?

[英]Is it possible to run kubectl within a container within the cluster?

I have a kubernetes cluster, and I basically have an authenticated api for deploying tasks within the cluster without having kubectl etc set-up locally.我有一个 kubernetes 集群,我基本上有一个经过身份验证的 api 用于在集群内部署任务,而无需在本地设置 kubectl 等。 I'm aware of the client libraries etc for the Kubernetes api, however they don't seem to support all of the different primatives etc (including some custom ones like Argo).我知道 Kubernetes api 的客户端库等,但是它们似乎并不支持所有不同的原语等(包括一些自定义的原语,如 Argo)。 So I just wondered if there was a way I could effectively run $ kubectl apply -f./file.yml within a container on the cluster?所以我只是想知道是否有一种方法可以在集群上的容器中有效地运行$ kubectl apply -f./file.yml

Obviously I can create a container with kubectl installed, but I just wondered how that could then 'connect' to the Kubernetes controller?显然我可以创建一个安装了 kubectl 的容器,但我只是想知道它如何“连接”到 Kubernetes controller?

Yes, it is possible.对的,这是可能的。 refer halyard container.参考吊索容器。 spinnaker is deployed from halyard container.大三角帆是从 halyard 容器部署的。

I found that the roffe/kubectl image works well for running a kubectl apply -f to deploy to my cluster.我发现 roffe/kubectl 映像非常适合运行 kubectl apply -f 以部署到我的集群。 However, you do need to use a ClusterRole and ClusterRoleBinding "attached" to your ServiceAccount, (and the serviceAccount named in your kubectl container), to deploy to any other namespaces.但是,您确实需要使用“附加”到您的 ServiceAccount(以及在您的 kubectl 容器中命名的 serviceAccount)的 ClusterRole 和 ClusterRoleBinding 来部署到任何其他命名空间。

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

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