/proc ディレクトリのメモ。
適当な Pod を実行する。
apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: apache name: apache spec: containers: - image: httpd name: apache resources: {} env: - name: SECRET value: "012345678902" dnsPolicy: ClusterFirst restartPolicy: Always status: {}
k apply -f pod.yaml
root@cks-master:~# k get pod NAME READY STATUS RESTARTS AGE apache 1/1 Running 0 12m
ワーカーノードでこの Pod を確認する。
root@cks-worker:~# crictl ps CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID POD 5ed77af7498a4 73c10eb9266e7 13 minutes ago Running apache 0 4da15aa43350f apache 7ff96b31dd2d8 e6ea68648f0cd 5 hours ago Running kube-flannel 1 b612e5af2647b canal-ncg7l ff37aef743c83 75392e3500e36 5 hours ago Running calico-node 1 b612e5af2647b canal-ncg7l a68026fe5b938 430bf372a28b7 5 hours ago Running kube-proxy 1 e03da17696175 kube-proxy-sq2p6
PID を確認する。
root@cks-worker:~# crictl inspect 5ed77af7498a4 | grep pid "pid": 65429, "pid": 1 "type": "pid"
ps コマンドでも確認する。
root@cks-worker:~# ps -ef | grep httpd root 65429 65369 0 00:54 ? 00:00:00 httpd -DFOREGROUND www-data 65442 65429 0 00:54 ? 00:00:00 httpd -DFOREGROUND www-data 65443 65429 0 00:54 ? 00:00:00 httpd -DFOREGROUND www-data 65444 65429 0 00:54 ? 00:00:00 httpd -DFOREGROUND root 69073 68717 0 01:08 pts/0 00:00:00 grep --color=auto httpd
このプロセスの /proc/65429
ディレクトリを見てみる。
root@cks-worker:~# cd /proc/65429 root@cks-worker:/proc/65429# ls -l total 0 -r--r--r-- 1 root root 0 Jan 5 00:57 arch_status dr-xr-xr-x 2 root root 0 Jan 5 00:57 attr -rw-r--r-- 1 root root 0 Jan 5 00:57 autogroup -r-------- 1 root root 0 Jan 5 00:57 auxv -r--r--r-- 1 root root 0 Jan 5 00:54 cgroup --w------- 1 root root 0 Jan 5 00:57 clear_refs -r--r--r-- 1 root root 0 Jan 5 00:55 cmdline -rw-r--r-- 1 root root 0 Jan 5 00:57 comm -rw-r--r-- 1 root root 0 Jan 5 00:57 coredump_filter -r--r--r-- 1 root root 0 Jan 5 00:57 cpu_resctrl_groups -r--r--r-- 1 root root 0 Jan 5 00:57 cpuset lrwxrwxrwx 1 root root 0 Jan 5 00:57 cwd -> /usr/local/apache2 -r-------- 1 root root 0 Jan 5 00:57 environ lrwxrwxrwx 1 root root 0 Jan 5 00:54 exe -> /usr/local/apache2/bin/httpd dr-x------ 2 root root 0 Jan 5 00:54 fd dr-xr-xr-x 2 root root 0 Jan 5 00:57 fdinfo -rw-r--r-- 1 root root 0 Jan 5 00:57 gid_map -r-------- 1 root root 0 Jan 5 00:57 io -r--r--r-- 1 root root 0 Jan 5 00:54 limits -rw-r--r-- 1 root root 0 Jan 5 00:57 loginuid dr-x------ 2 root root 0 Jan 5 00:57 map_files -r--r--r-- 1 root root 0 Jan 5 00:57 maps -rw------- 1 root root 0 Jan 5 00:57 mem -r--r--r-- 1 root root 0 Jan 5 00:54 mountinfo -r--r--r-- 1 root root 0 Jan 5 00:57 mounts -r-------- 1 root root 0 Jan 5 00:57 mountstats dr-xr-xr-x 64 root root 0 Jan 5 00:54 net dr-x--x--x 2 root root 0 Jan 5 00:55 ns -r--r--r-- 1 root root 0 Jan 5 00:57 numa_maps -rw-r--r-- 1 root root 0 Jan 5 00:57 oom_adj -r--r--r-- 1 root root 0 Jan 5 00:57 oom_score -rw-r--r-- 1 root root 0 Jan 5 00:57 oom_score_adj -r-------- 1 root root 0 Jan 5 00:57 pagemap -r-------- 1 root root 0 Jan 5 00:57 patch_state -r-------- 1 root root 0 Jan 5 00:57 personality -rw-r--r-- 1 root root 0 Jan 5 00:57 projid_map lrwxrwxrwx 1 root root 0 Jan 5 00:57 root -> / -rw-r--r-- 1 root root 0 Jan 5 00:57 sched -r--r--r-- 1 root root 0 Jan 5 00:57 schedstat -r--r--r-- 1 root root 0 Jan 5 00:57 sessionid -rw-r--r-- 1 root root 0 Jan 5 00:57 setgroups -r--r--r-- 1 root root 0 Jan 5 00:57 smaps -r--r--r-- 1 root root 0 Jan 5 00:57 smaps_rollup -r-------- 1 root root 0 Jan 5 00:57 stack -r--r--r-- 1 root root 0 Jan 5 00:54 stat -r--r--r-- 1 root root 0 Jan 5 00:57 statm -r--r--r-- 1 root root 0 Jan 5 00:55 status -r-------- 1 root root 0 Jan 5 00:57 syscall dr-xr-xr-x 3 root root 0 Jan 5 00:56 task -rw-r--r-- 1 root root 0 Jan 5 00:57 timens_offsets -r--r--r-- 1 root root 0 Jan 5 00:57 timers -rw-rw-rw- 1 root root 0 Jan 5 00:57 timerslack_ns -rw-r--r-- 1 root root 0 Jan 5 00:54 uid_map -r--r--r-- 1 root root 0 Jan 5 00:57 wchan root@cks-worker:/proc/65429#
exe がこのプロセスの実行ファイル。
root@cks-worker:/proc/65429# ls -l exe lrwxrwxrwx 1 root root 0 Jan 5 00:54 exe -> /usr/local/apache2/bin/httpd root@cks-worker:/proc/65429#
root
ディレクトリでコンテナから見えているファイルシステムが確認できる。
root@cks-worker:/proc/65429/root# ls -l total 68 drwxr-xr-x 1 root root 4096 Dec 21 11:27 bin drwxr-xr-x 2 root root 4096 Dec 9 19:15 boot drwxr-xr-x 5 root root 360 Jan 5 00:54 dev drwxr-xr-x 1 root root 4096 Jan 5 00:54 etc drwxr-xr-x 2 root root 4096 Dec 9 19:15 home drwxr-xr-x 1 root root 4096 Dec 21 11:27 lib drwxr-xr-x 2 root root 4096 Dec 19 00:00 lib64 drwxr-xr-x 2 root root 4096 Dec 19 00:00 media drwxr-xr-x 2 root root 4096 Dec 19 00:00 mnt drwxr-xr-x 2 root root 4096 Dec 19 00:00 opt dr-xr-xr-x 188 root root 0 Jan 5 00:54 proc drwx------ 1 root root 4096 Jan 5 00:55 root drwxr-xr-x 1 root root 4096 Jan 5 00:54 run drwxr-xr-x 2 root root 4096 Dec 19 00:00 sbin drwxr-xr-x 2 root root 4096 Dec 19 00:00 srv dr-xr-xr-x 13 root root 0 Jan 5 00:54 sys drwxrwxrwt 1 root root 4096 Dec 21 11:26 tmp drwxr-xr-x 1 root root 4096 Dec 19 00:00 usr drwxr-xr-x 1 root root 4096 Dec 19 00:00 var root@cks-worker:/proc/65429/root# cd ../ root@cks-worker:/proc/65429#
environ
ファイルで環境変数が確認できる。
root@cks-worker:/proc/65429# cat environ HTTPD_VERSION=2.4.54KUBERNETES_SERVICE_PORT=443KUBERNETES_PORT=tcp://10.96.0.1:443HOSTNAME=apacheHOME=/rootHTTPD_PATCHES=KUBERNETES_PORT_443_TCP_ADDR=10.96.0.1PATH=/usr/local/apache2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binKUBERNETES_PORT_443_TCP_PORT=443HTTPD_SHA256=eb397feeefccaf254f8d45de3768d9d68e8e73851c49afd5b7176d1ecf80c340KUBERNETES_PORT_443_TCP_PROTO=tcpSECRET=012345678902HTTPD_PREFIX=/usr/local/apache2KUBERNETES_PORT_443_TCP=tcp://10.96.0.1:443KUBERNETES_SERVICE_PORT_HTTPS=443KUBERNETES_SERVICE_HOST=10.96.0.1PWD=/usr/local/apache2root@cks-worker:/proc/65429#
fd
がファイルディスクリプタで開いているファイルを確認できる。
root@cks-worker:/proc/65429# cd fd root@cks-worker:/proc/65429/fd# ls -l total 0 lrwx------ 1 root root 64 Jan 5 00:54 0 -> /dev/null l-wx------ 1 root root 64 Jan 5 00:54 1 -> 'pipe:[311806]' l-wx------ 1 root root 64 Jan 5 00:54 2 -> 'pipe:[311807]' lrwx------ 1 root root 64 Jan 5 00:55 3 -> 'socket:[311114]' lrwx------ 1 root root 64 Jan 5 00:55 4 -> 'socket:[311115]' lr-x------ 1 root root 64 Jan 5 00:55 5 -> 'pipe:[311126]' l-wx------ 1 root root 64 Jan 5 00:54 6 -> 'pipe:[311126]' l-wx------ 1 root root 64 Jan 5 00:55 7 -> 'pipe:[311806]' root@cks-worker:/proc/65429/fd# cd ../ root@cks-worker:/proc/65429#