Create a deployment from a pod in kubernetes

6/24/2017

For a use case I need to create deployments from a pod when a script is being executed from inside the pod.

I am using google container engine for my cluster.

How to configure the container inside the pod to be able to run commands like kubectl create deployment.yaml?

P.S A bit clueless about it at the moment.

-- user2526795
google-kubernetes-engine
kubectl
kubernetes

1 Answer

6/24/2017

Your container is going to need to have kubectl available. There are some container images available, personally I can't vouch for any of them.

Personally I'd probably build my own and download the latest kubectl. A Dockerfile like this is probably a good starting point

FROM alpine:latest
RUN apk --no-cache add curl

RUN curl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl
RUN chmod +x /usr/local/bin/kubectl

This will build you a container image with kubectl, so you can then all the kubectl commands you want.

-- Dan Murphy
Source: StackOverflow