问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/44734822/create-a-deployment-from-a-pod-in-kubernetes