Skip to content

Commit 900a811

Browse files
authored
Merge pull request #31150 from shuaijinchao/zh/sync/access-application-cluster/access-cluster
[zh] synchronize translate access-cluster.md
2 parents e66a6c9 + 23aaa92 commit 900a811

File tree

1 file changed

+4
-204
lines changed

1 file changed

+4
-204
lines changed

content/zh/docs/tasks/access-application-cluster/access-cluster.md

Lines changed: 4 additions & 204 deletions
Original file line numberDiff line numberDiff line change
@@ -355,214 +355,14 @@ In each case, the credentials of the pod are used to communicate securely with t
355355
<!--
356356
## Accessing services running on the cluster
357357
358-
The previous section was about connecting the Kubernetes API server. This section is about
359-
connecting to other services running on Kubernetes cluster. In Kubernetes, the
360-
[nodes](/docs/admin/node), [pods](/docs/user-guide/pods) and [services](/docs/user-guide/services) all have
361-
their own IPs. In many cases, the node IPs, pod IPs, and some service IPs on a cluster will not be
362-
routable, so they will not be reachable from a machine outside the cluster,
363-
such as your desktop machine.
358+
The previous section describes how to connect to the Kubernetes API server. For information about connecting to other services running on a Kubernetes cluster, see [Access Cluster Services.](/docs/tasks/access-application-cluster/access-cluster/)
364359
-->
365-
## 访问集群中正在运行的服务 {#accessing-services-running-on-the-cluster}
366360

367-
上一节介绍了如何连接 Kubernetes API 服务。本节介绍如何连接到 Kubernetes
368-
集群上运行的其他服务。
369-
在 Kubernetes 中,[节点](/zh/docs/concepts/architecture/nodes/)
370-
[pods](/zh/docs/concepts/workloads/pods/)
371-
[服务](/zh/docs/concepts/services-networking/service/) 都有自己的 IP。
372-
在许多情况下,集群上的节点 IP、Pod IP 和某些服务 IP 将无法路由,
373-
因此无法从集群外部的计算机(例如桌面计算机)访问它们。
361+
## 访问集群上运行的服务 {#accessing-services-running-on-the-cluster}
374362

375-
<!--
376-
### Ways to connect
377-
378-
You have several options for connecting to nodes, pods and services from outside the cluster:
379-
380-
- Access services through public IPs.
381-
- Use a service with type `NodePort` or `LoadBalancer` to make the service reachable outside
382-
the cluster. See the [services](/docs/user-guide/services) and
383-
[kubectl expose](/docs/reference/generated/kubectl/kubectl-commands/#expose) documentation.
384-
- Depending on your cluster environment, this may only expose the service to your corporate network,
385-
or it may expose it to the internet. Think about whether the service being exposed is secure.
386-
Does it do its own authentication?
387-
- Place pods behind services. To access one specific pod from a set of replicas, such as for debugging,
388-
place a unique label on the pod and create a new service which selects this label.
389-
- In most cases, it should not be necessary for application developer to directly access
390-
nodes via their nodeIPs.
391-
-->
392-
### 连接的方法 {#ways-to-connect}
393-
394-
有多种方式可以从集群外部连接节点、Pod 和服务:
395-
396-
- 通过公共 IP 访问服务。
397-
398-
- 类型为 `NodePort``LoadBalancer` 的服务,集群外部可以访问。
399-
请参阅 [服务](/zh/docs/concepts/services-networking/service/)
400-
[kubectl expose](/docs/reference/generated/kubectl/kubectl-commands/#expose) 文档。
401-
- 取决于你的集群环境,该服务可能仅暴露给你的公司网络,或者也可能暴露给
402-
整个互联网。
403-
请考虑公开该服务是否安全。它是否进行自己的身份验证?
404-
- 在服务后端放置 Pod。要从一组副本中访问一个特定的 Pod,例如进行调试,
405-
请在 Pod 上设置一个唯一的标签,然后创建一个选择此标签的新服务。
406-
- 在大多数情况下,应用程序开发人员不应该通过其 nodeIP 直接访问节点。
407-
408-
<!--
409-
- Access services, nodes, or pods using the Proxy Verb.
410-
- Does apiserver authentication and authorization prior to accessing the remote service.
411-
Use this if the services are not secure enough to expose to the internet, or to gain
412-
access to ports on the node IP, or for debugging.
413-
- Proxies may cause problems for some web applications.
414-
- Only works for HTTP/HTTPS.
415-
- Described [here](#manually-constructing-apiserver-proxy-urls).
416-
-->
417-
- 使用 proxy 动词访问服务、节点或者 Pod。
418-
- 在访问远程服务之前进行 apiserver 身份验证和授权。
419-
如果服务不能够安全地暴露到互联网,或者服务不能获得节点 IP 端口的
420-
访问权限,或者是为了调试,那么请使用此选项。
421-
- 代理可能会给一些 web 应用带来问题。
422-
- 只适用于 HTTP/HTTPS。
423-
- 更多详细信息在[这里](#manually-constructing-apiserver-proxy-urls)
424-
425-
<!--
426-
- Access from a node or pod in the cluster.
427-
- Run a pod, and then connect to a shell in it using [kubectl exec](/docs/reference/generated/kubectl/kubectl-commands/#exec).
428-
Connect to other nodes, pods, and services from that shell.
429-
- Some clusters may allow you to ssh to a node in the cluster. From there you may be able to
430-
access cluster services. This is a non-standard method, and will work on some clusters but
431-
not others. Browsers and other tools may or may not be installed. Cluster DNS may not work.
432-
-->
433-
- 从集群中的节点或者 Pod 中访问。
434-
435-
- 运行一个 Pod,然后使用 [kubectl exec](/docs/reference/generated/kubectl/kubectl-commands/#exec)
436-
来连接 Pod 里的 Shell。
437-
然后从 Shell 中连接其它的节点、Pod 和服务。
438-
- 有些集群可能允许你通过 SSH 连接到节点,从那你可能可以访问集群的服务。
439-
这是一个非正式的方式,可能可以运行在个别的集群上。
440-
浏览器和其它一些工具可能没有被安装。集群的 DNS 可能无法使用。
441-
442-
<!--
443-
### Discovering builtin services
444-
445-
Typically, there are several services which are started on a cluster by kube-system. Get a list of these
446-
with the `kubectl cluster-info` command:
447-
-->
448-
### 发现内建服务
449-
450-
通常来说,集群中会有 kube-system 创建的一些运行的服务。
451-
452-
通过 `kubectl cluster-info` 命令获得这些服务列表:
453-
454-
```shell
455-
kubectl cluster-info
456-
```
457-
458-
```
459-
Kubernetes master is running at https://104.197.5.247
460-
elasticsearch-logging is running at https://104.197.5.247/api/v1/namespaces/kube-system/services/elasticsearch-logging/proxy
461-
kibana-logging is running at https://104.197.5.247/api/v1/namespaces/kube-system/services/kibana-logging/proxy
462-
kube-dns is running at https://104.197.5.247/api/v1/namespaces/kube-system/services/kube-dns/proxy
463-
grafana is running at https://104.197.5.247/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
464-
heapster is running at https://104.197.5.247/api/v1/namespaces/kube-system/services/monitoring-heapster/proxy
465-
```
466-
467-
<!--
468-
This shows the proxy-verb URL for accessing each service.
469-
For example, this cluster has cluster-level logging enabled (using Elasticsearch), which can be reached
470-
at `https://104.197.5.247/api/v1/namespaces/kube-system/services/elasticsearch-logging/proxy/` if suitable credentials are passed. Logging can also be reached through a kubectl proxy, for example at:
471-
`http://localhost:8080/api/v1/namespaces/kube-system/services/elasticsearch-logging/proxy/`.
472-
(See [Access Clusters Using the Kubernetes API](/docs/tasks/administer-cluster/access-cluster-api/) for how to pass credentials or use kubectl proxy.)
473-
-->
474-
这展示了访问每个服务的 proxy-verb URL。
475-
例如,如果集群启动了集群级别的日志(使用 Elasticsearch),并且传递合适的凭证,
476-
那么可以通过
477-
`https://104.197.5.247/api/v1/namespaces/kube-system/services/elasticsearch-logging/proxy/`
478-
进行访问。日志也能通过 kubectl 代理获取,例如:
479-
`http://localhost:8080/api/v1/namespaces/kube-system/services/elasticsearch-logging/proxy/`
480-
(参阅[使用 Kubernetes API 访问集群](/zh/docs/tasks/administer-cluster/access-cluster-api/)
481-
了解如何传递凭据,或者使用 kubectl proxy)
482-
<!--
483-
#### Manually constructing apiserver proxy URLs
484-
485-
As mentioned above, you use the `kubectl cluster-info` command to retrieve the service's proxy URL. To create proxy URLs that include service endpoints, suffixes, and parameters, you append to the service's proxy URL:
486-
`http://`*`kubernetes_master_address`*`/api/v1/namespaces/`*`namespace_name`*`/services/`*`service_name[:port_name]`*`/proxy`
487-
488-
If you haven't specified a name for your port, you don't have to specify *port_name* in the URL. You can also use the port number in place of the *port_name* for both named and unnamed ports.
489-
490-
By default, the API server proxies to your service using http. To use https, prefix the service name with `https:`:
491-
`http://`*`kubernetes_master_address`*`/api/v1/namespaces/`*`namespace_name`*`/services/`*`https:service_name:[port_name]`*`/proxy`
492-
493-
The supported formats for the name segment of the URL are:
494-
495-
* `<service_name>` - proxies to the default or unnamed port using http
496-
* `<service_name>:<port_name>` - proxies to the specified port name or port number using http
497-
* `https:<service_name>:` - proxies to the default or unnamed port using https (note the trailing colon)
498-
* `https:<service_name>:<port_name>` - proxies to the specified port name or port number using https
499-
-->
500-
#### 手动构建 apiserver 代理 URL {#manually-constructing-apiserver-proxy-urls}
501-
502-
如上所述,你可以使用 `kubectl cluster-info` 命令来获得服务的代理 URL。
503-
要创建包含服务端点、后缀和参数的代理 URL,需添加到服务的代理 URL:
504-
`http://`*`kubernetes_master_address`*`/api/v1/namespaces/`*`namespace_name`*`/services/`*`service_name[:port_name]`*`/proxy`
505-
506-
如果尚未为端口指定名称,则不必在 URL 中指定 *port_name*
507-
对于已命名和未命名的端口,也可以使用端口号代替 *port_name*
508-
509-
默认情况下,API server 使用 HTTP 代理你的服务。
510-
要使用 HTTPS,请在服务名称前加上 `https:`
511-
`http://`*`kubernetes_master_address`*`/api/v1/namespaces/`*`namespace_name`*`/services/`*`https:service_name:[port_name]`*`/proxy`
512-
513-
URL 名称段支持的格式为:
514-
515-
* `<service_name>` - 使用 http 代理到默认或未命名的端口
516-
* `<service_name>:<port_name>` - 使用 http 代理到指定的端口名称或端口号
517-
* `https:<service_name>:` - 使用 https 代理到默认或未命名的端口(注意后面的冒号)
518-
* `https:<service_name>:<port_name>` - 使用 https 代理到指定的端口名称或端口号
519-
520-
<!--
521-
##### Examples
522-
523-
* To access the Elasticsearch service endpoint `_search?q=user:kimchy`, you would use: `http://104.197.5.247/api/v1/namespaces/kube-system/services/elasticsearch-logging/proxy/_search?q=user:kimchy`
524-
* To access the Elasticsearch cluster health information `_cluster/health?pretty=true`, you would use: `https://104.197.5.247/api/v1/namespaces/kube-system/services/elasticsearch-logging/proxy/_cluster/health?pretty=true`
525-
-->
526-
##### 示例
527-
528-
* 要访问 Elasticsearch 服务端点 `_search?q=user:kimchy`,你需要使用:
529-
`http://104.197.5.247/api/v1/namespaces/kube-system/services/elasticsearch-logging/proxy/_search?q=user:kimchy`
530-
* 要访问 Elasticsearch 集群健康信息 `_cluster/health?pretty=true`,你需要使用:
531-
`https://104.197.5.247/api/v1/namespaces/kube-system/services/elasticsearch-logging/proxy/_cluster/health?pretty=true`
532-
533-
```json
534-
{
535-
"cluster_name" : "kubernetes_logging",
536-
"status" : "yellow",
537-
"timed_out" : false,
538-
"number_of_nodes" : 1,
539-
"number_of_data_nodes" : 1,
540-
"active_primary_shards" : 5,
541-
"active_shards" : 5,
542-
"relocating_shards" : 0,
543-
"initializing_shards" : 0,
544-
"unassigned_shards" : 5
545-
}
546-
```
547-
548-
<!--
549-
### Using web browsers to access services running on the cluster
550-
551-
You may be able to put an apiserver proxy url into the address bar of a browser. However:
552-
553-
- Web browsers cannot usually pass tokens, so you may need to use basic (password) auth. Apiserver can be configured to accept basic auth,
554-
but your cluster may not be configured to accept basic auth.
555-
- Some web apps may not work, particularly those with client side javascript that construct urls in a
556-
way that is unaware of the proxy path prefix.
557-
-->
558-
### 使用 web 浏览器访问运行在集群上的服务
559-
560-
你可以在浏览器地址栏中输入 apiserver 代理 URL。但是:
363+
上一节介绍了如何连接到 Kubernetes API 服务器。
364+
有关连接到 Kubernetes 集群上运行的其他服务的信息,请参阅[访问集群服务](/zh/docs/tasks/administer-cluster/access-cluster-services/)
561365

562-
- Web 浏览器通常不能传递令牌,因此你可能需要使用基本(密码)身份验证。
563-
Apiserver 可以配置为接受基本身份验证,但你的集群可能未进行配置。
564-
- 某些 Web 应用程序可能无法运行,尤其是那些使用客户端 javascript
565-
以不知道代理路径前缀的方式构建 URL 的应用程序。
566366

567367
<!--
568368
## Requesting redirects

0 commit comments

Comments
 (0)