@@ -16,7 +16,7 @@ weight: 230
16
16
<!--
17
17
What's Kompose? It's a conversion tool for all things compose (namely Docker Compose) to container orchestrators (Kubernetes or OpenShift).
18
18
-->
19
- Kompose 是什么?它是一个转换工具,可将 compose
19
+ Kompose 是什么?它是一个转换工具,可将 Compose
20
20
(即 Docker Compose)所组装的所有内容转换成容器编排器(Kubernetes 或 OpenShift)可识别的形式。
21
21
22
22
<!--
@@ -50,13 +50,13 @@ Kompose 通过 GitHub 发布,发布周期为三星期。
50
50
51
51
``` shell
52
52
# 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
54
54
55
55
# 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
57
57
58
58
# 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
60
60
61
61
chmod +x kompose
62
62
sudo mv ./kompose /usr/local/bin/kompose
@@ -145,26 +145,26 @@ you need is an existing `docker-compose.yml` file.
145
145
1 . 进入 ` docker-compose.yml ` 文件所在的目录。如果没有,请使用下面这个进行测试。
146
146
147
147
``` yaml
148
- version : " 2"
149
-
150
148
services :
151
149
152
- redis-master :
153
- image : registry.k8s.io/redis:e2e
150
+ redis-leader :
151
+ container_name : redis-leader
152
+ image : redis
154
153
ports :
155
154
- " 6379"
156
155
157
- redis-slave :
158
- image : gcr.io/google_samples/gb-redisslave:v3
156
+ redis-replica :
157
+ container_name : redis-replica
158
+ image : redis
159
159
ports :
160
160
- " 6379"
161
- environment :
162
- - GET_HOSTS_FROM=dns
161
+ command : redis-server --replicaof redis-leader 6379 --dir /tmp
163
162
164
- frontend :
165
- image : gcr.io/google-samples/gb-frontend:v4
163
+ web :
164
+ container_name : web
165
+ image : quay.io/kompose/web
166
166
ports :
167
- - " 80:80 "
167
+ - " 8080:8080 "
168
168
environment :
169
169
- GET_HOSTS_FROM=dns
170
170
labels :
@@ -188,16 +188,16 @@ you need is an existing `docker-compose.yml` file.
188
188
输出类似于:
189
189
190
190
` ` ` 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
197
197
` ` `
198
198
199
199
` ` ` 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
201
201
` ` `
202
202
203
203
<!--
@@ -206,12 +206,12 @@ you need is an existing `docker-compose.yml` file.
206
206
输出类似于:
207
207
208
208
` ` ` 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
215
215
` ` `
216
216
217
217
<!--
@@ -231,7 +231,7 @@ you need is an existing `docker-compose.yml` file.
231
231
如果你在开发过程中使用 `minikube`,请执行:
232
232
233
233
` ` ` bash
234
- minikube service frontend
234
+ minikube service web-tcp
235
235
` ` `
236
236
237
237
<!--
@@ -240,33 +240,29 @@ you need is an existing `docker-compose.yml` file.
240
240
否则,我们要查看一下你的服务使用了什么 IP!
241
241
242
242
` ` ` sh
243
- kubectl describe svc frontend
243
+ kubectl describe svc web-tcp
244
244
` ` `
245
245
246
246
` ` ` none
247
- Name: frontend -tcp
247
+ Name: web -tcp
248
248
Namespace: default
249
- Labels: io.kompose.service=frontend -tcp
249
+ Labels: io.kompose.service=web -tcp
250
250
Annotations: kompose.cmd: kompose convert
251
251
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
254
254
Type: LoadBalancer
255
255
IP Family Policy: SingleStack
256
256
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
263
263
Session Affinity: None
264
264
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>
270
266
` ` `
271
267
272
268
<!--
@@ -290,7 +286,7 @@ you need is an existing `docker-compose.yml` file.
290
286
你完成示例应用 Deployment 的测试之后,只需在 Shell 中运行以下命令,就能删除用过的资源。
291
287
292
288
` ` ` 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
294
290
` ` `
295
291
296
292
<!-- discussion -->
@@ -435,7 +431,7 @@ INFO OpenShift file "result-imagestream.yaml" created
435
431
<!--
436
432
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.
437
433
-->
438
- kompose 还支持为服务中的构建指令创建 buildconfig。
434
+ Kompose 还支持为服务中的构建指令创建 buildconfig。
439
435
默认情况下,它使用当前 git 分支的 remote 仓库作为源仓库,使用当前分支作为构建的源分支。
440
436
你可以分别使用 ``--build-repo`` 和 ``--build-branch`` 选项指定不同的源仓库和分支。
441
437
@@ -470,7 +466,7 @@ The default `kompose` transformation will generate Kubernetes [Deployments](/doc
470
466
[Deployment](/zh-cn/docs/concepts/workloads/controllers/deployment/) 和
471
467
[Service](/zh-cn/docs/concepts/services-networking/service/) 对象。
472
468
你可以选择通过 `-j` 参数生成 json 格式的对象。
473
- 你也可以替换生成 [Replication Controllers ](/zh-cn/docs/concepts/workloads/controllers/replicationcontroller/) 对象、
469
+ 你也可以替换生成 [ReplicationController ](/zh-cn/docs/concepts/workloads/controllers/replicationcontroller/) 对象、
474
470
[DaemonSet](/zh-cn/docs/concepts/workloads/controllers/daemonset/) 或
475
471
[Helm](https://github.com/helm/helm) Chart。
476
472
@@ -504,7 +500,7 @@ INFO Kubernetes file "web-replicationcontroller.yaml" created
504
500
<!--
505
501
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` .
506
502
-->
507
- ` *-replicationcontroller.yaml` 文件包含 Replication Controller 对象。
503
+ ` *-replicationcontroller.yaml` 文件包含 ReplicationController 对象。
508
504
如果你想指定副本数(默认为 1),可以使用 `--replicas` 参数:
509
505
` kompose convert --replication-controller --replicas 3`
510
506
@@ -559,7 +555,7 @@ docker-compose
559
555
<!--
560
556
The chart structure is aimed at providing a skeleton for building your Helm charts.
561
557
-->
562
- 这个 Chart 结构旨在为构建 Helm Chart 提供框架 。
558
+ 这个 Chart 结构旨在为构建 Helm Chart 时提供框架 。
563
559
564
560
<!--
565
561
# # Labels
@@ -604,7 +600,7 @@ For example:
604
600
如果在 Service 中定义了多个端口,则选择第一个端口作为公开端口。
605
601
606
602
- 如果使用 Kubernetes 驱动,会有一个 Ingress 资源被创建,并且假定已经配置了相应的 Ingress 控制器。
607
- - 如果使用 OpenShift 驱动,则会有一个 route 被创建。
603
+ - 如果使用 OpenShift 驱动,则会有一个 Route 被创建。
608
604
609
605
例如:
610
606
@@ -633,7 +629,7 @@ The currently supported options are:
633
629
| kompose.service.type | nodeport / clusterip / loadbalancer |
634
630
| kompose.service.expose| true / hostname |
635
631
-->
636
- 当前支持的选项有 :
632
+ 当前支持的选项有:
637
633
638
634
| 键 | 值 |
639
635
|------------------------|-------------------------------------|
@@ -665,7 +661,6 @@ If you want to create normal pods without controllers you can use `restart` cons
665
661
| `on-failure` | Pod | `OnFailure` |
666
662
| `no` | Pod | `Never` |
667
663
-->
668
-
669
664
| `docker-compose` `restart` | 创建的对象 | Pod `restartPolicy` |
670
665
|----------------------------|-------------------|---------------------|
671
666
| `""` | 控制器对象 | `Always` |
0 commit comments