-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
163 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
+++ | ||
title = "Docker 手动迁移镜像" | ||
date = 2017-02-02 | ||
[taxonomies] | ||
tags=["docker"] | ||
+++ | ||
使用公共或者私有的 Registry 可以方便的将 Docker 镜像进行转移,在某些场景可能期望手动来迁移镜像。 | ||
|
||
此时可以使用 `docker save` 和 `docker load` 指令将镜像打包然后在其它位置加载回来。这里使用 nginx 镜像来做演示,将镜像从一台机器手动迁移到另一台机器。 | ||
<!--more--> | ||
### 打包镜像 | ||
```bash | ||
docker save -o nginx.tar nginx:latest | ||
``` | ||
然后 `nginx:latest` 镜像被打包为 `nginx.tar` 文件,此时可以通过 scp 之类的方法传输这个镜像文件。 | ||
|
||
> 在打包过程中可以使用类似 `docker save nginx | gzip > nginx.tar.gz` 的命令进行压缩减小文件体积。 | ||
更多参数请参考 [官方文档](https://docs.docker.com/engine/reference/commandline/save/) 对此命令的说明。 | ||
|
||
### 加载镜像 | ||
在另一台没有 `nginx:latest` 镜像的机器上执行: | ||
```bash | ||
docker load -i nginx.tar | ||
# 下面为命令输出 | ||
3358360aedad: Loading layer [==================================================>] 58.44MB/58.44MB | ||
c632afbadb38: Loading layer [==================================================>] 53.91MB/53.91MB | ||
180ab8f004dc: Loading layer [==================================================>] 3.584kB/3.584kB | ||
``` | ||
执行完成后 `nginx:latest` 镜像就被手动迁移到了另一台机器上。 | ||
|
||
更多参数请参考 [官方文档](https://docs.docker.com/engine/reference/commandline/load/) 对此命令的说明。 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
+++ | ||
title = "Istio 中配置 Envoy 获取 Client 真实 IP" | ||
date = 2019-03-22 | ||
[taxonomies] | ||
tags=["istio", "kubernetes"] | ||
+++ | ||
背景:使用 Istio Ingress Gateway(Envoy),需要获取客户端真实 IP 地址 | ||
|
||
使用 Helm 安装 Istio 会安装一个名为 `istio-ingressgateway` 的 Service,类型为 `LoadBalancer`,可以将服务暴露到公网。 | ||
|
||
这个 Service 的 `spec.externalTrafficPolicy` 默认值是 `Cluster`,我们只要将这个值更新为`Local`,就可以在 `X-Forwarded-For` 请求头获取到客户端真实 IP 地址了。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
+++ | ||
title = "Kubernetes 从私有镜像仓库拉取镜像" | ||
date = 2019-01-11 | ||
[taxonomies] | ||
tags=["kubernetes"] | ||
+++ | ||
在企业内部使用 private registry 来存储私有镜像显然是必需的,本例的私仓使用 [Harbor](https://github.com/goharbor/harbor),下面来看看在 Kubernetes 集群中怎么配置使用我们建立的私有镜像仓库。假设私有镜像仓库地址为:`https://hub.xring.info`,我们要用的镜像为 nginx:v0.1.0,存在仓库 mynginx 中。如果使用 docker pull 来拉取镜像则命令为: | ||
``` | ||
docker pull hub.xring.info/mynginx/nginx:v0.1.0 | ||
``` | ||
为了在 Kubernetes 中使用私有镜像仓库,我们需要做两个事: | ||
- 创建一个存储了私有镜像 credential 信息的 Secret 资源对象 | ||
- 在 Pod 创建模板使用 spec.imagePullSecrets 中指定创建的 Secret 对象 | ||
<!--more--> | ||
|
||
### 创建 Secret 资源对象 | ||
``` | ||
kubectl create secret docker-registry my-hub-secret --docker-server=hub.xring.info --docker-username=xbot --docker-password=123456 [email protected] | ||
``` | ||
|
||
### 指定 Secret 对象 | ||
以下面的 Pod 资源定义为例: | ||
```yml | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx-v010 | ||
labels: | ||
app: nginx-v010 | ||
spec: | ||
imagePullSecrets: | ||
- name: my-hub-secret | ||
containers: | ||
- image: hub.xring.info/mynginx/nginx:v0.1.0 | ||
name: nginx-v010 | ||
``` | ||
然后再使用 `kubectl apply -f mynginx.yaml` 来创建 Pod 对象,就可以从私有镜像仓库中拉取镜像了。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
+++ | ||
title = "Maven 设置 HTTP 代理" | ||
date = 2017-02-10 | ||
[taxonomies] | ||
tags=["maven", "java"] | ||
+++ | ||
有时候基于公司安全因素考虑或者由于一些特殊原因,Maven 无法正常访问外部仓库来下载所需要的资源。这种情况下,可以通过为 Maven 配置 HTTP 代理来解决问题。 | ||
|
||
通过以下步骤来为 Maven 配置 HTTP 代理: | ||
``` | ||
- 获取 HTTP 代理信息 | ||
- 找到 Maven 配置文件 settings.xml | ||
- 将代理信息添加到配置文件 | ||
``` | ||
假设我们有如下 HTTP 代理信息: | ||
``` | ||
host: 9.30.123.123 | ||
port: 3712 | ||
username: xring | ||
password: volcano | ||
``` | ||
下一步来寻找 Maven 配置文件。`settimgs.xml` 文件可能存在于两个位置: | ||
– ~/.m2/settings.xml | ||
– M2_HOME/conf/settings.xml | ||
|
||
如果 `~/.m2/settings.xml` 文件存在,则 `优先` 使用这个文件进行配置,如果不存在则需要使用 `M2_HOME/conf/settings.xml` 文件。如果没有配置 `M2_HOME` 这个环境变量或者忘记了 Maven 的安装位置,可以通过 `mvn -version` 可以找到 Maven home 目录,即上面提到的 `M2_HOME`,在 Mac 下得到类似输出: | ||
```bash | ||
mvn -version | ||
... | ||
Maven home: /usr/local/Cellar/maven/3.3.9/libexec | ||
... | ||
``` | ||
则 `settimgs.xml` 文件就在 `/usr/local/Cellar/maven/3.3.9/libexec/conf` 目录中。 | ||
|
||
编辑找到的 settings.xml 文件,搜索 proxies 关键字,找到类似下面的这一段: | ||
```xml | ||
<proxies> | ||
<!-- proxy | ||
| Specification for one proxy, to be used in connecting to the network. | ||
| | ||
<proxy> | ||
<id>optional</id> | ||
<active>true</active> | ||
<protocol>http</protocol> | ||
<username>proxyuser</username> | ||
<password>proxypass</password> | ||
<host>proxy.host.net</host> | ||
<port>80</port> | ||
<nonProxyHosts>local.net|some.host.com</nonProxyHosts> | ||
</proxy> | ||
--> | ||
</proxies> | ||
``` | ||
在 proxies 下可以配置多个 proxy 元素,如果声明了多个 proxy 元素,则默认情况下第一个被激活的 proxy 元素会被使用。 | ||
当 proxy 元素里的 active 被设置为 true 时表示该 proxy 处于激活状态。 | ||
id 字段是 proxy 元素的一个标识 | ||
当代理不需要认证时,username 和 password 可以被注释掉 | ||
nonProxyHost 元素用来指定哪些主机名不需要代理,当有多个主机名不需要代理时用 | 来分隔主机名,主机名里支持通配符(如 *.google.com)。 | ||
|
||
了解了这段 XML 各元素的意义后将得到的 HTTP 代理信息依次填入相应元素: | ||
```xml | ||
<proxies> | ||
<proxy> | ||
<id>volcano-proxy</id> | ||
<active>true</active> | ||
<protocol>http</protocol> | ||
<username>xring</username> | ||
<password>volcano</password> | ||
<host>9.30.123.123</host> | ||
<port>3712</port> | ||
<!-- | ||
<nonProxyHosts>local.net|some.host.com</nonProxyHosts> | ||
--> | ||
</proxy> | ||
</proxies> | ||
``` | ||
保存 `settings.xml` 配置文件,Maven 配置 HTTP 代理完成。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
+++ | ||
title = "About Me" | ||
title = "About" | ||
path = "about" | ||
+++ | ||
|
||
|
@@ -20,5 +20,7 @@ path = "about" | |
- 基础设施架构、后端架构 | ||
|
||
## 联系 | ||
- E-mail: [email protected] | ||
- WeChat: xringxie | ||
- E-mail: [email protected] | ||
- WeChat: xringxie | ||
- GitHub: xring | ||
- Twitter: @xringxie |
This file was deleted.
Oops, something went wrong.