在 ubuntu pod 中找不到 curl 或 sudo 包

The*_*ver -1 ubuntu curl sudo apt-get kubernetes

我在 kubernetes 上部署了一个服务,然后我想在集群本身内部测试它,然后再设置入口规则以在外部访问它。

因此,在我从日志中验证该服务正在运行之后。

我尝试创建一个 Pod 并通过以下方式访问其中的 shell

kubectl run -i --tty ubuntu --image=ubuntu --restart=Never -- sh

这似乎工作正常。我看到了一个 ubuntu shell,它似乎运行良好。

但是如果我做一个卷曲:例如

curl --location --request GET 'http://127.0.0.1:9000/hello'

我得到回应 sh: 4: curl: not found

所以后来我尝试了,

apt-get install curl 这给了我:

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package curl
Run Code Online (Sandbox Code Playgroud)

认为这是因为 sudo 。我就是这么做的sudo apt-get install curl,但这告诉我 sh: 6: sudo: not found

尝试安装 sudoapt-get install sudo但那只是给出

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package sudo
Run Code Online (Sandbox Code Playgroud)

我在这里缺少什么?

The*_*ver 6

看来我只需要更新 apt-get 即可。

看起来当你进入这样的 Pod 时,你就是以 root 用户身份工作的。只要做apt-get update ,然后你就可以做apt-get install curl。那行得通。

如果你的是阿尔卑斯山的,而不是apt,那就是

apk add curl