如何以根用户身份输入Pod? [英] How to enter a pod as root?

查看:267
本文介绍了如何以根用户身份输入Pod?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我使用以下命令以mysql用户身份进入Pod:

Currently I enter the pod as a mysql user using the command:

kubectl exec -it PODNAME -n NAMESPACE bash

我想输入一个容器作为root. 我尝试了以下命令:

I want to enter a container as root. I've tried the following command:

kubectl exec -it PODNAME -n NAMESPACE -u root ID /bin/bash

kubectl exec -it PODNAME -n NAMESPACE -u root ID bash

一定有办法. :-)

推荐答案

我找到了答案.

您不能以root用户身份通过​​kubectl直接登录Pod.

You cannot log into the pod directly as root via kubectl.

您可以通过以下步骤进行操作.

You can do via the following steps.

1)找出其在kubectl get po -n [NAMESPACE] -o wide

2)ssh节点

3)找到docker容器sudo docker ps | grep [namespace]

3) find the docker container sudo docker ps | grep [namespace]

4)以root sudo docker exec -it -u root [DOCKER ID] /bin/bash

这篇关于如何以根用户身份输入Pod?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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