<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # Pause容器 Pause容器,又叫Infra容器,本文將探究該容器的作用與原理。 我們知道在kubelet的配置中有這樣一個參數: ```bash KUBELET_POD_INFRA_CONTAINER=--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest ``` 上面是openshift中的配置參數,kubernetes中默認的配置參數是: ```bash KUBELET_POD_INFRA_CONTAINER=--pod-infra-container-image=gcr.io/google_containers/pause-amd64:3.0 ``` Pause容器,是可以自己來定義,官方使用的`gcr.io/google_containers/pause-amd64:3.0`容器的代碼見[Github](https://github.com/kubernetes/kubernetes/tree/master/build/pause),使用C語言編寫。 ## Pause容器的作用 我們檢查node節點的時候會發現每個node上都運行了很多的pause容器,例如如下。 ```bash $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2c7d50f1a7be docker.io/jimmysong/heapster-grafana-amd64@sha256:d663759b3de86cf62e64a43b021f133c383e8f7b0dc2bdd78115bc95db371c9a "/run.sh" 3 hours ago Up 3 hours k8s_grafana_monitoring-influxdb-grafana-v4-5697c6b59-76zqs_kube-system_5788a3c5-29c0-11e8-9e88-525400005732_0 5df93dea877a docker.io/jimmysong/heapster-influxdb-amd64@sha256:a217008b68cb49e8f038c4eeb6029261f02adca81d8eae8c5c01d030361274b8 "influxd --config ..." 3 hours ago Up 3 hours k8s_influxdb_monitoring-influxdb-grafana-v4-5697c6b59-76zqs_kube-system_5788a3c5-29c0-11e8-9e88-525400005732_0 9cec6c0ef583 jimmysong/pause-amd64:3.0 "/pause" 3 hours ago Up 3 hours k8s_POD_monitoring-influxdb-grafana-v4-5697c6b59-76zqs_kube-system_5788a3c5-29c0-11e8-9e88-525400005732_0 54d06e30a4c7 docker.io/jimmysong/kubernetes-dashboard-amd64@sha256:668710d034c4209f8fa9a342db6d8be72b6cb5f1f3f696cee2379b8512330be4 "/dashboard --inse..." 3 hours ago Up 3 hours k8s_kubernetes-dashboard_kubernetes-dashboard-65486f5fdf-lshl7_kube-system_27c414a1-29c0-11e8-9e88-525400005732_0 5a5ef33b0d58 jimmysong/pause-amd64:3.0 "/pause" 3 hours ago Up 3 hours k8s_POD_kubernetes-dashboard-65486f5fdf-lshl7_kube-system_27c414a1-29c0-11e8-9e88-525400005732_0 ``` kubernetes中的pause容器主要為每個業務容器提供以下功能: - 在pod中擔任Linux命名空間共享的基礎; - 啟用pid命名空間,開啟init進程。 在[The Almighty Pause Container](https://www.ianlewis.org/en/almighty-pause-container)這篇文章中做出了詳細的說明,pause容器的作用可以從這個例子中看出,首先見下圖: ![Pause容器](https://box.kancloud.cn/4f248fe1035f0f21f14cb5a843a4eed6_1598x948.png) 我們首先在節點上運行一個pause容器。 ```bash docker run -d --name pause -p 8880:80 jimmysong/pause-amd64:3.0 ``` 然后再運行一個nginx容器,nginx將為`localhost:2368`創建一個代理。 ```bash $ cat <<EOF >> nginx.conff error_log stderr; events { worker_connections 1024; } http { access_log /dev/stdout combined; server { listen 80 default_server; server_name example.com www.example.com; location / { proxy_pass http://127.0.0.1:2368; } } } EOF $ docker run -d --name nginx -v `pwd`/nginx.conf:/etc/nginx/nginx.conf --net=container:pause --ipc=container:pause --pid=container:pause nginx ``` 然后再為[ghost](https://github.com/TryGhost/Ghost)創建一個應用容器,這是一款博客軟件。 ```bash $ docker run -d --name ghost --net=container:pause --ipc=container:pause --pid=container:pause ghost ``` 現在訪問<http://localhost:8880/>就可以看到ghost博客的界面了。 **解析** pause容器將內部的80端口映射到宿主機的8880端口,pause容器在宿主機上設置好了網絡namespace后,nginx容器加入到該網絡namespace中,我們看到nginx容器啟動的時候指定了`--net=container:pause`,ghost容器同樣加入到了該網絡namespace中,這樣三個容器就共享了網絡,互相之間就可以使用`localhost`直接通信,`--ipc=contianer:pause --pid=container:pause`就是三個容器處于同一個namespace中,init進程為`pause`,這時我們進入到ghost容器中查看進程情況。 ```bash # ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 1024 4 ? Ss 13:49 0:00 /pause root 5 0.0 0.1 32432 5736 ? Ss 13:51 0:00 nginx: master p systemd+ 9 0.0 0.0 32980 3304 ? S 13:51 0:00 nginx: worker p node 10 0.3 2.0 1254200 83788 ? Ssl 13:53 0:03 node current/in root 79 0.1 0.0 4336 812 pts/0 Ss 14:09 0:00 sh root 87 0.0 0.0 17500 2080 pts/0 R+ 14:10 0:00 ps aux ``` 在ghost容器中同時可以看到pause和nginx容器的進程,并且pause容器的PID是1。而在kubernetes中容器的PID=1的進程即為容器本身的業務進程。 ## 參考 - [The Almighty Pause Container](https://www.ianlewis.org/en/almighty-pause-container) - [Kubernetes之Pause容器](https://o-my-chenjian.com/2017/10/17/The-Pause-Container-Of-Kubernetes/)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看