问题描述
对于一个用例,当我从Pod内部执行脚本时,我需要从Pod创建部署.
For a use case I need to create deployments from a pod when a script is being executed from inside the pod.
我正在为集群使用google容器引擎.
I am using google container engine for my cluster.
如何配置pod内的容器以运行kubectl create deployment.yaml之类的命令?
How to configure the container inside the pod to be able to run commands like kubectl create deployment.yaml?
P.S目前对此一无所知.
P.S A bit clueless about it at the moment.
推荐答案
您的容器将需要有kubectl
可用.有一些容器图像可用,我个人不能保证他们中的任何一个.
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.
我个人可能会自己构建并下载最新的kubectl
.这样的Dockerfile可能是一个很好的起点
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
这将使用kubectl
构建一个容器映像,因此您可以使用所有想要的kubectl
命令.
This will build you a container image with kubectl
, so you can then all the kubectl
commands you want.
这篇关于从kubernetes中的Pod创建部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!