mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-08-10 16:37:34 +00:00
fix(content): harden dashboard and etcd examples
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
Dashboard 7.0+ 版本仅支持通过 Helm 安装:
|
Dashboard 7.0+ 版本仅支持通过 Helm 安装:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
|
$ helm repo add kubernetes-dashboard https://kubernetes-retired.github.io/dashboard/
|
||||||
|
|
||||||
$ helm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard \
|
$ helm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard \
|
||||||
--create-namespace --namespace kubernetes-dashboard
|
--create-namespace --namespace kubernetes-dashboard
|
||||||
|
|||||||
@@ -59,14 +59,14 @@ hello world
|
|||||||
|
|
||||||
### 15.2.2 Docker 镜像方式运行
|
### 15.2.2 Docker 镜像方式运行
|
||||||
|
|
||||||
镜像名称为 `quay.io/coreos/etcd`,可以通过下面的命令启动 `etcd` 服务监听到 `2379` 和 `2380` 端口。
|
镜像名称为 `quay.io/coreos/etcd`,可以通过下面的命令启动单机实验用 `etcd` 服务,并只把 `2379` 和 `2380` 映射到宿主机回环地址。
|
||||||
|
|
||||||
> **版本说明:** 示例中使用 `v3.5.29` 标签。请访问 [etcd 官方发布页](https://github.com/etcd-io/etcd/releases) 获取最新可用版本标签。
|
> **版本说明:** 示例中使用 `v3.5.29` 标签。请访问 [etcd 官方发布页](https://github.com/etcd-io/etcd/releases) 获取最新可用版本标签。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ docker run \
|
$ docker run \
|
||||||
-p 2379:2379 \
|
-p 127.0.0.1:2379:2379 \
|
||||||
-p 2380:2380 \
|
-p 127.0.0.1:2380:2380 \
|
||||||
--mount type=bind,source=/tmp/etcd-data.tmp,destination=/etcd-data \
|
--mount type=bind,source=/tmp/etcd-data.tmp,destination=/etcd-data \
|
||||||
--name etcd-gcr-v3.5.29 \
|
--name etcd-gcr-v3.5.29 \
|
||||||
quay.io/coreos/etcd:v3.5.29 \
|
quay.io/coreos/etcd:v3.5.29 \
|
||||||
@@ -74,10 +74,10 @@ quay.io/coreos/etcd:v3.5.29 \
|
|||||||
--name s1 \
|
--name s1 \
|
||||||
--data-dir /etcd-data \
|
--data-dir /etcd-data \
|
||||||
--listen-client-urls http://0.0.0.0:2379 \
|
--listen-client-urls http://0.0.0.0:2379 \
|
||||||
--advertise-client-urls http://<HOST_IP>:2379 \
|
--advertise-client-urls http://127.0.0.1:2379 \
|
||||||
--listen-peer-urls http://0.0.0.0:2380 \
|
--listen-peer-urls http://0.0.0.0:2380 \
|
||||||
--initial-advertise-peer-urls http://<HOST_IP>:2380 \
|
--initial-advertise-peer-urls http://127.0.0.1:2380 \
|
||||||
--initial-cluster s1=http://<HOST_IP>:2380 \
|
--initial-cluster s1=http://127.0.0.1:2380 \
|
||||||
--initial-cluster-token tkn \
|
--initial-cluster-token tkn \
|
||||||
--initial-cluster-state new \
|
--initial-cluster-state new \
|
||||||
--log-level info \
|
--log-level info \
|
||||||
@@ -85,7 +85,7 @@ quay.io/coreos/etcd:v3.5.29 \
|
|||||||
--log-outputs stderr
|
--log-outputs stderr
|
||||||
```
|
```
|
||||||
|
|
||||||
其中 `listen-*` 可以绑定 `0.0.0.0` 监听所有网卡,但 `advertise-*` 应填写其他节点或客户端**实际可访问的主机地址**,不能直接写成 `0.0.0.0`。
|
上面示例仅用于单机实验:宿主机端口限定在 `127.0.0.1`,因此不会把未启用 TLS 的 etcd 直接暴露到外部网络。容器内部的 `listen-*` 可以绑定 `0.0.0.0` 监听容器网卡,但 `advertise-*` 应填写其他节点或客户端**实际可访问的主机地址**,不能直接写成 `0.0.0.0`。生产或多节点环境不要使用明文 HTTP 暴露 etcd,应结合固定内网地址、TLS、客户端证书认证和防火墙访问控制。
|
||||||
|
|
||||||
打开新的终端按照上一步的方法测试 `etcd` 是否成功启动。
|
打开新的终端按照上一步的方法测试 `etcd` 是否成功启动。
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user