parent
219b8f07a7
commit
126f9a3a0d
|
@ -43,52 +43,58 @@ Process Namespace Sharing is enabled using the `ShareProcessNamespace` field of
|
|||
|
||||
1. Create the pod `nginx` on your cluster:
|
||||
|
||||
kubectl apply -f https://k8s.io/examples/pods/share-process-namespace.yaml
|
||||
```shell
|
||||
kubectl apply -f https://k8s.io/examples/pods/share-process-namespace.yaml
|
||||
```
|
||||
|
||||
1. Attach to the `shell` container and run `ps`:
|
||||
|
||||
```
|
||||
kubectl attach -it nginx -c shell
|
||||
```
|
||||
```shell
|
||||
kubectl attach -it nginx -c shell
|
||||
```
|
||||
|
||||
If you don't see a command prompt, try pressing enter.
|
||||
If you don't see a command prompt, try pressing enter.
|
||||
|
||||
```
|
||||
/ # ps ax
|
||||
PID USER TIME COMMAND
|
||||
1 root 0:00 /pause
|
||||
8 root 0:00 nginx: master process nginx -g daemon off;
|
||||
14 101 0:00 nginx: worker process
|
||||
15 root 0:00 sh
|
||||
21 root 0:00 ps ax
|
||||
```
|
||||
```
|
||||
/ # ps ax
|
||||
PID USER TIME COMMAND
|
||||
1 root 0:00 /pause
|
||||
8 root 0:00 nginx: master process nginx -g daemon off;
|
||||
14 101 0:00 nginx: worker process
|
||||
15 root 0:00 sh
|
||||
21 root 0:00 ps ax
|
||||
```
|
||||
|
||||
You can signal processes in other containers. For example, send `SIGHUP` to
|
||||
nginx to restart the worker process. This requires the `SYS_PTRACE` capability.
|
||||
|
||||
/ # kill -HUP 8
|
||||
/ # ps ax
|
||||
PID USER TIME COMMAND
|
||||
1 root 0:00 /pause
|
||||
8 root 0:00 nginx: master process nginx -g daemon off;
|
||||
15 root 0:00 sh
|
||||
22 101 0:00 nginx: worker process
|
||||
23 root 0:00 ps ax
|
||||
```
|
||||
/ # kill -HUP 8
|
||||
/ # ps ax
|
||||
PID USER TIME COMMAND
|
||||
1 root 0:00 /pause
|
||||
8 root 0:00 nginx: master process nginx -g daemon off;
|
||||
15 root 0:00 sh
|
||||
22 101 0:00 nginx: worker process
|
||||
23 root 0:00 ps ax
|
||||
```
|
||||
|
||||
It's even possible to access another container image using the
|
||||
`/proc/$pid/root` link.
|
||||
|
||||
/ # head /proc/8/root/etc/nginx/nginx.conf
|
||||
```
|
||||
/ # head /proc/8/root/etc/nginx/nginx.conf
|
||||
|
||||
user nginx;
|
||||
worker_processes 1;
|
||||
user nginx;
|
||||
worker_processes 1;
|
||||
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
events {
|
||||
worker_connections 1024;
|
||||
```
|
||||
|
||||
{{% /capture %}}
|
||||
|
||||
|
|
Loading…
Reference in New Issue