kubernetes如何从现有Pod创建新Pod [英] kubernetes how to create new pod from an existing pod

查看:95
本文介绍了kubernetes如何从现有Pod创建新Pod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下疑问,假设我有一个带有n = 1个副本的kubernetes容器A,并且我希望每隔x分钟它会创建一个类型为"Job"的新容器B,我可以从中创建一个作业容器kubectl没问题,但是如何从另一个吊舱实例化吊舱?

I have the following doubt, let's say I have a kubernetes pod A with n=1 replicas, and I want that every x minutes it will create a new pod B of type "Job", I can create a job pod from kubectl without problems, but how can I make a pod be instantiated from another pod ?

我可以尝试在父Pod上使用kubectl,但我认为这不是最优雅的方法.

I could try to use kubectl on the parent pod but I don't think it's the most elegant way to do it.

推荐答案

在窗格中,您可以使用任何受支持的

In the pod you could use any supported kubernetes client library to call REST API exposed by kubernetes API server to create a pod.

需要对客户端库进行身份验证才能调用kubernetes API.客户端库可以将服务帐户用于该服务帐户,并且该服务帐户必须具有RBAC才能通过调用kubernetes API服务器来创建Pod.

The client library need to be authenticated to be to call the kubernetes API. A service account can be used by the client library for that and the service account need to have RBAC to be to be able to create a pod by calling kubernetes API server.

在内部使用kubectl创建pod时,kubectl还调用kubernetes API服务器公开的REST API.

Internally kubectl also calls the REST API exposed by kubernetes API server when kubectl is used to create a pod.

这篇关于kubernetes如何从现有Pod创建新Pod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆