I have a 3 node cluster (1 master and 2 worker nodes)
I have a deployment running with pod image as nginx on one of workers node. The following is its manifest definition:-
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
run: nginx
name: nginx
spec:
replicas: 1
selector:
matchLabels:
run: nginx
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
run: nginx
spec:
volumes:
- name: logs
emptyDir: {}
containers:
- image: nginx
name: nginx
resources: {}
volumeMounts:
- name: logs
mountPath: /var/log/nginx
If I tail the nginx logs, I can see logs are getting generated in the location as /var/log/nginx:-
vagrant@mykubemaster:~/my-k8s/sidecar$ kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-5bb7d5c6dd-hjxnr 1/1 Running 0 8m8s
vagrant@mykubemaster:~/my-k8s/sidecar$ kubectl exec nginx-5bb7d5c6dd-hjxnr -- tail -f /var/log/nginx/access.log
10.32.0.1 - - [06/Jan/2021:02:43:11 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.58.0" "-"
10.32.0.1 - - [06/Jan/2021:02:43:56 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.58.0" "-"
10.32.0.1 - - [06/Jan/2021:02:46:11 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.58.0" "-"
10.32.0.1 - - [06/Jan/2021:02:46:17 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.58.0" "-"
10.32.0.1 - - [06/Jan/2021:02:48:29 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.58.0" "-"
However, the problem is if I ssh into the worker nodes (both) and even the master node, I do not see any folder as nginx created under /var/log then where this file (access.log) is getting stored which I can stream very well using the -f and --tail command?
My understanding was when we do a volume mount then Pod uses the VM's storage location where the pod got provisioned. If on node02, then at some location as specified in the manifest on Node02.
I would really appreciate if you can help me to understand on this and find the file path.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…