Create a deployment from a pod in kubernetes

好久不见. 提交于 2020-01-17 07:28:08

问题


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

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