I’m having an issue with my Kubernetes Pod YAML file. The commands specified in the args
section are not executing automatically when the Pod starts. Instead, I have to manually run these commands each time.
<code>apiVersion: v1
kind: Pod
metadata:
name: my-pod
namespace: default
spec:
nodeSelector:
node.kubernetes.io/instance-type: nice-gpu-machine
containers:
- args:
- -c
- |
apt-get update -y
apt upgrade -y
yes | unminimize
apt-get install -y byobu wget curl git vim nano jq unzip bzip2 tar gzip tmux htop tree net-tools man-db
apt update -y
apt upgrade -y
apt install -y software-properties-common
add-apt-repository -y ppa:deadsnakes/ppa
apt update -y
apt upgrade -y
apt install -y python3.11 python3.11-venv python3.11-dev python3.11-distutils
apt-get update -y && apt-get install -y openssh-server
sleep infinity
command:
- /bin/bash
image: my-registry/my-image:latest
imagePullPolicy: IfNotPresent
name: app
resources:
limits:
nvidia.com/gpu: 8
hugepages-2Mi: 5120Mi
requests:
memory: 8000Mi
volumeMounts:
- mountPath: /checkpoints
name: checkpoints-volume
- mountPath: /code
name: code-volume
- mountPath: /data
name: data-volume
- name: dshm
mountPath: /dev/shm
restartPolicy: Never
volumes:
- name: checkpoints-volume
persistentVolumeClaim:
claimName: checkpoints-pvc
- name: code-volume
persistentVolumeClaim:
claimName: code-pvc
- name: data-volume
persistentVolumeClaim:
claimName: data-pvc
- name: dshm
emptyDir:
medium: Memory
</code>
<code>apiVersion: v1
kind: Pod
metadata:
name: my-pod
namespace: default
spec:
nodeSelector:
node.kubernetes.io/instance-type: nice-gpu-machine
containers:
- args:
- -c
- |
apt-get update -y
apt upgrade -y
yes | unminimize
apt-get install -y byobu wget curl git vim nano jq unzip bzip2 tar gzip tmux htop tree net-tools man-db
apt update -y
apt upgrade -y
apt install -y software-properties-common
add-apt-repository -y ppa:deadsnakes/ppa
apt update -y
apt upgrade -y
apt install -y python3.11 python3.11-venv python3.11-dev python3.11-distutils
apt-get update -y && apt-get install -y openssh-server
sleep infinity
command:
- /bin/bash
image: my-registry/my-image:latest
imagePullPolicy: IfNotPresent
name: app
resources:
limits:
nvidia.com/gpu: 8
hugepages-2Mi: 5120Mi
requests:
memory: 8000Mi
volumeMounts:
- mountPath: /checkpoints
name: checkpoints-volume
- mountPath: /code
name: code-volume
- mountPath: /data
name: data-volume
- name: dshm
mountPath: /dev/shm
restartPolicy: Never
volumes:
- name: checkpoints-volume
persistentVolumeClaim:
claimName: checkpoints-pvc
- name: code-volume
persistentVolumeClaim:
claimName: code-pvc
- name: data-volume
persistentVolumeClaim:
claimName: data-pvc
- name: dshm
emptyDir:
medium: Memory
</code>
apiVersion: v1
kind: Pod
metadata:
name: my-pod
namespace: default
spec:
nodeSelector:
node.kubernetes.io/instance-type: nice-gpu-machine
containers:
- args:
- -c
- |
apt-get update -y
apt upgrade -y
yes | unminimize
apt-get install -y byobu wget curl git vim nano jq unzip bzip2 tar gzip tmux htop tree net-tools man-db
apt update -y
apt upgrade -y
apt install -y software-properties-common
add-apt-repository -y ppa:deadsnakes/ppa
apt update -y
apt upgrade -y
apt install -y python3.11 python3.11-venv python3.11-dev python3.11-distutils
apt-get update -y && apt-get install -y openssh-server
sleep infinity
command:
- /bin/bash
image: my-registry/my-image:latest
imagePullPolicy: IfNotPresent
name: app
resources:
limits:
nvidia.com/gpu: 8
hugepages-2Mi: 5120Mi
requests:
memory: 8000Mi
volumeMounts:
- mountPath: /checkpoints
name: checkpoints-volume
- mountPath: /code
name: code-volume
- mountPath: /data
name: data-volume
- name: dshm
mountPath: /dev/shm
restartPolicy: Never
volumes:
- name: checkpoints-volume
persistentVolumeClaim:
claimName: checkpoints-pvc
- name: code-volume
persistentVolumeClaim:
claimName: code-pvc
- name: data-volume
persistentVolumeClaim:
claimName: data-pvc
- name: dshm
emptyDir:
medium: Memory
I have two questions:
- Is there anything wrong with my YAML file that’s preventing the
args
commands from executing automatically? - If the YAML file is correct, would it be better to create a new Docker image with these commands pre-installed? If so, how should I approach this?
Solution 1 is strongly preferred as 2 is complicated and more time consuming than updating one YAML file e.g. pushing image building it and it might be huge.
Note: also posted at https://discuss.kubernetes.io/t/help-with-kubernetes-pod-yaml-commands-in-args-not-executing-automatically-how-to-do-so-by-editing-only-the-yml-file/29388
3