Exec commands on kubernetes pods with root access

2019-03-15 18:31发布

I have one pod running with name 'jenkins-app-2843651954-4zqdp'. I want to install few softwares temporarily on this pod. How can I do this?

I am trying this- kubectl exec -it jenkins-app-2843651954-4zqdp -- /bin/bash and then running apt-get install commands but since the user I am accessing with doesn't have sudo access I am not able to run commands

3条回答
唯我独甜
2楼-- · 2019-03-15 19:05

There are some plugins for kubectl that may help you achieve this: https://github.com/jordanwilson230/kubectl-plugins

One of the plugins called, 'ssh', will allow you to exec as root user by running (for example) kubectl ssh -u root -p nginx-0

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-03-15 19:07

kubectl exec -it <POD NAME> -n <NAMESPACE> -c <CONTAINER NAME> bash

查看更多
放荡不羁爱自由
4楼-- · 2019-03-15 19:09
  • Use kubectl describe pod ... to find the node running your Pod and the container ID (docker://...)
  • SSH into the node
  • run docker exec -u root ID -- /bin/bash
查看更多
登录 后发表回答