Question
There is a multi-container Deployment in Namespace management which seems to have issues and is not getting ready.
Write the logs of all containers to /root/logs.log
Can you see the reason for failure?
Fix the deployment
Answer
Write the logs:
kubectl -n management logs deploy/collect-data -c nginx >> /root/logs.log
kubectl -n management logs deploy/collect-data -c httpd >> /root/logs.log
The issue seems that both containers have processes that want to listen on port 80. Depending on container creation order and speed, the first will succeed, the other will fail:
(98)Address in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
For fixing we need to edit the deploy:
kubectl -n management edit deployments.apps collect-data
and delete one of containers:
- image: httpd:2.4.52-alpine
imagePullPolicy: IfNotPresent
name: httpd
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File