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:
|
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`:
|
1. Attach to the `shell` container and run `ps`:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
kubectl attach -it nginx -c 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
|
/ # ps ax
|
||||||
PID USER TIME COMMAND
|
PID USER TIME COMMAND
|
||||||
1 root 0:00 /pause
|
1 root 0:00 /pause
|
||||||
8 root 0:00 nginx: master process nginx -g daemon off;
|
8 root 0:00 nginx: master process nginx -g daemon off;
|
||||||
14 101 0:00 nginx: worker process
|
14 101 0:00 nginx: worker process
|
||||||
15 root 0:00 sh
|
15 root 0:00 sh
|
||||||
21 root 0:00 ps ax
|
21 root 0:00 ps ax
|
||||||
```
|
```
|
||||||
|
|
||||||
You can signal processes in other containers. For example, send `SIGHUP` to
|
You can signal processes in other containers. For example, send `SIGHUP` to
|
||||||
nginx to restart the worker process. This requires the `SYS_PTRACE` capability.
|
nginx to restart the worker process. This requires the `SYS_PTRACE` capability.
|
||||||
|
|
||||||
/ # kill -HUP 8
|
```
|
||||||
/ # ps ax
|
/ # kill -HUP 8
|
||||||
PID USER TIME COMMAND
|
/ # ps ax
|
||||||
1 root 0:00 /pause
|
PID USER TIME COMMAND
|
||||||
8 root 0:00 nginx: master process nginx -g daemon off;
|
1 root 0:00 /pause
|
||||||
15 root 0:00 sh
|
8 root 0:00 nginx: master process nginx -g daemon off;
|
||||||
22 101 0:00 nginx: worker process
|
15 root 0:00 sh
|
||||||
23 root 0:00 ps ax
|
22 101 0:00 nginx: worker process
|
||||||
|
23 root 0:00 ps ax
|
||||||
|
```
|
||||||
|
|
||||||
It's even possible to access another container image using the
|
It's even possible to access another container image using the
|
||||||
`/proc/$pid/root` link.
|
`/proc/$pid/root` link.
|
||||||
|
|
||||||
/ # head /proc/8/root/etc/nginx/nginx.conf
|
```
|
||||||
|
/ # head /proc/8/root/etc/nginx/nginx.conf
|
||||||
|
|
||||||
user nginx;
|
user nginx;
|
||||||
worker_processes 1;
|
worker_processes 1;
|
||||||
|
|
||||||
error_log /var/log/nginx/error.log warn;
|
error_log /var/log/nginx/error.log warn;
|
||||||
pid /var/run/nginx.pid;
|
pid /var/run/nginx.pid;
|
||||||
|
|
||||||
|
|
||||||
events {
|
events {
|
||||||
worker_connections 1024;
|
worker_connections 1024;
|
||||||
|
```
|
||||||
|
|
||||||
{{% /capture %}}
|
{{% /capture %}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue