committed by
Kubernetes Prow Robot
parent
0268ed0c18
commit
b05129acc3
@@ -313,7 +313,7 @@ such as your desktop machine.
|
||||
-->
|
||||
## 访问集群中正在运行的服务
|
||||
|
||||
上一节介绍了如何连接 Kubernetes API 服务。本节介绍如何连接到 Kubernetes 集群上运行的其他服务。
|
||||
上一节介绍了如何连接 Kubernetes API 服务。本节介绍如何连接到 Kubernetes 集群上运行的其他服务。
|
||||
在 Kubernetes 中,[节点](/docs/admin/node),[pods](/docs/user-guide/pods) 和 [服务](/docs/user-guide/services) 都有自己的 IP。
|
||||
在许多情况下,集群上的节点 IP,pod IP 和某些服务 IP 将无法路由,因此无法从集群外部的计算机(例如桌面计算机)访问它们。
|
||||
|
||||
@@ -499,14 +499,14 @@ The redirect capabilities have been deprecated and removed. Please use a proxy
|
||||
There are several different proxies you may encounter when using Kubernetes:
|
||||
|
||||
1. The [kubectl proxy](#directly-accessing-the-rest-api):
|
||||
|
||||
|
||||
- runs on a user's desktop or in a pod
|
||||
- proxies from a localhost address to the Kubernetes apiserver
|
||||
- client to proxy uses HTTP
|
||||
- proxy to apiserver uses HTTPS
|
||||
- locates apiserver
|
||||
- adds authentication headers
|
||||
|
||||
|
||||
-->
|
||||
## 多种代理
|
||||
|
||||
@@ -520,10 +520,10 @@ There are several different proxies you may encounter when using Kubernetes:
|
||||
- 代理到 apiserver 使用 HTTPS
|
||||
- 定位 apiserver
|
||||
- 添加身份验证 header
|
||||
|
||||
|
||||
<!--
|
||||
1. The [apiserver proxy](#discovering-builtin-services):
|
||||
|
||||
|
||||
- is a bastion built into the apiserver
|
||||
- connects a user outside of the cluster to cluster IPs which otherwise might not be reachable
|
||||
- runs in the apiserver processes
|
||||
@@ -541,10 +541,10 @@ There are several different proxies you may encounter when using Kubernetes:
|
||||
- 代理将根据可用的信息决定使用 HTTP 或者 HTTPS 代理到目标
|
||||
- 可用于访问节点、Pod 或服务
|
||||
- 在访问服务时进行负载平衡
|
||||
|
||||
|
||||
<!--
|
||||
1. The [kube proxy](/docs/concepts/services-networking/service/#ips-and-vips):
|
||||
|
||||
|
||||
- runs on each node
|
||||
- proxies UDP and TCP
|
||||
- does not understand HTTP
|
||||
@@ -552,29 +552,29 @@ There are several different proxies you may encounter when using Kubernetes:
|
||||
- is just used to reach services
|
||||
-->
|
||||
1. [kube proxy](/docs/concepts/services-networking/service/#ips-and-vips):
|
||||
|
||||
|
||||
- 运行在每个节点上
|
||||
- 代理 UDP 和 TCP
|
||||
- 不能代理 HTTP
|
||||
- 提供负载均衡
|
||||
- 只能用来访问服务
|
||||
|
||||
|
||||
<!--
|
||||
1. A Proxy/Load-balancer in front of apiserver(s):
|
||||
|
||||
|
||||
- existence and implementation varies from cluster to cluster (e.g. nginx)
|
||||
- sits between all clients and one or more apiservers
|
||||
- acts as load balancer if there are several apiservers.
|
||||
-->
|
||||
1. 位于 apiserver 之前的 Proxy/Load-balancer:
|
||||
|
||||
|
||||
- 存在和实现因集群而异(例如 nginx)
|
||||
- 位于所有客户和一个或多个 apiserver 之间
|
||||
- 如果有多个 apiserver,则充当负载均衡器
|
||||
|
||||
|
||||
<!--
|
||||
1. Cloud Load Balancers on external services:
|
||||
|
||||
|
||||
- are provided by some cloud providers (e.g. AWS ELB, Google Cloud Load Balancer)
|
||||
- are created automatically when the Kubernetes service has type `LoadBalancer`
|
||||
- use UDP/TCP only
|
||||
@@ -584,7 +584,7 @@ Kubernetes users will typically not need to worry about anything other than the
|
||||
will typically ensure that the latter types are setup correctly.
|
||||
-->
|
||||
1. 外部服务上的云负载均衡器:
|
||||
|
||||
|
||||
- 由一些云提供商提供(例如 AWS ELB,Google Cloud Load Balancer)
|
||||
- 当 Kubernetes 服务类型为 `LoadBalancer` 时自动创建
|
||||
- 只使用 UDP/TCP
|
||||
|
||||
+4
-4
@@ -9,7 +9,7 @@ weight: 90
|
||||
|
||||
{{% capture overview %}}
|
||||
|
||||
<!--
|
||||
<!--
|
||||
Many cloud providers (e.g. Google Compute Engine) define firewalls that help prevent inadvertent
|
||||
exposure to the internet. When exposing a service to the external world, you may need to open up
|
||||
one or more ports in these firewalls to serve traffic. This document describes this process, as
|
||||
@@ -141,15 +141,15 @@ Consider:
|
||||
-->
|
||||
* 因为在防火墙上为集群的所有节点都打开了 80 端口,所以外部的服务可以向你的
|
||||
服务发送数据包。
|
||||
|
||||
<!--
|
||||
|
||||
<!--
|
||||
* You start an nginx server, running on port 80 on the host virtual machine
|
||||
(IP Address 2.3.4.5). This nginx is also exposed to the internet on
|
||||
the VM's external IP address.
|
||||
-->
|
||||
* 最后你又虚拟机上的80端口启动 nginx 服务器(ip地址2.3.4.5)。
|
||||
这个 nginx 在虚拟机的外部 IP 地址上也被暴露到了互联网上。
|
||||
|
||||
|
||||
<!--
|
||||
Consequently, please be careful when opening firewalls in Google Compute Engine
|
||||
or Google Kubernetes Engine. You may accidentally be exposing other services to
|
||||
|
||||
@@ -13,7 +13,7 @@ content_template: templates/concept
|
||||
|
||||
{{% capture overview %}}
|
||||
<!--
|
||||
Kubernetes offers a DNS cluster addon, which most of the supported environments enable by default.
|
||||
Kubernetes offers a DNS cluster addon, which most of the supported environments enable by default.
|
||||
-->
|
||||
Kubernetes 提供 DNS 集群插件,大多数支持的环境默认情况下都会启用。
|
||||
{{% /capture %}}
|
||||
|
||||
+2
-2
@@ -57,7 +57,7 @@ load-balanced access to an application running in a cluster.
|
||||
```
|
||||
kubectl run hello-world --replicas=2 --labels="run=load-balancer-example" --image=gcr.io/google-samples/node-hello:1.0 --port=8080
|
||||
```
|
||||
|
||||
|
||||
<!--
|
||||
1. List the pods that are running the Hello World application:
|
||||
-->
|
||||
@@ -99,7 +99,7 @@ load-balanced access to an application running in a cluster.
|
||||
```
|
||||
kubectl get services example-service
|
||||
```
|
||||
|
||||
|
||||
<!--
|
||||
The output shows the internal IP address and the external IP address of
|
||||
your service. If the external IP address shows as `<pending>`, repeat the
|
||||
|
||||
+10
-10
@@ -53,24 +53,24 @@ for database debugging.
|
||||
查看输出是否成功,以验证是否成功创建 deployment:
|
||||
|
||||
deployment "redis-master" created
|
||||
|
||||
|
||||
<!--
|
||||
When the pod is ready, you can get:
|
||||
-->
|
||||
当 pod 是 ready 时,您将得到:
|
||||
|
||||
|
||||
kubectl get pods
|
||||
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
redis-master-765d459796-258hz 1/1 Running 0 50s
|
||||
|
||||
kubectl get deployment
|
||||
|
||||
|
||||
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
|
||||
redis-master 1 1 1 1 55s
|
||||
|
||||
kubectl get rs
|
||||
|
||||
|
||||
NAME DESIRED CURRENT READY AGE
|
||||
redis-master-765d459796 1 1 1 1m
|
||||
|
||||
@@ -104,9 +104,9 @@ for database debugging.
|
||||
-->
|
||||
3. 验证 Redis 服务是否运行在 pod 中并且监听 6379 端口:
|
||||
|
||||
|
||||
|
||||
kubectl get pods redis-master-765d459796-258hz --template='{{(index (index .spec.containers 0).ports 0).containerPort}}{{"\n"}}'
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
The output displays the port:
|
||||
@@ -125,7 +125,7 @@ for database debugging.
|
||||
|
||||
1. 从 Kubernetes v1.10 开始,`kubectl port-forward` 允许使用资源名称(例如服务名称)来选择匹配的 pod 来进行端口转发。
|
||||
|
||||
kubectl port-forward redis-master-765d459796-258hz 6379:6379
|
||||
kubectl port-forward redis-master-765d459796-258hz 6379:6379
|
||||
|
||||
<!--
|
||||
which is the same as
|
||||
@@ -135,18 +135,18 @@ for database debugging.
|
||||
kubectl port-forward pods/redis-master-765d459796-258hz 6379:6379
|
||||
|
||||
<!--
|
||||
or
|
||||
or
|
||||
-->
|
||||
或者
|
||||
|
||||
kubectl port-forward deployment/redis-master 6379:6379
|
||||
kubectl port-forward deployment/redis-master 6379:6379
|
||||
|
||||
<!--
|
||||
or
|
||||
-->
|
||||
或者
|
||||
|
||||
kubectl port-forward rs/redis-master 6379:6379
|
||||
kubectl port-forward rs/redis-master 6379:6379
|
||||
|
||||
<!--
|
||||
or
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ provides load balancing for an application that has two running instances.
|
||||
1. 在您的集群中运行一个 Hello World 应用:
|
||||
```shell
|
||||
kubectl run hello-world --replicas=2 --labels="run=load-balancer-example" --image=gcr.io/google-samples/node-hello:1.0 --port=8080
|
||||
```
|
||||
```
|
||||
<!--
|
||||
The preceding command creates a
|
||||
[Deployment](/docs/concepts/workloads/controllers/deployment/)
|
||||
|
||||
Reference in New Issue
Block a user