kubectl run 已弃用 - 寻找替代方案 [英] kubectl run is deprecated - looking for alternative

查看:56
本文介绍了kubectl run 已弃用 - 寻找替代方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有环境参数的 kubectl run 来为我创建临时的 docker 容器(例如一些用于调试目的的转发).几个星期以来,kubectl 抱怨 kubectl run 被弃用.很遗憾,我找不到合适的替代品.

I'm using kubectl run with environment parameters to create temporary docker containers for me (e.g. some forwarding for debugging purposes). Since several weeks kubectl is complaining about kubectl run being deprecated. Unfortunately I can't find an appropriate replacement.

这是旧命令:

$KUBECTL run -i -t --attach=false --image djfaze/port-forward --env="REMOTE_HOST=$REMOTE_HOST" --env="REMOTE_PORT=$REMOTE_PORT" $POD_NAME

发出此消息时,kubectl 抱怨此消息:

When issuing this, kubectl complains with this message:

kubectl run --generator=deployment/apps.v1beta1 已弃用,将在未来版本中删除.改用 kubectl create.

kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed in a future version. Use kubectl create instead.

任何想法如何替换此运行命令?

Any ideas how to replace this run command?

推荐答案

作为问题的作者,让我解释一下这个弃用背后的意图.就像 Brendan 在 他的回答 中解释的那样,kubectl run 本身并没有被弃用,只有所有生成器,除了为您创建 Pod 的那个.

As the author of the problem let me explain a little bit the intention behind this deprecation. Just like Brendan explains in his answer, kubectl run per se is not being deprecated, only all the generators, except for the one that creates a Pod for you.

这种变化的原因有两个:

The reason for this change is two folds:

  1. kubectl run 命令的绝大多数输入参数对于新手和老手来说都是压倒性的.弄清楚调用的结果是什么并不容易.您需要考虑几个传递的选项以及服务器版本.

  1. The vast majority of input parameters for kubectl run command is overwhelming for newcomers, as well as for the old timers. It's not that easy to figure out what will be the result of your invocation. You need to take into consideration several passed options as well as the server version.

考虑到可能性矩阵的增长速度超出了我们的处理能力,它背后的代码也很难维护.

The code behind it is also a mess to maintain given the matrix of possibilities is growing faster than we can handle.

这就是为什么我们试图让人们在他们的日常工作流程中不再使用 kubectl run,并说服他们使用显式的 kubectl create 命令更直接.最后,我们希望让那些使用 docker 或任何其他容器引擎(在其中运行容器)的新手拥有与 Kubernetes 相同的体验,其中 kubectl run 只会在集群中运行一个 Pod.

That's why we're trying to move people away from using kubectl run for their daily workflows and convince them that using explicit kubectl create commands is more straightforward. Finally, we want to make the newcomers that played with docker or any other container engine, where they run a container, to have the same experience with Kubernetes where kubectl run will just run a Pod in a cluster.

对于最初的困惑,我很抱歉,我希望这能解决问题.

Sorry for the initial confusion and I hope this will clear things up.

更新 (2020/01/10):截至 https://github.com/kubernetes/kubernetes/pull/87077 kubectl run 只会创建 Pod.所有发电机将被完全删除.

UPDATE (2020/01/10): As of https://github.com/kubernetes/kubernetes/pull/87077 kubectl run will ONLY create Pods. All generators will be removed entirely.

这篇关于kubectl run 已弃用 - 寻找替代方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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