snippetkubernetesMinor
How do I install local application dependencies in a Kubernetes manifest?
Viewed 0 times
localinstallapplicationkubernetesmanifesthowdependencies
Problem
In a container, there are RUN statements that you can add to a containerfile (such as a dockerfile) to add further dependencies using the package manager like APT or DNF within a container.
What is the proper equivalent to performing this in Kubernetes with a YAML manifest? For example, I'd like to install git in my Jenkins container so as to be able to use the git plugin in that application.
I tried to do this with "command" and "args" in the yaml, but it looks like it isn't executing as superuser? I get permission errors, and cannot install any packages that way.
What is the proper equivalent to performing this in Kubernetes with a YAML manifest? For example, I'd like to install git in my Jenkins container so as to be able to use the git plugin in that application.
I tried to do this with "command" and "args" in the yaml, but it looks like it isn't executing as superuser? I get permission errors, and cannot install any packages that way.
Solution
You can't add run-time dependencies on an already build image using a yaml manifest.
You might attach/exec to an already running pod and install them, but it makes no sence, since you need to make sure that when the pod is re-created you do it again. The much better and right way is simply to describe it in your Dockerfile.
Kubernetes is not created for such kind of hacky moves. It simpy maintains state that you describe. Essentially you need to add an instruction that adds git in your Jenkins dockerfile, build your new image and refer to it inside the manifest.
Commands and args are used if you want override the image's default entrypoint and its arguments.
You might attach/exec to an already running pod and install them, but it makes no sence, since you need to make sure that when the pod is re-created you do it again. The much better and right way is simply to describe it in your Dockerfile.
Kubernetes is not created for such kind of hacky moves. It simpy maintains state that you describe. Essentially you need to add an instruction that adds git in your Jenkins dockerfile, build your new image and refer to it inside the manifest.
Commands and args are used if you want override the image's default entrypoint and its arguments.
Context
StackExchange DevOps Q#11711, answer score: 2
Revisions (0)
No revisions yet.