How to run command in deployment and keep pod running

Asking for help? Comment out what you need so we can get more information to help you!

Cluster information:

Kubernetes version:1.22.11
Cloud being used:Microsoft Azure
Installation method:
Host OS: Ubuntu
CNI and version:AzureCNI
CRI and version:

Hi everyone:
I raised a gitlab image on this AKS cluster:
gitlab/gitlab-ce:latest
And I want to run some command with image startup.
like “apt-get update” as below:

spec:
  nodeSelector:
    "kubernetes.io/os": linux
  containers:
  - image: "gitlab/gitlab-ce:latest"
    command: ["/bin/bash", "-ce", "apt-get update"]
    name: gitlab-image
    ports:
    - name: http
      containerPort: 80

when I applied this deployment, the pod’s status returned ContainerCreating->Running->Completed → CrashLoopBackOff

Is there any way I can run some command when pod deployed and keep pod running?

Please kindly help.

look at initContainers

1 Like

Thank you!
That’s what I needed.