Command not found error while running exec command on kubernetes pod

Bhavishka Sathawane 26 Reputation points
2022-11-20T19:01:15.99+00:00

I have one pod name examplepod. I want to install one software on this pod. How can I do this?

I am trying this- kubectl exec -it examplepod -n namespacename-ci -- /bin/bash.
I get bash-4.4 I enter sudo su after it which I get bash:sudo :command not found
Tried running apt-get install commands but kept in getting command not found error .
The user with which I'm trying to access it has sudo privileges .

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,159 questions
{count} votes

Accepted answer
  1. Roderick Bant 2,051 Reputation points
    2022-11-20T19:37:34.953+00:00

    Hi,

    Thanks for posting your question on Q&A. Typically you do not install software in running containers within a kubernetes pod. Instead you use docker build to build a container image based on the instructions contained in a Dockerfile. You then push the built image to a docker registry, such as Azure Container Registry which acts as a repository for container images. In your kubernetes pod definition you can then reference your image and registry. Ideally you don't want to run any additional configuration or installation commands in a running container/pod as the kubernetes API does not know about these steps and is thus not able to reproduce them when scaling or rescheduling pods as would happen in host failure or maintenance.

    To use apt commands you would typically want to use a debian or ubuntu base image.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.