Ewan Valentine
Ewan Valentine

Reputation: 3941

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. 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). So I just wondered if there was a way I could effectively run $ kubectl apply -f ./file.yml within a container on the cluster?

Obviously I can create a container with kubectl installed, but I just wondered how that could then 'connect' to the Kubernetes controller?

Upvotes: 3

Views: 993

Answers (3)

BenDenney
BenDenney

Reputation: 1

I found that the roffe/kubectl image works well for running a kubectl apply -f to deploy to my cluster. 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.

Upvotes: 0

ozlevka
ozlevka

Reputation: 2156

You can choose from existing ones: https://hub.docker.com/search?q=kubectl&type=image

Upvotes: 1

P Ekambaram
P Ekambaram

Reputation: 17679

Yes, it is possible. refer halyard container. spinnaker is deployed from halyard container.

Upvotes: 1

Related Questions