Skip to content

Commit 2d90bc7

Browse files
authored
Merge pull request #46998 from my-git9/pc-2218
[zh-cn] Sync translate-compose-kubernetes
2 parents f29f4a5 + 03baff1 commit 2d90bc7

File tree

1 file changed

+48
-53
lines changed

1 file changed

+48
-53
lines changed

content/zh-cn/docs/tasks/configure-pod-container/translate-compose-kubernetes.md

Lines changed: 48 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ weight: 230
1616
<!--
1717
What's Kompose? It's a conversion tool for all things compose (namely Docker Compose) to container orchestrators (Kubernetes or OpenShift).
1818
-->
19-
Kompose 是什么?它是一个转换工具,可将 compose
19+
Kompose 是什么?它是一个转换工具,可将 Compose
2020
(即 Docker Compose)所组装的所有内容转换成容器编排器(Kubernetes 或 OpenShift)可识别的形式。
2121

2222
<!--
@@ -50,13 +50,13 @@ Kompose 通过 GitHub 发布,发布周期为三星期。
5050

5151
```shell
5252
# Linux
53-
curl -L https://github.com/kubernetes/kompose/releases/download/v1.26.0/kompose-linux-amd64 -o kompose
53+
curl -L https://github.com/kubernetes/kompose/releases/download/v1.34.0/kompose-linux-amd64 -o kompose
5454

5555
# macOS
56-
curl -L https://github.com/kubernetes/kompose/releases/download/v1.26.0/kompose-darwin-amd64 -o kompose
56+
curl -L https://github.com/kubernetes/kompose/releases/download/v1.34.0/kompose-darwin-amd64 -o kompose
5757

5858
# Windows
59-
curl -L https://github.com/kubernetes/kompose/releases/download/v1.26.0/kompose-windows-amd64.exe -o kompose.exe
59+
curl -L https://github.com/kubernetes/kompose/releases/download/v1.34.0/kompose-windows-amd64.exe -o kompose.exe
6060

6161
chmod +x kompose
6262
sudo mv ./kompose /usr/local/bin/kompose
@@ -145,26 +145,26 @@ you need is an existing `docker-compose.yml` file.
145145
1. 进入 `docker-compose.yml` 文件所在的目录。如果没有,请使用下面这个进行测试。
146146

147147
```yaml
148-
version: "2"
149-
150148
services:
151149

152-
redis-master:
153-
image: registry.k8s.io/redis:e2e
150+
redis-leader:
151+
container_name: redis-leader
152+
image: redis
154153
ports:
155154
- "6379"
156155

157-
redis-slave:
158-
image: gcr.io/google_samples/gb-redisslave:v3
156+
redis-replica:
157+
container_name: redis-replica
158+
image: redis
159159
ports:
160160
- "6379"
161-
environment:
162-
- GET_HOSTS_FROM=dns
161+
command: redis-server --replicaof redis-leader 6379 --dir /tmp
163162

164-
frontend:
165-
image: gcr.io/google-samples/gb-frontend:v4
163+
web:
164+
container_name: web
165+
image: quay.io/kompose/web
166166
ports:
167-
- "80:80"
167+
- "8080:8080"
168168
environment:
169169
- GET_HOSTS_FROM=dns
170170
labels:
@@ -188,16 +188,16 @@ you need is an existing `docker-compose.yml` file.
188188
输出类似于:
189189

190190
```none
191-
INFO Kubernetes file "frontend-tcp-service.yaml" created
192-
INFO Kubernetes file "redis-master-service.yaml" created
193-
INFO Kubernetes file "redis-slave-service.yaml" created
194-
INFO Kubernetes file "frontend-deployment.yaml" created
195-
INFO Kubernetes file "redis-master-deployment.yaml" created
196-
INFO Kubernetes file "redis-slave-deployment.yaml" created
191+
INFO Kubernetes file "redis-leader-service.yaml" created
192+
INFO Kubernetes file "redis-replica-service.yaml" created
193+
INFO Kubernetes file "web-tcp-service.yaml" created
194+
INFO Kubernetes file "redis-leader-deployment.yaml" created
195+
INFO Kubernetes file "redis-replica-deployment.yaml" created
196+
INFO Kubernetes file "web-deployment.yaml" created
197197
```
198198

199199
```bash
200-
kubectl apply -f frontend-tcp-service.yaml,redis-master-service.yaml,redis-slave-service.yaml,frontend-deployment.yaml,redis-master-deployment.yaml,redis-slave-deployment.yaml
200+
kubectl apply -f web-tcp-service.yaml,redis-leader-service.yaml,redis-replica-service.yaml,web-deployment.yaml,redis-leader-deployment.yaml,redis-replica-deployment.yaml
201201
```
202202

203203
<!--
@@ -206,12 +206,12 @@ you need is an existing `docker-compose.yml` file.
206206
输出类似于:
207207

208208
```none
209-
service/frontend-tcp created
210-
service/redis-master created
211-
service/redis-slave created
212-
deployment.apps/frontend created
213-
deployment.apps/redis-master created
214-
deployment.apps/redis-slave created
209+
deployment.apps/redis-leader created
210+
deployment.apps/redis-replica created
211+
deployment.apps/web created
212+
service/redis-leader created
213+
service/redis-replica created
214+
service/web-tcp created
215215
```
216216

217217
<!--
@@ -231,7 +231,7 @@ you need is an existing `docker-compose.yml` file.
231231
如果你在开发过程中使用 `minikube`,请执行:
232232

233233
```bash
234-
minikube service frontend
234+
minikube service web-tcp
235235
```
236236

237237
<!--
@@ -240,33 +240,29 @@ you need is an existing `docker-compose.yml` file.
240240
否则,我们要查看一下你的服务使用了什么 IP!
241241

242242
```sh
243-
kubectl describe svc frontend
243+
kubectl describe svc web-tcp
244244
```
245245

246246
```none
247-
Name: frontend-tcp
247+
Name: web-tcp
248248
Namespace: default
249-
Labels: io.kompose.service=frontend-tcp
249+
Labels: io.kompose.service=web-tcp
250250
Annotations: kompose.cmd: kompose convert
251251
kompose.service.type: LoadBalancer
252-
kompose.version: 1.26.0 (40646f47)
253-
Selector: io.kompose.service=frontend
252+
kompose.version: 1.33.0 (3ce457399)
253+
Selector: io.kompose.service=web
254254
Type: LoadBalancer
255255
IP Family Policy: SingleStack
256256
IP Families: IPv4
257-
IP: 10.43.67.174
258-
IPs: 10.43.67.174
259-
Port: 80 80/TCP
260-
TargetPort: 80/TCP
261-
NodePort: 80 31254/TCP
262-
Endpoints: 10.42.0.25:80
257+
IP: 10.102.30.3
258+
IPs: 10.102.30.3
259+
Port: 8080 8080/TCP
260+
TargetPort: 8080/TCP
261+
NodePort: 8080 31624/TCP
262+
Endpoints: 10.244.0.5:8080
263263
Session Affinity: None
264264
External Traffic Policy: Cluster
265-
Events:
266-
Type Reason Age From Message
267-
---- ------ ---- ---- -------
268-
Normal EnsuringLoadBalancer 62s service-controller Ensuring load balancer
269-
Normal AppliedDaemonSet 62s service-controller Applied LoadBalancer DaemonSet kube-system/svclb-frontend-tcp-9362d276
265+
Events: <none>
270266
```
271267

272268
<!--
@@ -290,7 +286,7 @@ you need is an existing `docker-compose.yml` file.
290286
你完成示例应用 Deployment 的测试之后,只需在 Shell 中运行以下命令,就能删除用过的资源。
291287

292288
```sh
293-
kubectl delete -f frontend-tcp-service.yaml,redis-master-service.yaml,redis-slave-service.yaml,frontend-deployment.yaml,redis-master-deployment.yaml,redis-slave-deployment.yaml
289+
kubectl delete -f web-tcp-service.yaml,redis-leader-service.yaml,redis-replica-service.yaml,web-deployment.yaml,redis-leader-deployment.yaml,redis-replica-deployment.yaml
294290
```
295291

296292
<!-- discussion -->
@@ -435,7 +431,7 @@ INFO OpenShift file "result-imagestream.yaml" created
435431
<!--
436432
It also supports creating buildconfig for build directive in a service. By default, it uses the remote repo for the current git branch as the source repo, and the current branch as the source branch for the build. You can specify a different source repo and branch using ``--build-repo`` and ``--build-branch`` options respectively.
437433
-->
438-
kompose 还支持为服务中的构建指令创建 buildconfig。
434+
Kompose 还支持为服务中的构建指令创建 buildconfig。
439435
默认情况下,它使用当前 git 分支的 remote 仓库作为源仓库,使用当前分支作为构建的源分支。
440436
你可以分别使用 ``--build-repo`` 和 ``--build-branch`` 选项指定不同的源仓库和分支。
441437

@@ -470,7 +466,7 @@ The default `kompose` transformation will generate Kubernetes [Deployments](/doc
470466
[Deployment](/zh-cn/docs/concepts/workloads/controllers/deployment/) 和
471467
[Service](/zh-cn/docs/concepts/services-networking/service/) 对象。
472468
你可以选择通过 `-j` 参数生成 json 格式的对象。
473-
你也可以替换生成 [Replication Controllers](/zh-cn/docs/concepts/workloads/controllers/replicationcontroller/) 对象、
469+
你也可以替换生成 [ReplicationController](/zh-cn/docs/concepts/workloads/controllers/replicationcontroller/) 对象、
474470
[DaemonSet](/zh-cn/docs/concepts/workloads/controllers/daemonset/) 或
475471
[Helm](https://github.com/helm/helm) Chart。
476472

@@ -504,7 +500,7 @@ INFO Kubernetes file "web-replicationcontroller.yaml" created
504500
<!--
505501
The `*-replicationcontroller.yaml` files contain the Replication Controller objects. If you want to specify replicas (default is 1), use `--replicas` flag: `kompose convert --replication-controller --replicas 3`.
506502
-->
507-
`*-replicationcontroller.yaml` 文件包含 Replication Controller 对象。
503+
`*-replicationcontroller.yaml` 文件包含 ReplicationController 对象。
508504
如果你想指定副本数(默认为 1),可以使用 `--replicas` 参数:
509505
`kompose convert --replication-controller --replicas 3`
510506

@@ -559,7 +555,7 @@ docker-compose
559555
<!--
560556
The chart structure is aimed at providing a skeleton for building your Helm charts.
561557
-->
562-
这个 Chart 结构旨在为构建 Helm Chart 提供框架
558+
这个 Chart 结构旨在为构建 Helm Chart 时提供框架
563559

564560
<!--
565561
## Labels
@@ -604,7 +600,7 @@ For example:
604600
如果在 Service 中定义了多个端口,则选择第一个端口作为公开端口。
605601

606602
- 如果使用 Kubernetes 驱动,会有一个 Ingress 资源被创建,并且假定已经配置了相应的 Ingress 控制器。
607-
- 如果使用 OpenShift 驱动,则会有一个 route 被创建。
603+
- 如果使用 OpenShift 驱动,则会有一个 Route 被创建。
608604

609605
例如:
610606

@@ -633,7 +629,7 @@ The currently supported options are:
633629
| kompose.service.type | nodeport / clusterip / loadbalancer |
634630
| kompose.service.expose| true / hostname |
635631
-->
636-
当前支持的选项有:
632+
当前支持的选项有
637633

638634
| 键 | 值 |
639635
|------------------------|-------------------------------------|
@@ -665,7 +661,6 @@ If you want to create normal pods without controllers you can use `restart` cons
665661
| `on-failure` | Pod | `OnFailure` |
666662
| `no` | Pod | `Never` |
667663
-->
668-
669664
| `docker-compose` `restart` | 创建的对象 | Pod `restartPolicy` |
670665
|----------------------------|-------------------|---------------------|
671666
| `""` | 控制器对象 | `Always` |

0 commit comments

Comments
 (0)