I need to make my Linux container running (without any app or service in it) so I can enter /bin/bash and modify some local linux files before I actually manually run my app from the container shell (this is purely for some debugging purposes so I do not want any modifications in my image itself, please do not suggest that as an option)
I have defined my Kubernetes YAML file hoping that I would be able to execute simple command: ["/bin/bash"]
but this does not work because it will execute command and Exit the container. So how I can make it not to exit so I am able to exec
container?
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontarena-ads-deployment2
labels:
app: frontarena-ads-deployment2
spec:
replicas: 1
template:
metadata:
name: frontarena-ads-aks-test2
labels:
app: frontarena-ads-aks-test2
spec:
nodeSelector:
"beta.kubernetes.io/os": linux
restartPolicy: Always
containers:
- name: frontarena-ads-aks-test2
image: test.dev/ads:test2
imagePullPolicy: Always
env:
- name: DB_TYPE
value: "odbc"
- name: LANG
value: "en_US.utf8"
command: ["/bin/bash"]
imagePullSecrets:
- name: fa-repo-secret
selector:
matchLabels:
app: frontarena-ads-aks-test2
When I want to see what is going on after the deployment I can notice:
NAME READY STATUS RESTARTS AGE
frontarena-ads-deployment2-546fc4b75-zmmrs 0/1 CrashLoopBackOff 19 77m
kubectl logs $POD
doesn't return anything
and kubectl describe pod $POD
output is:
Command:
/bin/bash
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Completed
Exit Code: 0
Started: Wed, 07 Apr 2021 11:40:31 +0000
Finished: Wed, 07 Apr 2021 11:40:31 +0000
You just need to run some long/endless process for the container to be up. For example you can read a stream, that'll last forever unless you kill the pod/container:
command: ["/bin/bash", "-c"]
args: ["cat /dev/stdout"]