vasudev chavan:
Events:
Type Reason Age From Message
Normal Scheduled 39s default-scheduler Successfully assigned ckaexam/simple-webapp-2fx7f to http://71fb734cf01c.mylabserver.com|71fb734cf01c.mylabserver.com
Normal Pulling 36s kubelet Pulling image “nginx”
Normal Pulled 33s kubelet Successfully pulled image “nginx” in 2.661329525s
Normal Created 33s kubelet Created container webapp
Normal Started 33s kubelet Started container webapp
Normal Pulled 28s kubelet Successfully pulled image “nginx” in 5.069889229s
Normal Pulled 22s kubelet Successfully pulled image “nginx” in 2.944485115s
Normal Pulling 7s (x3 over 33s) kubelet Pulling image “nginx”
Normal Created 4s (x3 over 28s) kubelet Created container sidecarpod
Normal Started 4s (x3 over 28s) kubelet Started container sidecarpod
Normal Pulled 4s kubelet Successfully pulled image “nginx” in 2.624941296s
Warning BackOff 1s (x2 over 18s) kubelet Back-off restarting failed container
Tej Singh Rana:
Hello, @vasudev chavan
It’s not a log. you are sharing events details.
Do kubectl logs <pod-name>
to see actual logs of that pod.
vasudev chavan:
Since i am using default port its failing i think
vasudev chavan:
cloud_user@682352d24d1c:~/Acloud/Replicaset$ kubectl logs simple-webapp-229r7 -c sidecarpod
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2021/12/06 14:56:41 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/12/06 14:56:41 [emerg] 1#1: bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
2021/12/06 14:56:41 [notice] 1#1: try again to bind() after 500ms
2021/12/06 14:56:41 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/12/06 14:56:41 [emerg] 1#1: bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
2021/12/06 14:56:41 [notice] 1#1: try again to bind() after 500ms
2021/12/06 14:56:41 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/12/06 14:56:41 [emerg] 1#1: bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
2021/12/06 14:56:41 [notice] 1#1: try again to bind() after 500ms
2021/12/06 14:56:41 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/12/06 14:56:41 [emerg] 1#1: bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
2021/12/06 14:56:41 [notice] 1#1: try again to bind() after 500ms
2021/12/06 14:56:41 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/12/06 14:56:41 [emerg] 1#1: bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
2021/12/06 14:56:41 [notice] 1#1: try again to bind() after 500ms
2021/12/06 14:56:41 [emerg] 1#1: still could not bind()
vasudev chavan:
@Tej Singh Rana can we have multiple images in replica set and can we control replicas for every images
vasudev chavan:
just now i have changed the image to busybox and and i cannot fetch logs for it
vasudev chavan:
kubectl get pods
NAME READY STATUS RESTARTS AGE
simple-webapp-67wq2 1/2 CrashLoopBackOff 5 (2m15s ago) 5m35s
simple-webapp-n4gp2 1/2 CrashLoopBackOff 5 (2m7s ago) 5m35s
simple-webapp-wv5zn 1/2 CrashLoopBackOff 5 (2m4s ago) 5m35s
vasudev chavan:
Replicaset$ kubectl logs simple-webapp-67wq2 -c sidecarpod && date
Mon Dec 6 15:05:02 UTC 2021
Puneet Khanna:
Did that work?
Antonio:
hi, both nginx containers by default try to bind the same port 80.
You need to use a different port for one of them. To do that you need to change the config of nginx /etc/nginx/conf.d/default.conf
Antonio:
there is the listen to 80. Change it to another one
server {
listen 80;
listen [::]:80;
server_name localhost;
…
…
Antonio:
to do that you can get the default config and store it in a file:
kubectl exec <pod name>-c webapp – cat /etc/nginx/conf.d/default.conf
Antonio:
then you change the port number
vasudev chavan:
its a replicaset and i was just trying to run multiple containers within that
vasudev chavan:
I was thinking if we can control replicaset for different images or containers in the same file
Antonio:
well, you have to consider that the network created for the containers is the same, the localhost. So, you end up having 2 containers binding the same port in the same network localhost
Antonio:
in a multi-container pod, you need to ensure that all the containers are using different ports
Antonio:
there are 2 networks involved.
- the local network cerated within the pod for the containers
Antonio:
2. the network that allows pod-to-pod communication