Merge pull request #26529 from tengqm/zh-resync-kompose
[zh] Resync translate-compose-kubernetes task
This commit is contained in:
commit
ebb3d6a14d
|
|
@ -40,26 +40,25 @@ We have multiple ways to install Kompose. Our preferred method is downloading th
|
|||
|
||||
我们有很多种方式安装 Kompose。首选方式是从最新的 GitHub 发布页面下载二进制文件。
|
||||
|
||||
<!--
|
||||
## GitHub release
|
||||
{{< tabs name="install_ways" >}}
|
||||
{{% tab name="GitHub 下载" %}}
|
||||
|
||||
<!--
|
||||
Kompose is released via GitHub on a three-week cycle, you can see all current releases on the [GitHub release page](https://github.com/kubernetes/kompose/releases).
|
||||
-->
|
||||
## GitHub 发布版本
|
||||
|
||||
Kompose 通过 GitHub 发布版本,发布周期为三星期。
|
||||
Kompose 通过 GitHub 发布,发布周期为三星期。
|
||||
你可以在 [GitHub 发布页面](https://github.com/kubernetes/kompose/releases)
|
||||
上看到所有当前版本。
|
||||
|
||||
```shell
|
||||
# Linux
|
||||
curl -L https://github.com/kubernetes/kompose/releases/download/v1.16.0/kompose-linux-amd64 -o kompose
|
||||
curl -L https://github.com/kubernetes/kompose/releases/download/v1.22.0/kompose-linux-amd64 -o kompose
|
||||
|
||||
# macOS
|
||||
curl -L https://github.com/kubernetes/kompose/releases/download/v1.16.0/kompose-darwin-amd64 -o kompose
|
||||
curl -L https://github.com/kubernetes/kompose/releases/download/v1.22.0/kompose-darwin-amd64 -o kompose
|
||||
|
||||
# Windows
|
||||
curl -L https://github.com/kubernetes/kompose/releases/download/v1.16.0/kompose-windows-amd64.exe -o kompose.exe
|
||||
curl -L https://github.com/kubernetes/kompose/releases/download/v1.22.0/kompose-windows-amd64.exe -o kompose.exe
|
||||
|
||||
chmod +x kompose
|
||||
sudo mv ./kompose /usr/local/bin/kompose
|
||||
|
|
@ -68,9 +67,10 @@ sudo mv ./kompose /usr/local/bin/kompose
|
|||
<!--
|
||||
Alternatively, you can download the [tarball](https://github.com/kubernetes/kompose/releases).
|
||||
-->
|
||||
或者,你可以下载 [tarball](https://github.com/kubernetes/kompose/releases)。
|
||||
或者,你可以下载 [tar 包](https://github.com/kubernetes/kompose/releases)。
|
||||
|
||||
## Go
|
||||
{{% /tab %}}
|
||||
{{% tab name="基于源代码构建" %}}
|
||||
|
||||
<!--
|
||||
Installing using `go get` pulls from the master branch with the latest development changes.
|
||||
|
|
@ -81,7 +81,8 @@ Installing using `go get` pulls from the master branch with the latest developme
|
|||
go get -u github.com/kubernetes/kompose
|
||||
```
|
||||
|
||||
## CentOS
|
||||
{{% /tab %}}
|
||||
{{% tab name="CentOS 包" %}}
|
||||
|
||||
<!--
|
||||
Kompose is in [EPEL](https://fedoraproject.org/wiki/EPEL) CentOS repository.
|
||||
|
|
@ -101,7 +102,8 @@ If you have [EPEL](https://fedoraproject.org/wiki/EPEL) enabled in your system,
|
|||
sudo yum -y install kompose
|
||||
```
|
||||
|
||||
## Fedora
|
||||
{{% /tab %}}
|
||||
{{% tab name="Fedora package" %}}
|
||||
|
||||
<!--
|
||||
Kompose is in Fedora 24, 25 and 26 repositories. You can install it just like any other package.
|
||||
|
|
@ -112,7 +114,8 @@ Kompose 位于 Fedora 24、25 和 26 的代码仓库。你可以像安装其他
|
|||
sudo dnf -y install kompose
|
||||
```
|
||||
|
||||
## macOS
|
||||
{{% /tab %}}
|
||||
{{% tab name="Homebrew (macOS)" %}}
|
||||
|
||||
<!--
|
||||
On macOS you can install latest release via [Homebrew](https://brew.sh):
|
||||
|
|
@ -123,6 +126,9 @@ On macOS you can install latest release via [Homebrew](https://brew.sh):
|
|||
brew install kompose
|
||||
```
|
||||
|
||||
{{% /tab %}}
|
||||
{{< /tabs >}}
|
||||
|
||||
<!--
|
||||
## Use Kompose
|
||||
-->
|
||||
|
|
@ -135,129 +141,139 @@ you need is an existing `docker-compose.yml` file.
|
|||
再需几步,我们就把你从 Docker Compose 带到 Kubernetes。
|
||||
你只需要一个现有的 `docker-compose.yml` 文件。
|
||||
|
||||
1. <!--Go to the directory containing your `docker-compose.yml` file. If you don't
|
||||
have one, test using this one.-->
|
||||
进入 `docker-compose.yml` 文件所在的目录。如果没有,请使用下面这个进行测试。
|
||||
1. <!--Go to the directory containing your `docker-compose.yml` file. If you don't
|
||||
have one, test using this one.-->
|
||||
进入 `docker-compose.yml` 文件所在的目录。如果没有,请使用下面这个进行测试。
|
||||
|
||||
```yaml
|
||||
version: "2"
|
||||
```yaml
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
services:
|
||||
|
||||
redis-master:
|
||||
image: k8s.gcr.io/redis:e2e
|
||||
ports:
|
||||
- "6379"
|
||||
redis-master:
|
||||
image: k8s.gcr.io/redis:e2e
|
||||
ports:
|
||||
- "6379"
|
||||
|
||||
redis-slave:
|
||||
image: gcr.io/google_samples/gb-redisslave:v3
|
||||
ports:
|
||||
- "6379"
|
||||
environment:
|
||||
- GET_HOSTS_FROM=dns
|
||||
redis-slave:
|
||||
image: gcr.io/google_samples/gb-redisslave:v3
|
||||
ports:
|
||||
- "6379"
|
||||
environment:
|
||||
- GET_HOSTS_FROM=dns
|
||||
|
||||
frontend:
|
||||
image: gcr.io/google-samples/gb-frontend:v4
|
||||
ports:
|
||||
- "80:80"
|
||||
environment:
|
||||
- GET_HOSTS_FROM=dns
|
||||
labels:
|
||||
kompose.service.type: LoadBalancer
|
||||
```
|
||||
frontend:
|
||||
image: gcr.io/google-samples/gb-frontend:v4
|
||||
ports:
|
||||
- "80:80"
|
||||
environment:
|
||||
- GET_HOSTS_FROM=dns
|
||||
labels:
|
||||
kompose.service.type: LoadBalancer
|
||||
```
|
||||
|
||||
2. <!--Run the `kompose up` command to deploy to Kubernetes directly, or skip to
|
||||
the next step instead to generate a file to use with `kubectl`.-->
|
||||
运行 `kompose up` 命令直接部署到 Kubernetes,或者跳到下一步,生成 `kubectl` 使用的文件。
|
||||
<!--
|
||||
2. To convert the `docker-compose.yml` file to files that you can use with
|
||||
`kubectl`, run `kompose convert` and then `kubectl create -f <output file>`.
|
||||
-->
|
||||
2. 要将 `docker-compose.yml` 转换为 `kubectl` 可用的文件,请运行 `kompose convert`
|
||||
命令进行转换,然后运行 `kubectl create -f <output file>` 进行创建。
|
||||
|
||||
```bash
|
||||
$ kompose up
|
||||
We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application.
|
||||
If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.
|
||||
```shell
|
||||
kompose convert
|
||||
```
|
||||
|
||||
INFO Successfully created Service: redis
|
||||
INFO Successfully created Service: web
|
||||
INFO Successfully created Deployment: redis
|
||||
INFO Successfully created Deployment: web
|
||||
```none
|
||||
INFO Kubernetes file "frontend-service.yaml" created
|
||||
INFO Kubernetes file "frontend-service.yaml" created
|
||||
INFO Kubernetes file "frontend-service.yaml" created
|
||||
INFO Kubernetes file "redis-master-service.yaml" created
|
||||
INFO Kubernetes file "redis-master-service.yaml" created
|
||||
INFO Kubernetes file "redis-master-service.yaml" created
|
||||
INFO Kubernetes file "redis-slave-service.yaml" created
|
||||
INFO Kubernetes file "redis-slave-service.yaml" created
|
||||
INFO Kubernetes file "redis-slave-service.yaml" created
|
||||
INFO Kubernetes file "frontend-deployment.yaml" created
|
||||
INFO Kubernetes file "frontend-deployment.yaml" created
|
||||
INFO Kubernetes file "frontend-deployment.yaml" created
|
||||
INFO Kubernetes file "redis-master-deployment.yaml" created
|
||||
INFO Kubernetes file "redis-master-deployment.yaml" created
|
||||
INFO Kubernetes file "redis-master-deployment.yaml" created
|
||||
INFO Kubernetes file "redis-slave-deployment.yaml" created
|
||||
INFO Kubernetes file "redis-slave-deployment.yaml" created
|
||||
INFO Kubernetes file "redis-slave-deployment.yaml" created
|
||||
```
|
||||
|
||||
Your application has been deployed to Kubernetes. You can run 'kubectl get deployment,svc,pods,pvc' for details.
|
||||
```
|
||||
```bash
|
||||
kubectl apply -f frontend-service.yaml,redis-master-service.yaml,redis-slave-service.yaml,frontend-deployment.yaml,
|
||||
```
|
||||
|
||||
3. <!--To convert the `docker-compose.yml` file to files that you can use with
|
||||
`kubectl`, run `kompose convert` and then `kubectl create -f <output file>`.-->
|
||||
要将 `docker-compose.yml` 转换为 `kubectl` 可用的文件,请运行 `kompose convert` 命令进行转换,
|
||||
然后运行 `kubectl create -f <output file>` 进行创建。
|
||||
<!--
|
||||
The output is similar to:
|
||||
-->
|
||||
输出类似于:
|
||||
|
||||
```shell
|
||||
kompose convert
|
||||
```
|
||||
```none
|
||||
service/frontend created
|
||||
service/redis-master created
|
||||
service/redis-slave created
|
||||
deployment.apps/frontend created
|
||||
deployment.apps/redis-master created
|
||||
deployment.apps/redis-slave created
|
||||
```
|
||||
|
||||
```
|
||||
INFO Kubernetes file "frontend-service.yaml" created
|
||||
INFO Kubernetes file "redis-master-service.yaml" created
|
||||
INFO Kubernetes file "redis-slave-service.yaml" created
|
||||
INFO Kubernetes file "frontend-deployment.yaml" created
|
||||
INFO Kubernetes file "redis-master-deployment.yaml" created
|
||||
INFO Kubernetes file "redis-slave-deployment.yaml" created
|
||||
```
|
||||
<!--
|
||||
Your deployments are running in Kubernetes.
|
||||
-->
|
||||
你部署的应用在 Kubernetes 中运行起来了。
|
||||
|
||||
```shell
|
||||
kubectl create -f frontend-service.yaml,redis-master-service.yaml,redis-slave-service.yaml,frontend-deployment.yaml,redis-master-deployment.yaml,redis-slave-deployment.yaml
|
||||
```
|
||||
<!--
|
||||
3. Access your application.
|
||||
-->
|
||||
3. 访问你的应用
|
||||
|
||||
```
|
||||
service/frontend created
|
||||
service/redis-master created
|
||||
service/redis-slave created
|
||||
deployment.apps/frontend created
|
||||
deployment.apps/redis-master created
|
||||
deployment.apps/redis-slave created
|
||||
```
|
||||
<!--
|
||||
If you're already using `minikube` for your development process:
|
||||
-->
|
||||
|
||||
<!--
|
||||
Your deployments are running in Kubernetes.
|
||||
-->
|
||||
你部署的应用在 Kubernetes 中运行起来了。
|
||||
如果你在开发过程中使用 `minikube`,请执行:
|
||||
|
||||
4. <!--Access your application.-->
|
||||
访问你的应用
|
||||
```shell
|
||||
minikube service frontend
|
||||
```
|
||||
|
||||
<!--If you're already using `minikube` for your development process:-->
|
||||
<!--
|
||||
Otherwise, let's look up what IP your service is using!
|
||||
-->
|
||||
否则,我们要查看一下你的服务使用了什么 IP!
|
||||
|
||||
如果你在开发过程中使用 `minikube`,请执行:
|
||||
```shell
|
||||
kubectl describe svc frontend
|
||||
```
|
||||
|
||||
```shell
|
||||
minikube service frontend
|
||||
```
|
||||
```none
|
||||
Name: frontend
|
||||
Namespace: default
|
||||
Labels: service=frontend
|
||||
Selector: service=frontend
|
||||
Type: LoadBalancer
|
||||
IP: 10.0.0.183
|
||||
LoadBalancer Ingress: 192.0.2.89
|
||||
Port: 80 80/TCP
|
||||
NodePort: 80 31144/TCP
|
||||
Endpoints: 172.17.0.4:80
|
||||
Session Affinity: None
|
||||
No events.
|
||||
```
|
||||
|
||||
<!--Otherwise, let's look up what IP your service is using!-->
|
||||
否则,我们要查看一下你的服务使用了什么 IP!
|
||||
<!--
|
||||
If you're using a cloud provider, your IP will be listed next to `LoadBalancer Ingress`.
|
||||
-->
|
||||
如果你使用的是云提供商,你的 IP 将在 `LoadBalancer Ingress` 字段给出。
|
||||
|
||||
```shell
|
||||
kubectl describe svc frontend
|
||||
```
|
||||
|
||||
```
|
||||
Name: frontend
|
||||
Namespace: default
|
||||
Labels: service=frontend
|
||||
Selector: service=frontend
|
||||
Type: LoadBalancer
|
||||
IP: 10.0.0.183
|
||||
LoadBalancer Ingress: 192.0.2.89
|
||||
Port: 80 80/TCP
|
||||
NodePort: 80 31144/TCP
|
||||
Endpoints: 172.17.0.4:80
|
||||
Session Affinity: None
|
||||
No events.
|
||||
```
|
||||
|
||||
<!--If you're using a cloud provider, your IP will be listed next to `LoadBalancer Ingress`.-->
|
||||
如果你使用的是云提供商,你的 IP 将在 `LoadBalancer Ingress` 字段给出。
|
||||
|
||||
```shell
|
||||
curl http://192.0.2.89
|
||||
```
|
||||
```shell
|
||||
curl http://192.0.2.89
|
||||
```
|
||||
|
||||
<!-- discussion -->
|
||||
|
||||
|
|
@ -284,29 +300,37 @@ you need is an existing `docker-compose.yml` file.
|
|||
- [`kompose down`](#kompose-down)
|
||||
|
||||
- 文档
|
||||
- [构建和推送 Docker 镜像](#构建和推送-docker-镜像)
|
||||
- [构建和推送 Docker 镜像](#build-and-push-docker-images)
|
||||
- [其他转换方式](#其他转换方式)
|
||||
- [标签](#标签)
|
||||
- [重启](#重启)
|
||||
- [Docker Compose 版本](#docker-compose-版本)
|
||||
- [标签](#labels)
|
||||
- [重启](#restart)
|
||||
- [Docker Compose 版本](#docker-compose-versions)
|
||||
|
||||
<!--
|
||||
Kompose has support for two providers: OpenShift and Kubernetes.
|
||||
You can choose a targeted provider using global option `--provider`. If no provider is specified, Kubernetes is set by default.
|
||||
-->
|
||||
Kompose 支持两种驱动:OpenShift 和 Kubernetes。
|
||||
你可以通过全局选项 `--provider` 选择驱动方式。如果没有指定,会将 Kubernetes 作为默认驱动。
|
||||
你可以通过全局选项 `--provider` 选择驱动。如果没有指定,
|
||||
会将 Kubernetes 作为默认驱动。
|
||||
|
||||
## `kompose convert`
|
||||
|
||||
<!--
|
||||
Kompose supports conversion of V1, V2, and V3 Docker Compose files into Kubernetes and OpenShift objects.
|
||||
-->
|
||||
Kompose 支持将 V1、V2 和 V3 版本的 Docker Compose 文件转换为 Kubernetes 和 OpenShift 资源对象。
|
||||
|
||||
### Kubernetes
|
||||
<!--
|
||||
### Kubernetes `kompose convert` example
|
||||
-->
|
||||
### Kubernetes `kompose convert` 示例
|
||||
|
||||
```shell
|
||||
kompose --file docker-voting.yml convert
|
||||
```
|
||||
```
|
||||
|
||||
```none
|
||||
WARN Unsupported key networks - ignoring
|
||||
WARN Unsupported key build - ignoring
|
||||
INFO Kubernetes file "worker-svc.yaml" created
|
||||
|
|
@ -325,7 +349,7 @@ INFO Kubernetes file "db-deployment.yaml" created
|
|||
ls
|
||||
```
|
||||
|
||||
```
|
||||
```none
|
||||
db-deployment.yaml docker-compose.yml docker-gitlab.yml redis-deployment.yaml result-deployment.yaml vote-deployment.yaml worker-deployment.yaml
|
||||
db-svc.yaml docker-voting.yml redis-svc.yaml result-svc.yaml vote-svc.yaml worker-svc.yaml
|
||||
```
|
||||
|
|
@ -338,7 +362,8 @@ You can also provide multiple docker-compose files at the same time:
|
|||
```shell
|
||||
kompose -f docker-compose.yml -f docker-guestbook.yml convert
|
||||
```
|
||||
```
|
||||
|
||||
```none
|
||||
INFO Kubernetes file "frontend-service.yaml" created
|
||||
INFO Kubernetes file "mlbparks-service.yaml" created
|
||||
INFO Kubernetes file "mongodb-service.yaml" created
|
||||
|
|
@ -368,7 +393,10 @@ When multiple docker-compose files are provided the configuration is merged. Any
|
|||
-->
|
||||
当提供多个 docker-compose 文件时,配置将会合并。任何通用的配置都将被后续文件覆盖。
|
||||
|
||||
### OpenShift
|
||||
<!--
|
||||
### OpenShift `kompose convert` example
|
||||
-->
|
||||
### OpenShift `kompose convert` 示例
|
||||
|
||||
```shell
|
||||
kompose --provider openshift --file docker-voting.yml convert
|
||||
|
|
@ -403,7 +431,7 @@ kompose 还支持为服务中的构建指令创建 buildconfig。
|
|||
kompose --provider openshift --file buildconfig/docker-compose.yml convert
|
||||
```
|
||||
|
||||
```
|
||||
```none
|
||||
WARN [foo] Service cannot be created because of missing port.
|
||||
INFO OpenShift Buildconfig using git@github.com:rtnpro/kompose.git::master as source.
|
||||
INFO OpenShift file "foo-deploymentconfig.yaml" created
|
||||
|
|
@ -424,15 +452,19 @@ imagestream 工件,以解决 Openshift 的这个问题:https://github.com/op
|
|||
<!--
|
||||
Kompose supports a straightforward way to deploy your "composed" application to Kubernetes or OpenShift via `kompose up`.
|
||||
-->
|
||||
Kompose 支持通过 `kompose up` 直接将你的"复合的(composed)" 应用程序部署到 Kubernetes 或 OpenShift。
|
||||
Kompose 支持通过 `kompose up` 直接将你的"复合的(composed)" 应用程序
|
||||
部署到 Kubernetes 或 OpenShift。
|
||||
|
||||
### Kubernetes
|
||||
<!--
|
||||
### Kubernetes `kompose up` example
|
||||
-->
|
||||
### Kubernetes `kompose up` 示例
|
||||
|
||||
```shell
|
||||
kompose --file ./examples/docker-guestbook.yml up
|
||||
```
|
||||
|
||||
```
|
||||
```none
|
||||
We are going to create Kubernetes deployments and services for your Dockerized application.
|
||||
If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.
|
||||
|
||||
|
|
@ -468,26 +500,27 @@ pod/redis-master-1432129712-63jn8 1/1 Running 0 4m
|
|||
pod/redis-slave-2504961300-nve7b 1/1 Running 0 4m
|
||||
```
|
||||
|
||||
|
||||
{{< note >}}
|
||||
<!--
|
||||
**Note**:
|
||||
- You must have a running Kubernetes cluster with a pre-configured kubectl context.
|
||||
- Only deployments and services are generated and deployed to Kubernetes. If you need different kind of resources, use the `kompose convert` and `kubectl create -f` commands instead.
|
||||
-->
|
||||
|
||||
**注意**:
|
||||
|
||||
- 你必须有一个运行正常的 Kubernetes 集群,该集群具有预先配置的 kubectl 上下文。
|
||||
- 此操作仅生成 Deployment 和 Service 对象并将其部署到 Kubernetes。
|
||||
如果需要部署其他不同类型的资源,请使用 `kompose convert` 和 `kubectl create -f` 命令。
|
||||
{{< /note >}}
|
||||
|
||||
|
||||
### OpenShift
|
||||
<!--
|
||||
### OpenShift `kompose up` example
|
||||
-->
|
||||
### OpenShift `kompose up` 示例
|
||||
|
||||
```shell
|
||||
kompose --file ./examples/docker-guestbook.yml --provider openshift up
|
||||
```
|
||||
|
||||
```
|
||||
```none
|
||||
We are going to create OpenShift DeploymentConfigs and Services for your Dockerized application.
|
||||
If you need different kind of resources, use the 'kompose convert' and 'oc create -f' commands instead.
|
||||
|
||||
|
|
@ -508,7 +541,7 @@ Your application has been deployed to OpenShift. You can run 'oc get dc,svc,is'
|
|||
oc get dc,svc,is
|
||||
```
|
||||
|
||||
```
|
||||
```none
|
||||
NAME REVISION DESIRED CURRENT TRIGGERED BY
|
||||
dc/frontend 0 1 0 config,image(frontend:v4)
|
||||
dc/redis-master 0 1 0 config,image(redis-master:e2e)
|
||||
|
|
@ -523,20 +556,18 @@ is/redis-master 172.30.12.200:5000/fff/redis-master
|
|||
is/redis-slave 172.30.12.200:5000/fff/redis-slave v1
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
<!--
|
||||
**Note**:
|
||||
- You must have a running OpenShift cluster with a pre-configured `oc` context (`oc login`)
|
||||
You must have a running OpenShift cluster with a pre-configured `oc` context (`oc login`)
|
||||
-->
|
||||
**注意**:
|
||||
|
||||
- 你必须有一个运行正常的 OpenShift 集群,该集群具有预先配置的 `oc` 上下文 (`oc login`)。
|
||||
你必须有一个运行正常的 OpenShift 集群,该集群具有预先配置的 `oc` 上下文 (`oc login`)。
|
||||
{{< /note >}}
|
||||
|
||||
## `kompose down`
|
||||
|
||||
<!--
|
||||
Once you have deployed "composed" application to Kubernetes, `$ kompose down` will help you to take the application out by deleting its deployments and services. If you need to remove other resources, use the 'kubectl' command.
|
||||
-->
|
||||
|
||||
你一旦将"复合(composed)" 应用部署到 Kubernetes,`kompose down`
|
||||
命令将能帮你通过删除 Deployment 和 Service 对象来删除应用。
|
||||
如果需要删除其他资源,请使用 'kubectl' 命令。
|
||||
|
|
@ -554,26 +585,27 @@ INFO Successfully deleted service: frontend
|
|||
INFO Successfully deleted deployment: frontend
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
<!--
|
||||
**Note**:
|
||||
|
||||
- You must have a running Kubernetes cluster with a pre-configured kubectl context.
|
||||
You must have a running Kubernetes cluster with a pre-configured kubectl context.
|
||||
-->
|
||||
- 你必须有一个运行正常的 Kubernetes 集群,该集群具有预先配置的 kubectl 上下文。
|
||||
{{< /note >}}
|
||||
|
||||
<!--
|
||||
## Build and Push Docker Images
|
||||
|
||||
Kompose supports both building and pushing Docker images. When using the `build` key within your Docker Compose file, your image will:
|
||||
|
||||
- Automatically be built with Docker using the `image` key specified within your file
|
||||
- Be pushed to the correct Docker repository using local credentials (located at `.docker/config`)
|
||||
|
||||
Using an [example Docker Compose file](https://raw.githubusercontent.com/kubernetes/kompose/master/examples/buildconfig/docker-compose.yml):
|
||||
-->
|
||||
## 构建和推送 Docker 镜像 {#build-and-push-docker-images}
|
||||
|
||||
**注意**:
|
||||
|
||||
- 你必须有一个运行正常的 Kubernetes 集群,该集群具有预先配置的 kubectl 上下文。
|
||||
|
||||
## 构建和推送 Docker 镜像
|
||||
|
||||
Kompose 支持构建和推送 Docker 镜像。如果 Docker Compose 文件中使用了 `build` 关键字,你的镜像将会:
|
||||
Kompose 支持构建和推送 Docker 镜像。如果 Docker Compose 文件中使用了 `build`
|
||||
关键字,你的镜像将会:
|
||||
|
||||
- 使用文档中指定的 `image` 键自动构建 Docker 镜像
|
||||
- 使用本地凭据推送到正确的 Docker 仓库
|
||||
|
|
@ -598,7 +630,7 @@ Using `kompose up` with a `build` key:
|
|||
kompose up
|
||||
```
|
||||
|
||||
```
|
||||
```none
|
||||
INFO Build key detected. Attempting to build and push image 'docker.io/foo/bar'
|
||||
INFO Building image 'docker.io/foo/bar' from directory 'build'
|
||||
INFO Image 'docker.io/foo/bar' from directory 'build' built successfully
|
||||
|
|
@ -621,10 +653,10 @@ In order to disable the functionality, or choose to use BuildConfig generation (
|
|||
可以通过传递 `--build (local|build-config|none)` 参数来实现。
|
||||
|
||||
```shell
|
||||
# Disable building/pushing Docker images
|
||||
# 禁止构造和推送 Docker 镜像
|
||||
kompose up --build none
|
||||
|
||||
# Generate Build Config artifacts for OpenShift
|
||||
# 为 OpenShift 生成 Build Config 工件
|
||||
kompose up --provider openshift --build build-config
|
||||
```
|
||||
|
||||
|
|
@ -633,7 +665,7 @@ kompose up --provider openshift --build build-config
|
|||
|
||||
The default `kompose` transformation will generate Kubernetes [Deployments](/docs/concepts/workloads/controllers/deployment/) and [Services](/docs/concepts/services-networking/service/), in yaml format. You have alternative option to generate json with `-j`. Also, you can alternatively generate [Replication Controllers](/docs/concepts/workloads/controllers/replicationcontroller/) objects, [Daemon Sets](/docs/concepts/workloads/controllers/daemonset/), or [Helm](https://github.com/helm/helm) charts.
|
||||
-->
|
||||
## 其他转换方式
|
||||
## 其他转换方式 {#alternative-conversions}
|
||||
|
||||
默认的 `kompose` 转换会生成 yaml 格式的 Kubernetes
|
||||
[Deployment](/zh/docs/concepts/workloads/controllers/deployment/) 和
|
||||
|
|
@ -646,7 +678,8 @@ The default `kompose` transformation will generate Kubernetes [Deployments](/doc
|
|||
```shell
|
||||
kompose convert -j
|
||||
```
|
||||
```
|
||||
|
||||
```none
|
||||
INFO Kubernetes file "redis-svc.json" created
|
||||
INFO Kubernetes file "web-svc.json" created
|
||||
INFO Kubernetes file "redis-deployment.json" created
|
||||
|
|
@ -661,7 +694,8 @@ The `*-deployment.json` files contain the Deployment objects.
|
|||
```shell
|
||||
kompose convert --replication-controller
|
||||
```
|
||||
```
|
||||
|
||||
```none
|
||||
INFO Kubernetes file "redis-svc.yaml" created
|
||||
INFO Kubernetes file "web-svc.yaml" created
|
||||
INFO Kubernetes file "redis-replicationcontroller.yaml" created
|
||||
|
|
@ -671,7 +705,6 @@ INFO Kubernetes file "web-replicationcontroller.yaml" created
|
|||
<!--
|
||||
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`
|
||||
-->
|
||||
|
||||
`*-replicationcontroller.yaml` 文件包含 Replication Controller 对象。
|
||||
如果你想指定副本数(默认为 1),可以使用 `--replicas` 参数:
|
||||
`kompose convert --replication-controller --replicas 3`
|
||||
|
|
@ -680,7 +713,7 @@ The `*-replicationcontroller.yaml` files contain the Replication Controller obje
|
|||
kompose convert --daemon-set
|
||||
```
|
||||
|
||||
```
|
||||
```none
|
||||
INFO Kubernetes file "redis-svc.yaml" created
|
||||
INFO Kubernetes file "web-svc.yaml" created
|
||||
INFO Kubernetes file "redis-daemonset.yaml" created
|
||||
|
|
@ -688,17 +721,19 @@ INFO Kubernetes file "web-daemonset.yaml" created
|
|||
```
|
||||
|
||||
<!--
|
||||
The `*-daemonset.yaml` files contain the Daemon Set objects
|
||||
The `*-daemonset.yaml` files contain the DaemonSet objects
|
||||
If you want to generate a Chart to be used with [Helm](https://github.com/kubernetes/helm) simply do:
|
||||
-->
|
||||
`*-daemonset.yaml` 文件包含 Daemon Set 对象。
|
||||
`*-daemonset.yaml` 文件包含 DaemonSet 对象。
|
||||
|
||||
如果你想生成 [Helm](https://github.com/kubernetes/helm) 可用的 Chart,只需简单的执行下面的命令:
|
||||
如果你想生成 [Helm](https://github.com/kubernetes/helm) 可用的 Chart,
|
||||
只需简单的执行下面的命令:
|
||||
|
||||
```shell
|
||||
kompose convert -c
|
||||
```
|
||||
```
|
||||
|
||||
```none
|
||||
INFO Kubernetes file "web-svc.yaml" created
|
||||
INFO Kubernetes file "redis-svc.yaml" created
|
||||
INFO Kubernetes file "web-deployment.yaml" created
|
||||
|
|
@ -734,9 +769,10 @@ The chart structure is aimed at providing a skeleton for building your Helm char
|
|||
|
||||
For example:
|
||||
-->
|
||||
## 标签
|
||||
## 标签 {#labels}
|
||||
|
||||
`kompose` 支持 `docker-compose.yml` 文件中用于 Kompose 的标签,以便在转换时明确定义 Service 的行为。
|
||||
`kompose` 支持 `docker-compose.yml` 文件中用于 Kompose 的标签,以便
|
||||
在转换时明确定义 Service 的行为。
|
||||
|
||||
- `kompose.service.type` 定义要创建的 Service 类型。例如:
|
||||
|
||||
|
|
@ -761,11 +797,13 @@ For example:
|
|||
For example:
|
||||
-->
|
||||
- `kompose.service.expose` 定义是否允许从集群外部访问 Service。
|
||||
如果该值被设置为 "true",提供程序将自动设置端点,对于任何其他值,该值将被设置为主机名。
|
||||
如果该值被设置为 "true",提供程序将自动设置端点,
|
||||
对于任何其他值,该值将被设置为主机名。
|
||||
如果在 Service 中定义了多个端口,则选择第一个端口作为公开端口。
|
||||
|
||||
- 对于 Kubernetes 驱动程序,创建了一个 Ingress 资源,并且假定已经配置了相应的 Ingress 控制器。
|
||||
- 对于 OpenShift 驱动程序, 创建一个 route。
|
||||
- 如果使用 Kubernetes 驱动,会有一个 Ingress 资源被创建,并且假定
|
||||
已经配置了相应的 Ingress 控制器。
|
||||
- 如果使用 OpenShift 驱动, 则会有一个 route 被创建。
|
||||
|
||||
例如:
|
||||
|
||||
|
|
@ -793,19 +831,18 @@ The currently supported options are:
|
|||
| kompose.service.type | nodeport / clusterip / loadbalancer |
|
||||
| kompose.service.expose| true / hostname |
|
||||
-->
|
||||
|
||||
当前支持的选项有:
|
||||
|
||||
| 键 | 值 |
|
||||
|----------------------|-------------------------------------|
|
||||
| kompose.service.type | nodeport / clusterip / loadbalancer |
|
||||
| kompose.service.expose| true / hostname |
|
||||
| 键 | 值 |
|
||||
|------------------------|-------------------------------------|
|
||||
| kompose.service.type | nodeport / clusterip / loadbalancer |
|
||||
| kompose.service.expose | true / hostname |
|
||||
|
||||
{{< note >}}
|
||||
<!--
|
||||
The `kompose.service.type` label should be defined with `ports` only, otherwise `kompose` will fail.
|
||||
-->
|
||||
{{< note >}}
|
||||
`kompose.service.type` 标签应该只用`ports`来定义,否则 `kompose` 会失败。
|
||||
`kompose.service.type` 标签应该只用 `ports` 来定义,否则 `kompose` 会失败。
|
||||
{{< /note >}}
|
||||
|
||||
<!--
|
||||
|
|
@ -813,10 +850,10 @@ The `kompose.service.type` label should be defined with `ports` only, otherwise
|
|||
|
||||
If you want to create normal pods without controllers you can use `restart` construct of docker-compose to define that. Follow table below to see what happens on the `restart` value.
|
||||
-->
|
||||
## 重启
|
||||
## 重启 {#restart}
|
||||
|
||||
如果你想创建没有控制器的普通 Pod,可以使用 docker-compose 的 `restart` 结构来定义它。
|
||||
请参考下表了解 `restart` 的不同参数。
|
||||
如果你想创建没有控制器的普通 Pod,可以使用 docker-compose 的 `restart`
|
||||
结构来指定这一行为。请参考下表了解 `restart` 的不同参数。
|
||||
|
||||
<!--
|
||||
| `docker-compose` `restart` | object created | Pod `restartPolicy` |
|
||||
|
|
@ -827,10 +864,10 @@ If you want to create normal pods without controllers you can use `restart` cons
|
|||
| `no` | Pod | `Never` |
|
||||
-->
|
||||
|
||||
| `docker-compose` `restart` | 创建的对象 | Pod `restartPolicy` |
|
||||
| `docker-compose` `restart` | 创建的对象 | Pod `restartPolicy` |
|
||||
|----------------------------|-------------------|---------------------|
|
||||
| `""` | 控制器对象 | `Always` |
|
||||
| `always` | 控制器对象 | `Always` |
|
||||
| `""` | 控制器对象 | `Always` |
|
||||
| `always` | 控制器对象 | `Always` |
|
||||
| `on-failure` | Pod | `OnFailure` |
|
||||
| `no` | Pod | `Never` |
|
||||
|
||||
|
|
@ -843,9 +880,9 @@ The controller object could be `deployment` or `replicationcontroller`, etc.
|
|||
{{< /note >}}
|
||||
|
||||
<!--
|
||||
For e.g. `pival` service will become pod down here. This container calculated value of `pi`.
|
||||
For example, the `pival` service will become pod down here. This container calculated value of `pi`.
|
||||
-->
|
||||
例如,`pival` Service 将在这里变成 Pod。这个容器的计算值为 `pi`。
|
||||
例如,`pival` Service 将在这里变成 Pod。这个容器计算 `pi` 的取值。
|
||||
|
||||
```yaml
|
||||
version: '2'
|
||||
|
|
@ -858,23 +895,22 @@ services:
|
|||
```
|
||||
|
||||
<!--
|
||||
### Warning about Deployment Config's
|
||||
### Warning about Deployment Configurations
|
||||
|
||||
If the Docker Compose file has a volume specified for a service, the Deployment (Kubernetes) or DeploymentConfig (OpenShift) strategy is changed to "Recreate" instead of "RollingUpdate" (default). This is done to avoid multiple instances of a service from accessing a volume at the same time.
|
||||
-->
|
||||
|
||||
### 关于 Deployment Config 的提醒
|
||||
|
||||
如果 Docker Compose 文件中为服务声明了卷,Deployment (Kubernetes) 或 DeploymentConfig (OpenShift)
|
||||
的策略会从 "RollingUpdate" (默认) 变为 "Recreate"。
|
||||
如果 Docker Compose 文件中为服务声明了卷,Deployment (Kubernetes) 或
|
||||
DeploymentConfig (OpenShift) 策略会从 "RollingUpdate" (默认) 变为 "Recreate"。
|
||||
这样做的目的是为了避免服务的多个实例同时访问卷。
|
||||
|
||||
<!--
|
||||
If the Docker Compose file has service name with `_` in it (eg.`web_service`), then it will be replaced by `-` and the service name will be renamed accordingly (eg.`web-service`). Kompose does this because "Kubernetes" doesn't allow `_` in object name.
|
||||
Please note that changing service name might break some `docker-compose` files.
|
||||
-->
|
||||
如果 Docker Compose 文件中的服务名包含 `_` (例如 `web_service`),
|
||||
那么将会被替换为 `-`,服务也相应的会重命名(例如 `web-service`)。
|
||||
如果 Docker Compose 文件中的服务名包含 `_`(例如 `web_service`),
|
||||
那么将会被替换为 `-`,服务也相应的会重命名(例如 `web-service`)。
|
||||
Kompose 这样做的原因是 "Kubernetes" 不允许对象名称中包含 `_`。
|
||||
|
||||
请注意,更改服务名称可能会破坏一些 `docker-compose` 文件。
|
||||
|
|
@ -883,14 +919,15 @@ Kompose 这样做的原因是 "Kubernetes" 不允许对象名称中包含 `_`。
|
|||
## Docker Compose Versions
|
||||
|
||||
Kompose supports Docker Compose versions: 1, 2 and 3. We have limited support on versions 2.1 and 3.2 due to their experimental nature.
|
||||
|
||||
A full list on compatibility between all three versions is listed in our [conversion document](https://github.com/kubernetes/kompose/blob/master/docs/conversion.md) including a list of all incompatible Docker Compose keys.
|
||||
-->
|
||||
## Docker Compose 版本
|
||||
## Docker Compose 版本 {#docker-compose-versions}
|
||||
|
||||
Kompose 支持的 Docker Compose 版本包括:1、2 和 3。有限支持 2.1 和 3.2 版本,因为它们还在实验阶段。
|
||||
Kompose 支持的 Docker Compose 版本包括:1、2 和 3。
|
||||
对 2.1 和 3.2 版本的支持还有限,因为它们还在实验阶段。
|
||||
|
||||
所有三个版本的兼容性列表请查看我们的
|
||||
[转换文档](https://github.com/kubernetes/kompose/blob/master/docs/conversion.md),
|
||||
文档中列出了所有不兼容的 Docker Compose 关键字。
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue