Merge pull request #41001 from Zhuzhenghao/expose-external-ip-address
Cleanup page expose-external-ip-addresspull/41013/head
commit
2849ccec38
|
@ -46,116 +46,116 @@ external IP address.
|
||||||
|
|
||||||
1. Display information about the Deployment:
|
1. Display information about the Deployment:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl get deployments hello-world
|
kubectl get deployments hello-world
|
||||||
kubectl describe deployments hello-world
|
kubectl describe deployments hello-world
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Display information about your ReplicaSet objects:
|
1. Display information about your ReplicaSet objects:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl get replicasets
|
kubectl get replicasets
|
||||||
kubectl describe replicasets
|
kubectl describe replicasets
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Create a Service object that exposes the deployment:
|
1. Create a Service object that exposes the deployment:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl expose deployment hello-world --type=LoadBalancer --name=my-service
|
kubectl expose deployment hello-world --type=LoadBalancer --name=my-service
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Display information about the Service:
|
1. Display information about the Service:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl get services my-service
|
kubectl get services my-service
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is similar to:
|
The output is similar to:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||||
my-service LoadBalancer 10.3.245.137 104.198.205.71 8080/TCP 54s
|
my-service LoadBalancer 10.3.245.137 104.198.205.71 8080/TCP 54s
|
||||||
```
|
```
|
||||||
|
|
||||||
{{< note >}}
|
{{< note >}}
|
||||||
|
|
||||||
The `type=LoadBalancer` service is backed by external cloud providers, which is not covered in this example, please refer to [this page](/docs/concepts/services-networking/service/#loadbalancer) for the details.
|
The `type=LoadBalancer` service is backed by external cloud providers, which is not covered in this example, please refer to [this page](/docs/concepts/services-networking/service/#loadbalancer) for the details.
|
||||||
|
|
||||||
{{< /note >}}
|
{{< /note >}}
|
||||||
|
|
||||||
{{< note >}}
|
{{< note >}}
|
||||||
|
|
||||||
If the external IP address is shown as \<pending\>, wait for a minute and enter the same command again.
|
If the external IP address is shown as \<pending\>, wait for a minute and enter the same command again.
|
||||||
|
|
||||||
{{< /note >}}
|
{{< /note >}}
|
||||||
|
|
||||||
1. Display detailed information about the Service:
|
1. Display detailed information about the Service:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl describe services my-service
|
kubectl describe services my-service
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is similar to:
|
The output is similar to:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
Name: my-service
|
Name: my-service
|
||||||
Namespace: default
|
Namespace: default
|
||||||
Labels: app.kubernetes.io/name=load-balancer-example
|
Labels: app.kubernetes.io/name=load-balancer-example
|
||||||
Annotations: <none>
|
Annotations: <none>
|
||||||
Selector: app.kubernetes.io/name=load-balancer-example
|
Selector: app.kubernetes.io/name=load-balancer-example
|
||||||
Type: LoadBalancer
|
Type: LoadBalancer
|
||||||
IP: 10.3.245.137
|
IP: 10.3.245.137
|
||||||
LoadBalancer Ingress: 104.198.205.71
|
LoadBalancer Ingress: 104.198.205.71
|
||||||
Port: <unset> 8080/TCP
|
Port: <unset> 8080/TCP
|
||||||
NodePort: <unset> 32377/TCP
|
NodePort: <unset> 32377/TCP
|
||||||
Endpoints: 10.0.0.6:8080,10.0.1.6:8080,10.0.1.7:8080 + 2 more...
|
Endpoints: 10.0.0.6:8080,10.0.1.6:8080,10.0.1.7:8080 + 2 more...
|
||||||
Session Affinity: None
|
Session Affinity: None
|
||||||
Events: <none>
|
Events: <none>
|
||||||
```
|
```
|
||||||
|
|
||||||
Make a note of the external IP address (`LoadBalancer Ingress`) exposed by
|
Make a note of the external IP address (`LoadBalancer Ingress`) exposed by
|
||||||
your service. In this example, the external IP address is 104.198.205.71.
|
your service. In this example, the external IP address is 104.198.205.71.
|
||||||
Also note the value of `Port` and `NodePort`. In this example, the `Port`
|
Also note the value of `Port` and `NodePort`. In this example, the `Port`
|
||||||
is 8080 and the `NodePort` is 32377.
|
is 8080 and the `NodePort` is 32377.
|
||||||
|
|
||||||
1. In the preceding output, you can see that the service has several endpoints:
|
1. In the preceding output, you can see that the service has several endpoints:
|
||||||
10.0.0.6:8080,10.0.1.6:8080,10.0.1.7:8080 + 2 more. These are internal
|
10.0.0.6:8080,10.0.1.6:8080,10.0.1.7:8080 + 2 more. These are internal
|
||||||
addresses of the pods that are running the Hello World application. To
|
addresses of the pods that are running the Hello World application. To
|
||||||
verify these are pod addresses, enter this command:
|
verify these are pod addresses, enter this command:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl get pods --output=wide
|
kubectl get pods --output=wide
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is similar to:
|
The output is similar to:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
NAME ... IP NODE
|
NAME ... IP NODE
|
||||||
hello-world-2895499144-1jaz9 ... 10.0.1.6 gke-cluster-1-default-pool-e0b8d269-1afc
|
hello-world-2895499144-1jaz9 ... 10.0.1.6 gke-cluster-1-default-pool-e0b8d269-1afc
|
||||||
hello-world-2895499144-2e5uh ... 10.0.1.8 gke-cluster-1-default-pool-e0b8d269-1afc
|
hello-world-2895499144-2e5uh ... 10.0.1.8 gke-cluster-1-default-pool-e0b8d269-1afc
|
||||||
hello-world-2895499144-9m4h1 ... 10.0.0.6 gke-cluster-1-default-pool-e0b8d269-5v7a
|
hello-world-2895499144-9m4h1 ... 10.0.0.6 gke-cluster-1-default-pool-e0b8d269-5v7a
|
||||||
hello-world-2895499144-o4z13 ... 10.0.1.7 gke-cluster-1-default-pool-e0b8d269-1afc
|
hello-world-2895499144-o4z13 ... 10.0.1.7 gke-cluster-1-default-pool-e0b8d269-1afc
|
||||||
hello-world-2895499144-segjf ... 10.0.2.5 gke-cluster-1-default-pool-e0b8d269-cpuc
|
hello-world-2895499144-segjf ... 10.0.2.5 gke-cluster-1-default-pool-e0b8d269-cpuc
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Use the external IP address (`LoadBalancer Ingress`) to access the Hello
|
1. Use the external IP address (`LoadBalancer Ingress`) to access the Hello
|
||||||
World application:
|
World application:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
curl http://<external-ip>:<port>
|
curl http://<external-ip>:<port>
|
||||||
```
|
```
|
||||||
|
|
||||||
where `<external-ip>` is the external IP address (`LoadBalancer Ingress`)
|
where `<external-ip>` is the external IP address (`LoadBalancer Ingress`)
|
||||||
of your Service, and `<port>` is the value of `Port` in your Service
|
of your Service, and `<port>` is the value of `Port` in your Service
|
||||||
description.
|
description.
|
||||||
If you are using minikube, typing `minikube service my-service` will
|
If you are using minikube, typing `minikube service my-service` will
|
||||||
automatically open the Hello World application in a browser.
|
automatically open the Hello World application in a browser.
|
||||||
|
|
||||||
The response to a successful request is a hello message:
|
The response to a successful request is a hello message:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
Hello Kubernetes!
|
Hello Kubernetes!
|
||||||
```
|
```
|
||||||
|
|
||||||
## {{% heading "cleanup" %}}
|
## {{% heading "cleanup" %}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue